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.


Constructor Index

 o LLCell()
 o LLCell(Object)
 o LLCell(Object, LLCell)

Method Index

 o clone()
Clone is SHALLOW; i.e., just makes a copy of the current cell
 o copyList()
make a copy of the list; i.e., a new list containing new cells but including the same elements in the same order
 o count(Object)
Count the number of occurrences of element in list
 o find(Object)
Linear search down the list looking for element (using Object.equals)
 o index(Object)
return the number of cells traversed to find first occurrence of a cell with element() element, or -1 if not present
 o last()
return the cell representing the last element of the list (i.e., the one whose next() is null
 o length()
return the number of cells in the list
 o linkNext(LLCell)
Splice in p between current cell and whatever it was previously pointing to
 o merge(LLCell, LLCell, Comparator)
Basic linkedlist merge algorithm.
 o mergeSort(LLCell, Comparator)
Standard merge sort algorithm
 o next()
Return the next cell (or null if none)
 o next(LLCell)
set to point to n as next cell
 o nth(int)
return the nth cell of the list, or null if no such
 o split(LLCell)
Standard list splitter, used by sort.
 o unlinkNext()
Cause current cell to skip over the current next() one, effectively removing the next element from the list

Constructors

 o LLCell
 public LLCell(Object v,
               LLCell n)
 o LLCell
 public LLCell(Object v)
 o LLCell
 public LLCell()

Methods

 o next
 public final LLCell next()
Return the next cell (or null if none)

 o next
 public final void next(LLCell n)
set to point to n as next cell

Parameters:
n, - the new next cell
 o 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
 o unlinkNext
 public final void unlinkNext()
Cause current cell to skip over the current next() one, effectively removing the next element from the list

 o 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
 o 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

 o count
 public final int count(Object element)
Count the number of occurrences of element in list

 o length
 public final int length()
return the number of cells in the list

 o last
 public final LLCell last()
return the cell representing the last element of the list (i.e., the one whose next() is null

 o nth
 public final LLCell nth(int n)
return the nth cell of the list, or null if no such

 o 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

 o clone
 protected Object clone() throws CloneNotSupportedException
Clone is SHALLOW; i.e., just makes a copy of the current cell

Overrides:
clone in class Cell
 o 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
 o 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
 o 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