Slink

Slink instances provide standard linked list next-fields, and support standard operations upon them. Slink structures are pure implementation tools, and perform no argument checking, no result screening, and no synchronization. They rely on user-level classes (see HashSet, for example) to do such things.

Still, Slink is made `public' so that you can use it to build other kinds of containers

Note that when K is specified, support for keys are enabled. When Identity is stipulated as 'true', those keys are compared using an identity-comparison instead of equality (using 'is'). Similarly, if HashCache is set true, an additional attribute is create in order to retain the hash of K

Members

Aliases

Comparator
alias Comparator = Compare!(V)
Undocumented in source.
Ref
alias Ref = Type*
Undocumented in source.
Type
alias Type = Slink!(V, K, Identity, HashCache)
Undocumented in source.

Functions

attach
void attach(Ref p)

Splice in p between current cell and whatever it was previously pointing to

copy
Ref copy(Ref delegate() alloc)

Make a copy of the list; i.e., a new list containing new cells but including the same elements in the same order

count
int count(V element)

Count the number of occurrences of element in list

count
int count()

Return the number of cells in the list

countKey
int countKey(K key)

add support for keys also?

countPair
int countPair(K key, V value)

add support for keys also?

detachNext
void detachNext()

Cause current cell to skip over the current next() one, effectively removing the next element from the list

find
Ref find(V element)

Linear search down the list looking for element

findKey
Ref findKey(K key)

add support for keys also?

findPair
Ref findPair(K key, V value)

add support for keys also?

hash
hash_t hash()

add support for keys also?

index
int index(V element)

Return the number of cells traversed to find first occurrence of a cell with element() element, or -1 if not present

indexKey
int indexKey(K key)

add support for keys also?

indexPair
int indexPair(K key, V value)

add support for keys also?

nth
Ref nth(long n)

Return the nth cell of the list, or null if no such

set
Ref set(K k, V v, Ref n)

add support for keys also?

set
Ref set(V v, Ref n)

Set to point to n as next cell

tail
Ref tail()

Return the cell representing the last element of the list (i.e., the one whose next() is null

Static functions

merge
Ref merge(Ref fst, Ref snd, Comparator cmp)

Basic linkedlist merge algorithm. Merges the lists head by fst and snd with respect to cmp

sort
Ref sort(Ref s, Comparator cmp)

Standard merge sort algorithm

split
Ref split(Ref s)

Standard list splitter, used by sort. Splits the list in half. Returns the head of the second half

Variables

cache
hash_t cache;
Undocumented in source.
key
K key;

add support for keys also?

next
Ref next;
Undocumented in source.
value
V value;
Undocumented in source.

Meta