Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultMaxLevel = 32
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator interface {
// Next returns true if the iterator contains subsequent elements
// and advances its state to the next element if that is possible.
Next() (ok bool)
// Previous returns true if the iterator contains previous elements
// and rewinds its state to the previous element if that is possible.
Previous() (ok bool)
// Key returns the current key.
Key() interface{}
// Value returns the current value.
Value() interface{}
// Seek reduces iterative seek costs for searching forward into the Skip List
// by remarking the range of keys over which it has scanned before. If the
// requested key occurs prior to the point, the Skip List will start searching
// as a safeguard. It returns true if the key is within the known range of the list.
Seek(key interface{}) (ok bool)
// Close this iterator to reap resources associated with it. While not
// strictly required, it will provide extra hints for the garbage collector.
Close()
}
Iterator is an interface that you can use to iterate through the skip list (in its entirety or fragments).
type Ordered ¶
Ordered is an interface which can be linearly ordered by the LessThan method, whereby this instance is deemed to be less than other. Additionally, Ordered instances should behave properly when compared using == and !=.
type SkipList ¶
type SkipList struct {
// max level
MaxLevel int
// contains filtered or unexported fields
}
Skip list that maintains an ordered collection of key-value pairs
func New ¶
func New() *SkipList
New returns a new SkipList. Its keys must implement the Ordered interface.
func NewStringSkipList ¶
func NewStringSkipList() *SkipList
returns a SkipList that accepts string keys.
Click to show internal directories.
Click to hide internal directories.