All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tw.edu.ncnu.im.cnclab.DataStru.ListArray2

java.lang.Object
   |
   +----tw.edu.ncnu.im.cnclab.DataStru.ListArray2

public class ListArray2
extends Object
implements Cloneable, Serializable
The ListArray2 class implements an two dimension ListArray

Coordinate is needed while specified the location of item. Example of of coordinate:

int coord[]=new int[]{column,row}

Version:
0.4 Jul 8, 1999
Author:
Ding-Yi Chen
See Also:
Enumeration, ListItem, ListArray

Variable Index

 o capacity
The capacity of the ListArray.
 o COLUMN
Stand for column
 o dimension
The capacity of the ListArray.
 o first
First availible item of the ListArray2 in one dimension .
 o firstOfAll
First availible item of the ListArray2.
 o itemArray
The array buffer into which the components of the ListArray are stored.
 o last
Last availible item of the ListArray2 in one dimension.
 o lastOfAll
Last availible item of the ListArray2.
 o numOfItem
The number of valid object in one column (or row).
 o ROW
Stand for row
 o totalItem
The number of valid object in this ListArray

Constructor Index

 o ListArray2(int)
Constructs an empty ListArray with the specified initial capacity.

Method Index

 o addItemAt(Object, int[])
Add an item at specified index.
 o addItemAt(Object, int[], boolean)
Add an item at specified index.
 o allElements()
Returns an enumeration of the all components of this ListArray2.
 o allListItems()
Returns an enumeration of the all ListItem of this ListArray2.
 o clone()
Returns a deep-copied clone of this ListArray.
 o copyFrom(ListArray2)
Copies the components from specified ListArray to this ListArray The size of these ListArrays must be identical.
 o count()
Number of valid items in this ListArray.
 o count(int, int)
Number of valid items in this ListArray of specified row/column.
 o deleteAllItems()
delete all items
 o deleteItemAt(int[])
delete item at specified coordinate
 o deleteItemAt(ListItem)
delete specified item
 o elements(int, int)
Returns an enumeration of the components of one column/row of this ListArray2.
 o getFirst(int, int)
Get first ListItem of linked-list.
 o getFirstCoord(int, int)
Get coordinate of first item of linked-list.
 o getFirstIndex(int, int)
Get index of first item of linked-list.
 o getLast(int, int)
Get last ListItem of linked-list.
 o getLastCoord(int, int)
Get coordinate of last item of linked-list.
 o getLastIndex(int, int)
Get index of last item of linked-list.
 o getListItemAt(int[])
Get the ListItem at specified index.
 o getNext(int[], int)
Get next ListItem of linked-list.
 o getNextCoord(int[], int)
Get the coordinate next ListItem of linked-list.
 o getNextIndex(int[], int)
Get index of next item of linked-list.
 o getPrev(int[], int)
Get prev ListItem of linked-list.
 o getPrevCoord(int[], int)
Get the coordinate prev ListItem of linked-list.
 o getPrevIndex(int[], int)
Get index of prev item of linked-list.
 o itemAt(int[])
Get the item at specified index.
 o itemExistAt(int[])
Check whether item exist at specified index.
 o makeLink(int[], int[])
Link item from specified coordinate to another coordinate.
 o purge(int[])
Remove deleted items from specified index translation table
 o setItemAt(Object, int[])
Set an item at specified index.

Variables

 o COLUMN
 public static final int COLUMN
Stand for column

 o ROW
 public static final int ROW
Stand for row

 o capacity
 protected int capacity
The capacity of the ListArray.

 o dimension
 protected int dimension
The capacity of the ListArray.

 o totalItem
 protected int totalItem
The number of valid object in this ListArray

 o numOfItem
 protected int numOfItem[][]
The number of valid object in one column (or row).

 o itemArray
 protected ListItem itemArray[][]
The array buffer into which the components of the ListArray are stored.

 o first
 protected ListItem first[][]
First availible item of the ListArray2 in one dimension . Used in linked-list.

 o firstOfAll
 protected ListItem firstOfAll
First availible item of the ListArray2. Used in linked-list.

 o last
 protected ListItem last[][]
Last availible item of the ListArray2 in one dimension. Used in linked-list.

 o lastOfAll
 protected ListItem lastOfAll
Last availible item of the ListArray2. Used in linked-list.

Constructors

 o ListArray2
 public ListArray2(int capacity)
Constructs an empty ListArray with the specified initial capacity.

Parameters:
capacity - the initial capacity of the ListArray.

Methods

 o addItemAt
 public synchronized void addItemAt(Object object,
                                    int coord[])
Add an item at specified index. Also link the item at tail of linked-list.

Parameters:
object - the item to insert.
coord - coordinate to insert the new component.
 o addItemAt
 public synchronized void addItemAt(Object object,
                                    int coord[],
                                    boolean linkOnly)
Add an item at specified index. Also link the item at tail of linked-list.

Parameters:
object - the item to insert.
coord - coordinate to insert the new component.
linkOnly - If true , it won't appear in allElements(), false otherwise.
 o makeLink
 public synchronized void makeLink(int coordSrc[],
                                   int coordTarget[])
Link item from specified coordinate to another coordinate.

