skiplists

    Dark Mode
Search:
Group by:
  Source   Edit

Types

cmp {.pure.} = enum
  Undefined, Less, Equal, More
Comparisons between SkipLists   Source   Edit
EmptySkipListError {....deprecated.} = SkipListEmptyError
Deprecated
Alias for SkipListEmptyError   Source   Edit
SkipList[T] = ref SkipListObj[T]
  Source   Edit
SkipListCmp[T] = proc (a, b: SkipList[T]): cmp {.noSideEffect.}
The procedure signature to use for comparing two SkipLists.   Source   Edit
SkipListDefect = object of AssertionDefect
A defect was detected in the SkipList implementation.   Source   Edit
SkipListEmptyError = object of ValueError
An empty SkipList is invalid for this operation.   Source   Edit
SkipListError = object of IndexDefect
A specified index that should have existed did not.   Source   Edit
SkipListFind[T] = proc (a: SkipList[T]): cmp {.noSideEffect.}
The procedure signature to use for finding one SkipList.   Source   Edit
SkipListObj[T] = object
  over: SkipList[T]
  down: SkipList[T]
  value*: T
  Source   Edit
SkipListPred[T] = proc (up: SkipList[T]; here: SkipList[T]; child: SkipList[T]): bool
The predicate used to determine whether the SkipList will grow during an add() operation.
up:a larger scope of the SkipList, perhaps top-most
here:a narrower scope of the SkipList
child:a SkipList holding the new value
  Source   Edit

Procs

func `<>`[T](a, b: SkipList[T]): cmp
Compare SkipList a and b.   Source   Edit
proc `<`(a, b: SkipList): bool
true if SkipList a is less than SkipList b, else false.   Source   Edit
func `===`(a, b: SkipList): bool
true if SkipLists a and b share the same memory, else false.   Source   Edit
proc `==`(a, b: SkipList): bool
true if SkipList a is equal to SkipList b, else false.   Source   Edit
proc `==`[T](s: SkipList[T]; q: openArray[T]): bool
true if SkipList s holds the same values as openArray q.   Source   Edit
proc add[T](s: var SkipList[T]; v: T; pred: SkipListPred[T] = defaultPred)
Add a value v into SkipList s.   Source   Edit
proc bottom(s: SkipList): SkipList
Traverse to the longest SkipList, which holds all values.   Source   Edit
proc clear(s: var SkipList)
Empty SkipList s of all entries.   Source   Edit
proc contains[T](s: SkipList[T]; v: T): bool
true if the SkipList s contains value v.

Example:

var s: SkipList[int]
assert 5 notin s
s.add 5
s.add 9
assert 9 in s
assert 5 in s
  Source   Edit
proc count(s: SkipList): int
Count the number of entries in SkipList s.

Example:

var s: SkipList[int]
assert count(s) == 0
s.add 3
assert count(s) == 1
s.add 5
assert count(s) == 2
  Source   Edit
proc find[T](s: SkipList[T]; r: var SkipList[T]; compare: SkipListFind[T]): bool
Find a SkipList in s for which compare r yields Equal, storing the result in r; returns true if the value was found, else false.   Source   Edit
proc find[T](s: SkipList[T]; value: SkipList[T]; r: var SkipList[T];
             compare: SkipListCmp[T] = `<>`): bool
Find the SkipList value in SkipList s, storing the result in r; returns true if the value was found, else false.   Source   Edit
proc find[T](s: SkipList[T]; value: T): SkipList[T]
Find the SkipList holding value in SkipList s; raises a KeyError` if the value was not found.   Source   Edit
proc find[T](s: SkipList[T]; value: T; r: var SkipList[T]): bool
Find value in SkipList s, storing the result in r; returns true if the value was found, else false.   Source   Edit
proc grow[T](s: var SkipList[T]; n: SkipList[T]): bool
true if we grew.   Source   Edit
proc hash(s: SkipList): Hash
The Hash of SkipList s is a function of all its values.   Source   Edit
proc isEmpty(s: SkipList): bool
True if SkipList s holds no items.   Source   Edit
proc newSkipList[T](value: T): SkipList[T]
Instantiate a SkipList from value value.   Source   Edit
proc rank(s: SkipList): int
The higher the rank, the shorter the SkipList.   Source   Edit
proc remove[T](s: var SkipList[T]; n: SkipList[T]): bool
Remove SkipList n from SkipList s; returns true if s changed.
s:The source SkipList
n:The SkipList to remove
  Source   Edit
proc remove[T](s: var SkipList[T]; value: T): bool {.discardable.}
Remove value from SkipList s; returns true if s changed.   Source   Edit
proc toSkipList[T](values: openArray[T] = @[]): SkipList[T]
Create a SkipList from an openArray values.   Source   Edit

Iterators

iterator items[T](s: SkipList[T]): T
Iterate over entries in SkipList s.

Example:

var s = newSkipList 3
for item in items(s):
  assert item == 3
  Source   Edit
iterator mitems[T](s: var SkipList[T]): var T
Iterate over mutable entries in SkipList s.

Example:

var s = newSkipList"foo"
for item in mitems(s):
  item.add "bar"
for item in items(s):
  assert item == "foobar"
  Source   Edit
iterator pairs[T](s: SkipList[T]): tuple[index: int, value: T]
Iterate over entries in SkipList s.

Example:

var s = newSkipList 3
for index, value in pairs(s):
  assert index == 0
  assert value == 3
  Source   Edit

Templates

template `<=`(a, b: SkipList): bool
true if SkipList a is less or equal to SkipList b, else false.   Source   Edit
template `=!=`(a, b: SkipList): bool
false if SkipLists a and b share the same memory, else true.   Source   Edit
template `>=`(a, b: SkipList): bool
true if SkipList a is more or equal to SkipList b, else false.   Source   Edit
template append[T](s: var SkipList[T]; value: T)
Alias for add(s, value).   Source   Edit