iptree8

package
v0.0.0-...-66ceba8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package iptree8 implements radix tree data structure for IPv4 and IPv6 networks as key and uint8 as value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Key   *net.IPNet
	Value uint8
}

Pair represents a key-value pair returned by Enumerate method.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree is a radix tree for IPv4 and IPv6 networks.

func NewTree

func NewTree() *Tree

NewTree creates empty tree.

func (*Tree) DeleteByIP

func (t *Tree) DeleteByIP(ip net.IP) (*Tree, bool)

DeleteByIP removes node by given IP address. The method returns new tree (old one remains unaffected) and flag indicating if deletion happens indeed.

func (*Tree) DeleteByNet

func (t *Tree) DeleteByNet(n *net.IPNet) (*Tree, bool)

DeleteByNet removes subtree which is contained by given network. The method returns new tree (old one remains unaffected) and flag indicating if deletion happens indeed.

func (*Tree) Enumerate

func (t *Tree) Enumerate() chan Pair

Enumerate returns channel which is populated by key-value pairs of tree content.

func (*Tree) GetByIP

func (t *Tree) GetByIP(ip net.IP) (uint8, bool)

GetByIP gets value for network which is equal to or contains given IP address.

func (*Tree) GetByNet

func (t *Tree) GetByNet(n *net.IPNet) (uint8, bool)

GetByNet gets value for network which is equal to or contains given network.

func (*Tree) InplaceInsertIP

func (t *Tree) InplaceInsertIP(ip net.IP, value uint8)

InplaceInsertIP inserts (or replaces) value using given IP address as a key in current tree.

func (*Tree) InplaceInsertNet

func (t *Tree) InplaceInsertNet(n *net.IPNet, value uint8)

InplaceInsertNet inserts (or replaces) value using given network as a key in current tree.

func (*Tree) InsertIP

func (t *Tree) InsertIP(ip net.IP, value uint8) *Tree

InsertIP inserts value using given IP address as a key. The method returns new tree (old one remains unaffected).

func (*Tree) InsertNet

func (t *Tree) InsertNet(n *net.IPNet, value uint8) *Tree

InsertNet inserts value using given network as a key. The method returns new tree (old one remains unaffected).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL