tango.util.container.Clink

License:

BSD style: see license.txt

Version:

Apr 2008: Initial release

Authors:

Kris

Since:

0.99.7

Based upon Doug Lea's Java collection package
struct Clink(V)
Clinks are links that are always arranged in circular lists.
Ref set(V v)
Set to point to ourselves
Ref set(V v, Ref p, Ref n)
Set to point to n as next cell and p as the prior cell

param:

n, the new next cell

param:

p, the new prior cell
bool singleton() [@property, const]
Return true if current cell is the only one on the list
void addNext(V v, scope Ref delegate() alloc)
Make a cell holding v and link it immediately after current cell
Ref addPrev(V v, scope Ref delegate() alloc)
make a node holding v, link it before the current cell, and return it
void linkPrev(Ref p)
link p before current cell
int size() [@property, const]
return the number of cells in the list
Ref find(V element)
return the first cell holding element found in a circular traversal starting at current cell, or null if no such
int count(V element) [const]
return the number of cells holding element found in a circular traversal
Ref nth(size_t n)
return the nth cell traversed from here. It may wrap around.
void unlinkNext()
Unlink the next cell. This has no effect on the list if isSingleton()
void unlinkPrev()
Unlink the previous cell. This has no effect on the list if isSingleton()
void unlink()
Unlink self from list it is in. Causes it to be a singleton
Ref copyList(scope Ref delegate() alloc) [const]
Make a copy of the list and return new head.