tree

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: BSD-3-Clause Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedTrunk

type CachedTrunk struct {
	*SimpleTrunk
	// contains filtered or unexported fields
}

CachedTrunk is a Trunk with a LRU cache

func NewCachedTrunk

func NewCachedTrunk(size int, numberOfFullList int) (*CachedTrunk, error)

NewCachedTrunk returns a new CachedTrunk

func (*CachedTrunk) Get

func (c *CachedTrunk) Get(ip net.IP) (interface{}, bool)

type Leaf

type Leaf struct {
	Netmask *net.IPNet
	Data    interface{}
}

Leaf is the end of a tree path

type Node

type Node struct {
	Name  byte
	Sons  Nodes
	Leafs []*Leaf
	// contains filtered or unexported fields
}

func NewNode

func NewNode(name byte, full bool) *Node

func (*Node) Son

func (n *Node) Son(a byte) *Node

func (*Node) SonOrNew

func (n *Node) SonOrNew(a byte, full bool) *Node

type Nodes

type Nodes []*Node

func (Nodes) Len

func (n Nodes) Len() int

func (Nodes) Less

func (n Nodes) Less(i, j int) bool

func (Nodes) Swap

func (n Nodes) Swap(i, j int)

type SimpleTrunk

type SimpleTrunk struct {
	*Node
	// contains filtered or unexported fields
}

SimpleTrunk is a naïve Trunk, without any cache

func NewTrunk

func NewTrunk(numberOfFullList int) *SimpleTrunk

NewTrunk returns a new Trunk

func (*SimpleTrunk) Append

func (t *SimpleTrunk) Append(nm *net.IPNet, data interface{})

func (*SimpleTrunk) Dump

func (t *SimpleTrunk) Dump(w io.Writer)

func (*SimpleTrunk) Get

func (t *SimpleTrunk) Get(ip net.IP) (interface{}, bool)

func (*SimpleTrunk) Size

func (t *SimpleTrunk) Size() int

type Trunk

type Trunk interface {
	// Append an IP network, and a payload
	Append(nm *net.IPNet, data interface{})
	// Get an IP, return a payload, and a boolean, true if the IP is in a registered network
	Get(ip net.IP) (interface{}, bool)
	// Size is the number of networks
	Size() int
	// Dump the tree, for debugging purpose
	Dump(w io.Writer)
}

Trunk is the start of a tree storage

Jump to

Keyboard shortcuts

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