Like hard-link of UNIX, Item at coordSrc and coordTarget share the same space.

Parameters:
coordSrc - Coordinate of original item to link.
coordTarget - Coordinate of new reference.
 o clone
 public synchronized Object clone()
Returns a deep-copied clone of this ListArray.

Returns:
a deep-copied clone of this ListArray.
Overrides:
clone in class Object
 o copyFrom
 public synchronized void copyFrom(ListArray2 src)
Copies the components from specified ListArray to this ListArray The size of these ListArrays must be identical.

Parameters:
src - the source ListArray
 o count
 public int count()
Number of valid items in this ListArray.

Returns:
Number of valid items in this ListArray
 o count
 public int count(int index,
                  int dimension)
Number of valid items in this ListArray of specified row/column.

Parameters:
index - the index of row/column
dimension - COLUMN stand for column, ROW stand for row
Returns:
Number of valid items in this ListArray.
 o deleteAllItems
 public synchronized void deleteAllItems()
delete all items

 o deleteItemAt
 public synchronized void deleteItemAt(int coord[]) throws NullItemException
delete item at specified coordinate

Parameters:
coord - coordinate to be delete.
 o deleteItemAt
 public synchronized void deleteItemAt(ListItem li) throws NullItemException
delete specified item

Parameters:
li - ListItem to delete.
 o itemAt
 public Object itemAt(int coord[])
Get the item at specified index.

Parameters:
coord - the coordinate of the item.
Returns:
the item at specified coord ; null if no such item
 o getListItemAt
 public ListItem getListItemAt(int coord[])
Get the ListItem at specified index.

Parameters:
coord - the coordinate of the ListItem.
Returns:
the ListItem at specified coord ; null if no such ListItem
 o itemExistAt
 public boolean itemExistAt(int coord[])
Check whether item exist at specified index.

Parameters:
coord - the coordinate of the item.
Returns:
true if item exist at index.
 o purge
 public synchronized void purge(int indexTable[])
Remove deleted items from specified index translation table

Parameters:
indexTable - the index translation table
 o setItemAt
 public synchronized void setItemAt(Object object,
                                    int coord[])
Set an item at specified index.

if item exist, then set object into item ; otherwise add item at specified coordinate.

Parameters:
obj - the item to replace.
coord - where to set the new component (obj).
 o getFirstCoord
 public int[] getFirstCoord(int index,
                            int dimension)
Get coordinate of first item of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
coordinate of first item of linked-list.
 o getFirstIndex
 public int getFirstIndex(int index,
                          int dimension)
Get index of first item of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
index of first item of linked-list of specified dimension.
 o getLastCoord
 public int[] getLastCoord(int index,
                           int dimension)
Get coordinate of last item of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
coordinate of last item of linked-list.
 o getLastIndex
 public int getLastIndex(int index,
                         int dimension)
Get index of last item of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
index of last item of linked-list of specified dimension.
 o getFirst
 public ListItem getFirst(int index,
                          int dimension)
Get first ListItem of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
first item of linked-list.
 o getLast
 public ListItem getLast(int index,
                         int dimension)
Get last ListItem of linked-list.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
last ListItem of linked-list.
 o getNext
 public ListItem getNext(int coord[],
                         int dimension)
Get next ListItem of linked-list.

Parameters:
index - the index of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
next ListItem of linked-list.
 o getNextCoord
 public int[] getNextCoord(int coord[],
                           int dimension)
Get the coordinate next ListItem of linked-list.

Parameters:
coord - the coordinate of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
next ListItem of linked-list.
 o getNextIndex
 public int getNextIndex(int coord[],
                         int dimension)
Get index of next item of linked-list.

Parameters:
index - the index of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
index of last item of linked-list of specified dimension.
 o getPrev
 public ListItem getPrev(int coord[],
                         int dimension)
Get prev ListItem of linked-list.

Parameters:
index - the index of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
prev ListItem of linked-list.
 o getPrevCoord
 public int[] getPrevCoord(int coord[],
                           int dimension)
Get the coordinate prev ListItem of linked-list.

Parameters:
coord - the coordinate of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
prev ListItem of linked-list.
 o getPrevIndex
 public int getPrevIndex(int coord[],
                         int dimension)
Get index of prev item of linked-list.

Parameters:
index - the index of current row/column
dimension - 0 stand for column, 1 stand for row
Returns:
index of prev item of linked-list of specified dimension.
 o elements
 public final synchronized Enumeration elements(int index,
                                                int dimension)
Returns an enumeration of the components of one column/row of this ListArray2.

Parameters:
index - the index of row/column
dimension - 0 stand for column, 1 stand for row
Returns:
an enumeration of the components of this ListArray2.
See Also:
Enumeration
 o allElements
 public final synchronized Enumeration allElements()
Returns an enumeration of the all components of this ListArray2.

Returns:
an enumeration of the all components of this ListArray2.
See Also:
Enumeration
 o allListItems
 public final synchronized Enumeration allListItems()
Returns an enumeration of the all ListItem of this ListArray2.

Returns:
an enumeration of the all ListItem of this ListArray2.
See Also:
Enumeration

All Packages  Class Hierarchy  This Package  Previous  Next  Index