Documentation
¶
Index ¶
- Constants
- type Element
- type Interface
- type SkipList
- func (sl *SkipList[T]) Back() *Element[T]
- func (sl *SkipList[T]) Delete(v T) (res T)
- func (sl *SkipList[T]) Find(v T) *Element[T]
- func (sl *SkipList[T]) Front() *Element[T]
- func (sl *SkipList[T]) GetElementByRank(rank int) *Element[T]
- func (sl *SkipList[T]) GetRank(v T) int
- func (sl *SkipList[T]) Init() *SkipList[T]
- func (sl *SkipList[T]) Insert(v T) *Element[T]
- func (sl *SkipList[T]) Len() int
- func (sl *SkipList[T]) Remove(e *Element[T]) (res T)
Constants ¶
View Source
const SKIPLIST_BRANCH = 4
View Source
const SKIPLIST_MAXLEVEL = 32
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[T Interface[T]] struct { Value T // contains filtered or unexported fields }
type SkipList ¶
type SkipList[T Interface[T]] struct { // contains filtered or unexported fields }
func (*SkipList[T]) Delete ¶
func (sl *SkipList[T]) Delete(v T) (res T)
Delete deletes an element e that e.Value == v, and returns e.Value or zero T value.
func (*SkipList[T]) GetElementByRank ¶
GetElementByRank finds an element by ites rank. The rank argument needs bo be 1-based. Note that is the first element e that GetRank(e.Value) == rank, and returns e or nil.
func (*SkipList[T]) GetRank ¶
GetRank finds the rank for an element e that e.Value == v, Returns 0 when the element cannot be found, rank otherwise. Note that the rank is 1-based due to the span of sl.header to the first element.
func (*SkipList[T]) Insert ¶
Insert inserts v, increments sl.length, and returns a new element of wrap v.
Click to show internal directories.
Click to hide internal directories.