interval_tree

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README

区间树

用于处理 IP地址到国家的查找

例如: IP [A,B] -> CN

一个IP区间,对应一个国家

Documentation

Index

Constants

View Source
const (
	RED = iota
	BLACK
)

Variables

This section is empty.

Functions

func M

func M(n *Node) int64

func Max

func Max(a, b int64) int64

Types

type Node

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

func (*Node) Data

func (n *Node) Data() interface{}

type Tree

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

func (*Tree) DeleteNode

func (t *Tree) DeleteNode(n *Node)

func (*Tree) Insert

func (t *Tree) Insert(low, high int64, data interface{})

*

  • Insert
  • insert range [low, high] into red-black tree

func (*Tree) Lookup

func (t *Tree) Lookup(low, high int64) *Node

*

  • interval tree lookup function *
  • search range [low, high] for overlap, return only one element
  • use lookup & delete & insert schema to get multiple elements *
  • nil is returned if not found.

Jump to

Keyboard shortcuts

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