|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.util.SkipList
public class SkipList
A simple implementation of a randomized sorted skip list that uses SkipList.Cell
s to carry the values.
YList
Nested Class Summary | |
---|---|
static class |
SkipList.Cell
The cells that are used by SkipList . |
Constructor Summary | |
---|---|
SkipList()
Creates a skip list that uses a comparator that uses the Comparable of the instances in the cells. |
|
SkipList(java.util.Comparator comparator)
Creates a skip list that uses the given comparator to sort the list. |
Method Summary | |
---|---|
void |
clear()
Clears this list. |
void |
clear(SkipList.Cell from,
SkipList.Cell to)
Removes all cells from from to to inclusive from this list. |
SkipList.Cell |
findCell(java.lang.Object o)
Finds a cell in this list where the comparator yields 0 when it compares o with the cell's
contents or null if no such cell could be found. |
SkipList.Cell |
findPredecessor(java.lang.Object o)
Finds the greatest predecessor in this list where the comparator yields positive values when it compares o with the cell's
contents or null if no such cell could be found. |
SkipList.Cell |
findSuccessor(java.lang.Object o)
Finds the smallest successor in this list where the comparator yields negative values when it compares o with the cell's
contents or null if no such cell could be found. |
SkipList.Cell |
firstCell()
Gets the first cell in this list or null if there are no cells in this list. |
SkipList.Cell |
insertAfter(SkipList.Cell cell,
java.lang.Object o)
Inserts a new item after the provided cell. |
SkipList.Cell |
insertBefore(SkipList.Cell cell,
java.lang.Object o)
Inserts a new item before the provided cell. |
SkipList.Cell |
insertCell(java.lang.Object o)
Inserts a new item into the list at the correct position. |
java.util.Iterator |
iterator()
Creates a non-fail-save iterator that iterates over the cells in this list and yields their SkipList.Cell.getInfo() |
SkipList.Cell |
lastCell()
Gets the last cell in this list or null if there are no cells in this list. |
SkipList.Cell |
predCell(SkipList.Cell cell)
Returns the predecessor of the given cell or null . |
void |
removeCell(SkipList.Cell cell)
Removes the given cell from this list. |
int |
size()
Yields the number of cells in this list. |
SkipList.Cell |
succCell(SkipList.Cell cell)
Returns the successor of the given cell or null . |
java.lang.String |
toString()
Yields a human readable string version of the list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SkipList(java.util.Comparator comparator)
comparator
- The comparator to use for sorting.public SkipList()
Comparable
of the instances in the cells.
Method Detail |
---|
public SkipList.Cell insertCell(java.lang.Object o)
o
- The item to insert.
public void clear(SkipList.Cell from, SkipList.Cell to)
from
to to
inclusive from this list.
from
- The first cell to removeto
- The last cell to removepublic SkipList.Cell insertAfter(SkipList.Cell cell, java.lang.Object o)
Comparator
.
cell
- The cell to insert the item after.o
- The item to insert.
public SkipList.Cell insertBefore(SkipList.Cell cell, java.lang.Object o)
Comparator
.
cell
- The cell to insert the item before.o
- The item to insert.
public int size()
public void removeCell(SkipList.Cell cell)
cell
- The cell to remove.public void clear()
public SkipList.Cell succCell(SkipList.Cell cell)
null
.
cell
- The cell to get the successor from.
null
if cell is the last cell in the list.public SkipList.Cell predCell(SkipList.Cell cell)
null
.
cell
- The cell to get the predecessor from.
null
if cell is the first cell in the list.public SkipList.Cell firstCell()
null
if there are no cells in this list.
null
.public SkipList.Cell lastCell()
null
if there are no cells in this list.
null
.public java.util.Iterator iterator()
SkipList.Cell.getInfo()
public SkipList.Cell findCell(java.lang.Object o)
0
when it compares o
with the cell's
contents or null
if no such cell could be found.
o
- the value to search.
null
.public SkipList.Cell findPredecessor(java.lang.Object o)
o
with the cell's
contents or null
if no such cell could be found.
o
- the value to search.
null
.public SkipList.Cell findSuccessor(java.lang.Object o)
o
with the cell's
contents or null
if no such cell could be found.
o
- the value to search.
null
.public java.lang.String toString()
toString
in class java.lang.Object
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |