All Packages Class Hierarchy This Package Previous Next Index
Class collections.LLCell
java.lang.Object
|
+----collections.Cell
|
+----collections.LLCell
- public class LLCell
- extends Cell
LLCells extend Cells with standard linkedlist next-fields,
and provide a standard operations on them.
LLCells are pure implementation tools. They perform
no argument checking, no result screening, and no synchronization.
They rely on user-level classes (see for example LinkedList) to do such things.
Still, the class is made `public' so that you can use them to
build other kinds of collections or whatever, not just the ones
currently supported.
-
LLCell()
-
-
LLCell(Object)
-
-
LLCell(Object, LLCell)
-
-
clone()
- Clone is SHALLOW; i.e., just makes a copy of the current cell
-
copyList()
- make a copy of the list; i.e., a new list containing new cells
but including the same elements in the same order
-
count(Object)
- Count the number of occurrences of element in list
-
find(Object)
- Linear search down the list looking for element (using Object.equals)
-
index(Object)
- return the number of cells traversed to find first occurrence
of a cell with element() element, or -1 if not present
-
last()
- return the cell representing the last element of the list
(i.e., the one whose next() is null
-
length()
- return the number of cells in the list
-
linkNext(LLCell)
- Splice in p between current cell and whatever it was previously
pointing to
-
merge(LLCell, LLCell, Comparator)
- Basic linkedlist merge algorithm.
-
mergeSort(LLCell, Comparator)
- Standard merge sort algorithm
-
next()
- Return the next cell (or null if none)
-
next(LLCell)
- set to point to n as next cell
-
nth(int)
- return the nth cell of the list, or null if no such
-
split(LLCell)
- Standard list splitter, used by sort.
-
unlinkNext()
- Cause current cell to skip over the current next() one,
effectively removing the next element from the list
LLCell
public LLCell(Object v,
LLCell n)
LLCell
public LLCell(Object v)
LLCell
public LLCell()
next
public final LLCell next()
- Return the next cell (or null if none)
next
public final void next(LLCell n)
- set to point to n as next cell
- Parameters:
- n, - the new next cell
linkNext
public final void linkNext(LLCell p)
- Splice in p between current cell and whatever it was previously
pointing to
- Parameters:
- p, - the cell to splice
unlinkNext
public final void unlinkNext()
- Cause current cell to skip over the current next() one,
effectively removing the next element from the list
find
public final LLCell find(Object element)
- Linear search down the list looking for element (using Object.equals)
- Parameters:
- element - to look for
- Returns:
- the cell containing element, or null if no such
index
public final int index(Object element)
- return the number of cells traversed to find first occurrence
of a cell with element() element, or -1 if not present
count
public final int count(Object element)
- Count the number of occurrences of element in list
length
public final int length()
- return the number of cells in the list
last
public final LLCell last()
- return the cell representing the last element of the list
(i.e., the one whose next() is null
nth
public final LLCell nth(int n)
- return the nth cell of the list, or null if no such
copyList
public LLCell copyList()
- make a copy of the list; i.e., a new list containing new cells
but including the same elements in the same order
clone
protected Object clone() throws CloneNotSupportedException
- Clone is SHALLOW; i.e., just makes a copy of the current cell
- Overrides:
- clone in class Cell
merge
public static LLCell merge(LLCell fst,
LLCell snd,
Comparator cmp)
- Basic linkedlist merge algorithm.
Merges the lists head by fst and snd with respect to cmp
- Parameters:
- fst - head of the first list
- snd - head of the second list
- cmp - a Comparator used to compare elements
- Returns:
- the merged ordered list
split
public static LLCell split(LLCell s)
- Standard list splitter, used by sort.
Splits the list in half. Returns the head of the second half
- Parameters:
- s - the head of the list
- Returns:
- the head of the second half
mergeSort
public static LLCell mergeSort(LLCell s,
Comparator cmp)
- Standard merge sort algorithm
- Parameters:
- s - the list to sort
- cmp, - the comparator to use for ordering
- Returns:
- the head of the sorted list
All Packages Class Hierarchy This Package Previous Next Index