Documentation ¶
Index ¶
- type FilterFunc
- type MatchesFunc
- type TreeIteratorV4
- func (iter *TreeIteratorV4[T]) Address() patricia.IPv4Address
- func (iter *TreeIteratorV4[T]) Delete(matchFunc MatchesFunc[T], matchVal T) int
- func (iter *TreeIteratorV4[T]) DeleteWithBuffer(buf []T, matchFunc MatchesFunc[T], matchVal T) int
- func (iter *TreeIteratorV4[T]) Next() bool
- func (iter *TreeIteratorV4[T]) Tags() []T
- func (iter *TreeIteratorV4[T]) TagsWithBuffer(ret []T) []T
- type TreeIteratorV6
- func (iter *TreeIteratorV6[T]) Address() patricia.IPv6Address
- func (iter *TreeIteratorV6[T]) Delete(matchFunc MatchesFunc[T], matchVal T) int
- func (iter *TreeIteratorV6[T]) DeleteWithBuffer(buf []T, matchFunc MatchesFunc[T], matchVal T) int
- func (iter *TreeIteratorV6[T]) Next() bool
- func (iter *TreeIteratorV6[T]) Tags() []T
- func (iter *TreeIteratorV6[T]) TagsWithBuffer(ret []T) []T
- type TreeV4
- func (t *TreeV4[T]) Add(address patricia.IPv4Address, tag T, matchFunc MatchesFunc[T]) (bool, int)
- func (t *TreeV4[T]) AddOrUpdate(address patricia.IPv4Address, tag T, matchFunc MatchesFunc[T], ...) (bool, int)
- func (t *TreeV4[T]) Clone() *TreeV4[T]
- func (t *TreeV4[T]) CountTags() int
- func (t *TreeV4[T]) Delete(address patricia.IPv4Address, matchFunc MatchesFunc[T], matchVal T) int
- func (t *TreeV4[T]) DeleteWithBuffer(buf []T, address patricia.IPv4Address, matchFunc MatchesFunc[T], matchVal T) int
- func (t *TreeV4[T]) FindDeepestTag(address patricia.IPv4Address) (bool, T)
- func (t *TreeV4[T]) FindDeepestTags(address patricia.IPv4Address) (bool, []T)
- func (t *TreeV4[T]) FindDeepestTagsAppend(ret []T, address patricia.IPv4Address) (bool, []T)
- func (t *TreeV4[T]) FindDeepestTagsWithFilter(address patricia.IPv4Address, filterFunc FilterFunc[T]) (bool, []T)
- func (t *TreeV4[T]) FindDeepestTagsWithFilterAppend(ret []T, address patricia.IPv4Address, filterFunc FilterFunc[T]) (bool, []T)
- func (t *TreeV4[T]) FindTags(address patricia.IPv4Address) []T
- func (t *TreeV4[T]) FindTagsAppend(ret []T, address patricia.IPv4Address) []T
- func (t *TreeV4[T]) FindTagsWithFilter(address patricia.IPv4Address, filterFunc FilterFunc[T]) []T
- func (t *TreeV4[T]) FindTagsWithFilterAppend(ret []T, address patricia.IPv4Address, filterFunc FilterFunc[T]) []T
- func (t *TreeV4[T]) Iterate() *TreeIteratorV4[T]
- func (t *TreeV4[T]) Set(address patricia.IPv4Address, tag T) (bool, int)
- func (t *TreeV4[T]) SetOrUpdate(address patricia.IPv4Address, tag T, updateFunc UpdatesFunc[T]) (bool, int)
- type TreeV6
- func (t *TreeV6[T]) Add(address patricia.IPv6Address, tag T, matchFunc MatchesFunc[T]) (bool, int)
- func (t *TreeV6[T]) AddOrUpdate(address patricia.IPv6Address, tag T, matchFunc MatchesFunc[T], ...) (bool, int)
- func (t *TreeV6[T]) Clone() *TreeV6[T]
- func (t *TreeV6[T]) CountTags() int
- func (t *TreeV6[T]) Delete(address patricia.IPv6Address, matchFunc MatchesFunc[T], matchVal T) int
- func (t *TreeV6[T]) DeleteWithBuffer(buf []T, address patricia.IPv6Address, matchFunc MatchesFunc[T], matchVal T) int
- func (t *TreeV6[T]) FindDeepestTag(address patricia.IPv6Address) (bool, T)
- func (t *TreeV6[T]) FindDeepestTags(address patricia.IPv6Address) (bool, []T)
- func (t *TreeV6[T]) FindDeepestTagsAppend(ret []T, address patricia.IPv6Address) (bool, []T)
- func (t *TreeV6[T]) FindDeepestTagsWithFilter(address patricia.IPv6Address, filterFunc FilterFunc[T]) (bool, []T)
- func (t *TreeV6[T]) FindDeepestTagsWithFilterAppend(ret []T, address patricia.IPv6Address, filterFunc FilterFunc[T]) (bool, []T)
- func (t *TreeV6[T]) FindTags(address patricia.IPv6Address) []T
- func (t *TreeV6[T]) FindTagsAppend(ret []T, address patricia.IPv6Address) []T
- func (t *TreeV6[T]) FindTagsWithFilter(address patricia.IPv6Address, filterFunc FilterFunc[T]) []T
- func (t *TreeV6[T]) FindTagsWithFilterAppend(ret []T, address patricia.IPv6Address, filterFunc FilterFunc[T]) []T
- func (t *TreeV6[T]) Iterate() *TreeIteratorV6[T]
- func (t *TreeV6[T]) Set(address patricia.IPv6Address, tag T) (bool, int)
- func (t *TreeV6[T]) SetOrUpdate(address patricia.IPv6Address, tag T, updateFunc UpdatesFunc[T]) (bool, int)
- type UpdatesFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc[T] is called on each result to see if it belongs in the resulting set
type MatchesFunc ¶
MatchesFunc[T] is called to check if tag data matches the input value
type TreeIteratorV4 ¶
type TreeIteratorV4[T any] struct { // contains filtered or unexported fields }
TreeIteratorV4[T] is a stateful iterator over a tree.
func (*TreeIteratorV4[T]) Address ¶
func (iter *TreeIteratorV4[T]) Address() patricia.IPv4Address
Address returns the current IP address for the iterator.
func (*TreeIteratorV4[T]) Delete ¶ added in v1.2.1
func (iter *TreeIteratorV4[T]) Delete(matchFunc MatchesFunc[T], matchVal T) int
Delete a tag from the current node if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - use DeleteWithBuffer if you can reuse slices, to cut down on allocations
func (*TreeIteratorV4[T]) DeleteWithBuffer ¶ added in v1.2.1
func (iter *TreeIteratorV4[T]) DeleteWithBuffer(buf []T, matchFunc MatchesFunc[T], matchVal T) int
DeleteWithBuffer a tag from the current node if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - uses input slice to reduce allocations
func (*TreeIteratorV4[T]) Next ¶
func (iter *TreeIteratorV4[T]) Next() bool
Next jumps to the next element of a tree. It returns false if there is none.
func (*TreeIteratorV4[T]) Tags ¶
func (iter *TreeIteratorV4[T]) Tags() []T
Tags returns the current tags for the iterator. This is not a copy and the result should not be used outside the iterator.
func (*TreeIteratorV4[T]) TagsWithBuffer ¶ added in v1.2.1
func (iter *TreeIteratorV4[T]) TagsWithBuffer(ret []T) []T
TagsWithBuffer returns the current tags for the iterator. To avoid allocation, it uses the provided buffer.
type TreeIteratorV6 ¶
type TreeIteratorV6[T any] struct { // contains filtered or unexported fields }
TreeIteratorV6[T] is a stateful iterator over a tree.
func (*TreeIteratorV6[T]) Address ¶
func (iter *TreeIteratorV6[T]) Address() patricia.IPv6Address
Address returns the current IP address for the iterator.
func (*TreeIteratorV6[T]) Delete ¶ added in v1.2.1
func (iter *TreeIteratorV6[T]) Delete(matchFunc MatchesFunc[T], matchVal T) int
Delete a tag from the current node if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - use DeleteWithBuffer if you can reuse slices, to cut down on allocations
func (*TreeIteratorV6[T]) DeleteWithBuffer ¶ added in v1.2.1
func (iter *TreeIteratorV6[T]) DeleteWithBuffer(buf []T, matchFunc MatchesFunc[T], matchVal T) int
DeleteWithBuffer a tag from the current node if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - uses input slice to reduce allocations
func (*TreeIteratorV6[T]) Next ¶
func (iter *TreeIteratorV6[T]) Next() bool
Next jumps to the next element of a tree. It returns false if there is none.
func (*TreeIteratorV6[T]) Tags ¶
func (iter *TreeIteratorV6[T]) Tags() []T
Tags returns the current tags for the iterator. This is not a copy and the result should not be used outside the iterator.
func (*TreeIteratorV6[T]) TagsWithBuffer ¶ added in v1.2.1
func (iter *TreeIteratorV6[T]) TagsWithBuffer(ret []T) []T
TagsWithBuffer returns the current tags for the iterator. To avoid allocation, it uses the provided buffer.
type TreeV4 ¶
type TreeV4[T any] struct { // contains filtered or unexported fields }
TreeV4[T] is an IP Address patricia tree
func (*TreeV4[T]) Add ¶
func (t *TreeV4[T]) Add(address patricia.IPv4Address, tag T, matchFunc MatchesFunc[T]) (bool, int)
Add adds a tag to the tree - if matchFunc is non-nil, it will be used to ensure uniqueness at this node - returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV4[T]) AddOrUpdate ¶ added in v1.2.1
func (t *TreeV4[T]) AddOrUpdate(address patricia.IPv4Address, tag T, matchFunc MatchesFunc[T], updateFunc UpdatesFunc[T]) (bool, int)
AddOrUpdate adds a tag to the tree or update it if it already exists - if matchFunc is non-nil, it will be used to ensure uniqueness at this node - returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV4[T]) Clone ¶
Clone creates an identical copy of the tree - Note: the items in the tree are not deep copied
func (*TreeV4[T]) CountTags ¶
CountTags iterates through the tree, counting the number of tags - note: unused nodes will have TagCount==0
func (*TreeV4[T]) Delete ¶
func (t *TreeV4[T]) Delete(address patricia.IPv4Address, matchFunc MatchesFunc[T], matchVal T) int
Delete a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - use DeleteWithBuffer if you can reuse slices, to cut down on allocations
func (*TreeV4[T]) DeleteWithBuffer ¶
func (t *TreeV4[T]) DeleteWithBuffer(buf []T, address patricia.IPv4Address, matchFunc MatchesFunc[T], matchVal T) int
DeleteWithBuffer a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - uses input slice to reduce allocations
func (*TreeV4[T]) FindDeepestTag ¶
func (t *TreeV4[T]) FindDeepestTag(address patricia.IPv4Address) (bool, T)
FindDeepestTag finds a tag at the deepest level in the tree, representing the closest match. - if that target node has multiple tags, the first in the list is returned
func (*TreeV4[T]) FindDeepestTags ¶
func (t *TreeV4[T]) FindDeepestTags(address patricia.IPv4Address) (bool, []T)
FindDeepestTags finds all tags at the deepest level in the tree, representing the closest match - use FindDeepestTagsAppend if you can reuse slices, to cut down on allocations
func (*TreeV4[T]) FindDeepestTagsAppend ¶
func (t *TreeV4[T]) FindDeepestTagsAppend(ret []T, address patricia.IPv4Address) (bool, []T)
FindDeepestTagsAppend finds all tags at the deepest level in the tree, representing the closest match - appends results to the input slice
func (*TreeV4[T]) FindDeepestTagsWithFilter ¶ added in v1.2.1
func (t *TreeV4[T]) FindDeepestTagsWithFilter(address patricia.IPv4Address, filterFunc FilterFunc[T]) (bool, []T)
FindDeepestTagsWithFilter finds all tags at the deepest level in the tree, matching the provided filter, representing the closest match - use FindDeepestTagsWithFilterAppend if you can reuse slices, to cut down on allocations - returns true regardless of the result of the filtering function
func (*TreeV4[T]) FindDeepestTagsWithFilterAppend ¶ added in v1.2.1
func (t *TreeV4[T]) FindDeepestTagsWithFilterAppend(ret []T, address patricia.IPv4Address, filterFunc FilterFunc[T]) (bool, []T)
FindDeepestTagsWithFilterAppend finds all tags at the deepest level in the tree, matching the provided filter, representing the closest match - appends results to the input slice - returns true regardless of the result of the filtering function
func (*TreeV4[T]) FindTags ¶
func (t *TreeV4[T]) FindTags(address patricia.IPv4Address) []T
FindTags finds all matching tags for given address - use FindTagsAppend if you can reuse slices, to cut down on allocations
func (*TreeV4[T]) FindTagsAppend ¶
func (t *TreeV4[T]) FindTagsAppend(ret []T, address patricia.IPv4Address) []T
FindTagsAppend finds all matching tags for given address and appends them to ret
func (*TreeV4[T]) FindTagsWithFilter ¶
func (t *TreeV4[T]) FindTagsWithFilter(address patricia.IPv4Address, filterFunc FilterFunc[T]) []T
FindTagsWithFilter finds all matching tags that passes the filter function - use FindTagsWithFilterAppend if you can reuse slices, to cut down on allocations
func (*TreeV4[T]) FindTagsWithFilterAppend ¶
func (t *TreeV4[T]) FindTagsWithFilterAppend(ret []T, address patricia.IPv4Address, filterFunc FilterFunc[T]) []T
FindTagsWithFilterAppend finds all matching tags that passes the filter function - results are appended to the input slice
func (*TreeV4[T]) Iterate ¶
func (t *TreeV4[T]) Iterate() *TreeIteratorV4[T]
Iterate returns an iterator to find all nodes from a tree. It is important for the tree to not be modified while using the iterator.
func (*TreeV4[T]) Set ¶
func (t *TreeV4[T]) Set(address patricia.IPv4Address, tag T) (bool, int)
Set the single value for a node - overwrites what's there Returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV4[T]) SetOrUpdate ¶ added in v1.2.1
func (t *TreeV4[T]) SetOrUpdate(address patricia.IPv4Address, tag T, updateFunc UpdatesFunc[T]) (bool, int)
SetOrUpdate the single value for a node - overwrites what's there using updateFunc if present - returns whether the tag count at this address was increased, and how many tags at this address
type TreeV6 ¶
type TreeV6[T any] struct { // contains filtered or unexported fields }
TreeV6[T] is an IP Address patricia tree
func (*TreeV6[T]) Add ¶
func (t *TreeV6[T]) Add(address patricia.IPv6Address, tag T, matchFunc MatchesFunc[T]) (bool, int)
Add adds a tag to the tree - if matchFunc is non-nil, it will be used to ensure uniqueness at this node - returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV6[T]) AddOrUpdate ¶ added in v1.2.1
func (t *TreeV6[T]) AddOrUpdate(address patricia.IPv6Address, tag T, matchFunc MatchesFunc[T], updateFunc UpdatesFunc[T]) (bool, int)
AddOrUpdate adds a tag to the tree or update it if it already exists - if matchFunc is non-nil, it will be used to ensure uniqueness at this node - returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV6[T]) Clone ¶
Clone creates an identical copy of the tree - Note: the items in the tree are not deep copied
func (*TreeV6[T]) CountTags ¶
CountTags iterates through the tree, counting the number of tags - note: unused nodes will have TagCount==0
func (*TreeV6[T]) Delete ¶
func (t *TreeV6[T]) Delete(address patricia.IPv6Address, matchFunc MatchesFunc[T], matchVal T) int
Delete a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - use DeleteWithBuffer if you can reuse slices, to cut down on allocations
func (*TreeV6[T]) DeleteWithBuffer ¶
func (t *TreeV6[T]) DeleteWithBuffer(buf []T, address patricia.IPv6Address, matchFunc MatchesFunc[T], matchVal T) int
DeleteWithBuffer a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - uses input slice to reduce allocations
func (*TreeV6[T]) FindDeepestTag ¶
func (t *TreeV6[T]) FindDeepestTag(address patricia.IPv6Address) (bool, T)
FindDeepestTag finds a tag at the deepest level in the tree, representing the closest match. - if that target node has multiple tags, the first in the list is returned
func (*TreeV6[T]) FindDeepestTags ¶
func (t *TreeV6[T]) FindDeepestTags(address patricia.IPv6Address) (bool, []T)
FindDeepestTags finds all tags at the deepest level in the tree, representing the closest match - use FindDeepestTagsAppend if you can reuse slices, to cut down on allocations
func (*TreeV6[T]) FindDeepestTagsAppend ¶
func (t *TreeV6[T]) FindDeepestTagsAppend(ret []T, address patricia.IPv6Address) (bool, []T)
FindDeepestTagsAppend finds all tags at the deepest level in the tree, representing the closest match - appends results to the input slice
func (*TreeV6[T]) FindDeepestTagsWithFilter ¶ added in v1.2.1
func (t *TreeV6[T]) FindDeepestTagsWithFilter(address patricia.IPv6Address, filterFunc FilterFunc[T]) (bool, []T)
FindDeepestTagsWithFilter finds all tags at the deepest level in the tree, matching the provided filter, representing the closest match - use FindDeepestTagsWithFilterAppend if you can reuse slices, to cut down on allocations - returns true regardless of the result of the filtering function
func (*TreeV6[T]) FindDeepestTagsWithFilterAppend ¶ added in v1.2.1
func (t *TreeV6[T]) FindDeepestTagsWithFilterAppend(ret []T, address patricia.IPv6Address, filterFunc FilterFunc[T]) (bool, []T)
FindDeepestTagsWithFilterAppend finds all tags at the deepest level in the tree, matching the provided filter, representing the closest match - appends results to the input slice - returns true regardless of the result of the filtering function
func (*TreeV6[T]) FindTags ¶
func (t *TreeV6[T]) FindTags(address patricia.IPv6Address) []T
FindTags finds all matching tags for given address - use FindTagsAppend if you can reuse slices, to cut down on allocations
func (*TreeV6[T]) FindTagsAppend ¶
func (t *TreeV6[T]) FindTagsAppend(ret []T, address patricia.IPv6Address) []T
FindTagsAppend finds all matching tags for given address and appends them to ret
func (*TreeV6[T]) FindTagsWithFilter ¶
func (t *TreeV6[T]) FindTagsWithFilter(address patricia.IPv6Address, filterFunc FilterFunc[T]) []T
FindTagsWithFilter finds all matching tags that passes the filter function - use FindTagsWithFilterAppend if you can reuse slices, to cut down on allocations
func (*TreeV6[T]) FindTagsWithFilterAppend ¶
func (t *TreeV6[T]) FindTagsWithFilterAppend(ret []T, address patricia.IPv6Address, filterFunc FilterFunc[T]) []T
FindTagsWithFilterAppend finds all matching tags that passes the filter function - results are appended to the input slice
func (*TreeV6[T]) Iterate ¶
func (t *TreeV6[T]) Iterate() *TreeIteratorV6[T]
Iterate returns an iterator to find all nodes from a tree. It is important for the tree to not be modified while using the iterator.
func (*TreeV6[T]) Set ¶
func (t *TreeV6[T]) Set(address patricia.IPv6Address, tag T) (bool, int)
Set the single value for a node - overwrites what's there Returns whether the tag count at this address was increased, and how many tags at this address
func (*TreeV6[T]) SetOrUpdate ¶ added in v1.2.1
func (t *TreeV6[T]) SetOrUpdate(address patricia.IPv6Address, tag T, updateFunc UpdatesFunc[T]) (bool, int)
SetOrUpdate the single value for a node - overwrites what's there using updateFunc if present - returns whether the tag count at this address was increased, and how many tags at this address
type UpdatesFunc ¶ added in v1.2.1
type UpdatesFunc[T any] func(payload T) T
UpdatesFunc[T] is called to update the tag value