Documentation
¶
Overview ¶
Skip List implement in Go.
A Skip List is a data structure that allows fast search within an ordered sequence of elements. Fast search is made possible by maintaining a linked hierarchy of subsequences, each skipping over fewer elements.
This Implementation is Partially Concurrent: It supports a single writer and multiple concurrent readers. Readers can access the Skiplist without locking.
Index ¶
- Constants
- Variables
- type Skiplist
- func (b *Skiplist) Delete(searchKey interface{}) error
- func (b *Skiplist) DisplayAll()
- func (b *Skiplist) Insert(searchKey interface{}, value interface{})
- func (b *Skiplist) RandomLevel() int
- func (b *Skiplist) Search(searchKey interface{}) (interface{}, error)
- func (b *Skiplist) SetMaxLevel(maxLevel int)
- type Skipnode
Constants ¶
View Source
const ( DefaultMaxLevel int = 15 //Maximal level allow to create in this skip list DefaultPropability float32 = 0.25 //Default Propability )
Variables ¶
View Source
var (
ErrNotFound = errors.New("Not found.")
)
Functions ¶
This section is empty.
Types ¶
type Skiplist ¶
type Skiplist struct {
Header *Skipnode
// List configuration
MaxLevel int
Propability float32
// List Comparison
Comparator utils.Comparator
// List status
Level int //current level of whole skiplist
Random *rand.Rand
}
func NewSkipList ¶
func NewSkipList(comparator utils.Comparator) *Skiplist
NewSkipList : Init structure for Skit List.
func (*Skiplist) DisplayAll ¶
func (b *Skiplist) DisplayAll()
DisplayAll: Display current SkipList content in console, will also print out the linked pointer.
func (*Skiplist) Insert ¶
func (b *Skiplist) Insert(searchKey interface{}, value interface{})
Insert: Insert a search key and its value which could be interface.
func (*Skiplist) RandomLevel ¶
func (*Skiplist) SetMaxLevel ¶
Change SkipList default maxlevel is 4.
Click to show internal directories.
Click to hide internal directories.