Documentation ¶
Overview ¶
Package skiplist implements a skiplist. See https://en.wikipedia.org/wiki/Skip_list for more details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[T constraints.Ordered] struct { // contains filtered or unexported fields }
Node represents node of a list.
type SkipList ¶
type SkipList[T constraints.Ordered] struct { // contains filtered or unexported fields }
SkipList represents a skiplist. Zero value of SkipList is invalid skiplist, should be used only with New() or NewWithProbability().
func New ¶
func New[T constraints.Ordered]() *SkipList[T]
New returns an initialized skiplist with probability = 0.5.
func NewWithProbability ¶
func NewWithProbability[T constraints.Ordered](p float64) *SkipList[T]
NewWithProbability returns an initialized skiplist with given probability.
func (*SkipList[T]) All ¶
func (s *SkipList[T]) All() []T
All returns all elements from the skiplist.
func (*SkipList[T]) Contains ¶
Contains returns true if skiplist contains given value, false otherwise.
Click to show internal directories.
Click to hide internal directories.