Documentation ¶
Index ¶
- type NetRadixTree
- func (rtree *NetRadixTree) Add(addr, udata string) error
- func (rtree *NetRadixTree) Close()
- func (rtree *NetRadixTree) Remove(addr string) error
- func (rtree *NetRadixTree) SearchBest(addr string) (found bool, udata string, err error)
- func (rtree *NetRadixTree) SearchExact(addr string) (found bool, udata string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetRadixTree ¶
type NetRadixTree struct {
// contains filtered or unexported fields
}
func NewNetRadixTree ¶
func NewNetRadixTree() (*NetRadixTree, error)
NewNetRadixTree creates new NetRadixTree structure. Return tuple in which the first element specifies tree structure and the second element specifies error object or nil if no error has occured.
func (*NetRadixTree) Add ¶
func (rtree *NetRadixTree) Add(addr, udata string) error
Add adds network or subnet specification and user defined payload string to the radix tree. If no mask width is specified, the longest possible mask is assumed, i.e. 32 bits for IPv4 network and 128 bits for IPv6 network. On success, returns nil, otherwise returns error object.
func (*NetRadixTree) Remove ¶
func (rtree *NetRadixTree) Remove(addr string) error
Remove deletes a node which exactly matches the address given. If no errors occured returns nil or error object otherwise.
func (*NetRadixTree) SearchBest ¶
func (rtree *NetRadixTree) SearchBest(addr string) (found bool, udata string, err error)
SearchBest searches radix tree to find a matching node using usual subnetting rules for the address specified. If no mask width is specified, the longest possible mask for this type of address (IPv4 or IPv6) is assumed. Returns triple in which the first element indicates success of a search, the second element returns user payload (or empty string if not found) and the third element returns error object in case such an error occured or nil otherwise.
func (*NetRadixTree) SearchExact ¶
func (rtree *NetRadixTree) SearchExact(addr string) (found bool, udata string, err error)
SearchExact searches radix tree to find a matching node. Its semantics are the same as in SearchBest() method except that the addr must match a node exactly.