skiplist

package
v0.0.0-...-e5a160e Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_LEVEL = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesComparator

type BytesComparator struct {
}

func (*BytesComparator) Compare

func (self *BytesComparator) Compare(a, b interface{}) int

type Comparator

type Comparator interface {
	// NOTE: skiplist will be ascending order if a < b, otherwise descending
	Compare(interface{}, interface{}) int
}

type IntComparator

type IntComparator struct {
}

func (*IntComparator) Compare

func (self *IntComparator) Compare(a, b interface{}) int

type SkipList

type SkipList struct {
	Header     *SkipListNode
	Tail       *SkipListNode
	Length     int
	MaxLevel   int
	Level      int
	Comparator Comparator
}

func NewSkipList

func NewSkipList(c Comparator) *SkipList

func (*SkipList) Delete

func (self *SkipList) Delete(score interface{})

func (*SkipList) Insert

func (self *SkipList) Insert(score, data interface{})

func (*SkipList) Iterator

func (self *SkipList) Iterator() *SkipListIterator

type SkipListIterator

type SkipListIterator struct {
	Node   *SkipListNode
	Parent *SkipList
}

func (*SkipListIterator) Key

func (self *SkipListIterator) Key() interface{}

func (*SkipListIterator) Next

func (self *SkipListIterator) Next()

func (*SkipListIterator) Rewind

func (self *SkipListIterator) Rewind()

func (*SkipListIterator) Seek

func (self *SkipListIterator) Seek(score interface{})

func (*SkipListIterator) Valid

func (self *SkipListIterator) Valid() bool

func (*SkipListIterator) Value

func (self *SkipListIterator) Value() interface{}

type SkipListLevel

type SkipListLevel struct {
	Forward *SkipListNode
	Span    int
}

type SkipListNode

type SkipListNode struct {
	Score interface{}
	Data  interface{}
	Level map[int]*SkipListLevel
}

func CreateSkiplistNode

func CreateSkiplistNode(level int, score interface{}, data interface{}) (*SkipListNode, error)

type StringComparator

type StringComparator struct {
}

func (*StringComparator) Compare

func (self *StringComparator) Compare(a, b interface{}) int

Jump to

Keyboard shortcuts

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