All Packages Class Hierarchy This Package Previous Next Index
Class tw.edu.ncnu.im.cnclab.DataStru.ListArray
java.lang.Object
|
+----tw.edu.ncnu.im.cnclab.DataStru.ListArray
- public class ListArray
- extends Object
- implements Cloneable, Serializable
The ListArray class implements an array with linked-list
support. Like an array, it contains components that can be
accessed using an integer index. Also, the ListArray is
capable of double linked-list. For example :
- Get index of next item of index
i in ListArray la :
-
nextIndex = la.getNextIndex(i);
- Get all item of ListArray
la :
-
for(Enumeration e=la.elements(); e.hasMoreElements();){
System.out.println(e.nextElement());
}
Unlike java.util.Vector, ListArray
can not change size.
- Version:
- 0.4 Jul 8, 1999
- Author:
- Ding-Yi Chen
- See Also:
- Enumeration, ListItem, ListArray2
-
capacity
- The capacity of the ListArray.
-
first
- First availible item of the ListArray.
-
itemArray
- The array buffer into which the components of the ListArray are stored.
-
last
- Last availible item of the ListArray.
-
numOfItem
- The number of valid object in this ListArray.
-
ListArray(int)
- Constructs an empty ListArray with the specified initial capacity.
-
addItemAt(Object, int)
- Add an item at specified index.
-
clone()
- Returns a deep-copied clone of this ListArray.
-
copyFrom(ListArray)
- Copies the components from specified ListArray to this ListArray
The size of these ListArrays must be identical.
-
count()
- Number of valid items in this ListArray.
-
deleteAllItems()
- Remove all items.
-
deleteItemAt(int)
- Delete an item at specified index.
-
elements()
- Returns an enumeration of the components of this ListArray.
-
getFirst()
- Get first item of linked-list.
-
getFirstIndex()
- Get index of first item of linked-list.
-
getLast()
- Get last item of linked-list.
-
getLastIndex()
- Get index of last item of linked-list.
-
getNext(int)
- Get next ListItem of linked-list.
-
getNext(ListItem)
- Get next ListItem of linked-list.
-
getNextIndex(int)
- Get index of next item of linked-list.
-
getPrev(int)
- Get previous ListItem of linked-list.
-
getPrev(ListItem)
- Get prev ListItem of linked-list.
-
getPrevIndex(int)
- Get index of prev item of linked-list.
-
itemAt(int)
- Get the item at specified index.
-
itemExistAt(int)
- Check whether item exist at specified index.
-
purge()
- Remove deleted items
-
purge(int[])
- Remove deleted items from specified index translation table
-
purgeIndexTable()
- Create index translation table.
-
setItemAt(Object, int)
- Set an item at specified index.
capacity
protected int capacity
- The capacity of the ListArray.
numOfItem
protected int numOfItem
- The number of valid object in this ListArray.
itemArray
protected ListItem itemArray[]
- The array buffer into which the components of the ListArray are stored.
first
protected ListItem first
- First availible item of the ListArray. Used in linked-list.
last
protected ListItem last
- Last availible item of the ListArray. Used in linked-list.
ListArray
public ListArray(int capacity)
- Constructs an empty ListArray with the specified initial capacity.
- Parameters:
- capacity - the initial capacity of the ListArray.
addItemAt
public synchronized void addItemAt(Object object,
int index)
- Add an item at specified index.
- Parameters:
- object - the item to insert.
- index - where to insert the new component.
deleteAllItems
public void deleteAllItems()
- Remove all items.
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
copyFrom
public synchronized void copyFrom(ListArray src)
- Copies the components from specified ListArray to this ListArray
The size of these ListArrays must be identical.
- Parameters:
- src - the source ListArray
count
public int count()
- Number of valid items in this ListArray.
- Returns:
- Number of valid items in this ListArray
deleteItemAt
public synchronized void deleteItemAt(int index) throws NullItemException
- Delete an item at specified index.
- Parameters:
- index - the index of the item to delete
itemAt
public Object itemAt(int index)
- Get the item at specified index.
- Parameters:
- index - the index of the item.
- Returns:
- the item at specified index ;
null if no such item
itemExistAt
public boolean itemExistAt(int index)
- Check whether item exist at specified index.
- Parameters:
- index - the index of the item.
- Returns:
-
true if item exist at index.
purge
public synchronized void purge()
- Remove deleted items
purge
public synchronized void purge(int indexTable[])
- Remove deleted items from specified index translation table
- Parameters:
- indexTable - the index translation table
purgeIndexTable
public synchronized int[] purgeIndexTable()
- Create index translation table.
While purging graph, if we purge the adjacency matrix of edges directly,
some edges will not put on the right place. Thus, index trnaslation table
is required while
- Returns:
- indexTable index trnaslation table
setItemAt
public synchronized void setItemAt(Object obj,
int index)
- Set an item at specified index.
if item exist, then set object into item ; otherwise add item at specified index.
- Parameters:
- obj - the item to replace.
- index - where to set the new component (obj).
getFirstIndex
public int getFirstIndex()
- Get index of first item of linked-list.
- Returns:
- index of first item of linked-list.
getLastIndex
public int getLastIndex()
- Get index of last item of linked-list.
- Returns:
- index of last item of linked-list.
getFirst
public ListItem getFirst()
- Get first item of linked-list.
- Returns:
- first item of linked-list.
getLast
public ListItem getLast()
- Get last item of linked-list.
- Returns:
- last item of linked-list.
getNextIndex
public int getNextIndex(int index)
- Get index of next item of linked-list.
- Parameters:
- index - index of current item
- Returns:
- index of next item of linked-list.
getNext
public ListItem getNext(ListItem li)
- Get next ListItem of linked-list.
- Parameters:
- li - the listitem
- Returns:
- next ListItem of
li .
getNext
public ListItem getNext(int index)
- Get next ListItem of linked-list.
- Parameters:
- index - index of current item
- Returns:
- next ListItem of linked-list.
getPrevIndex
public int getPrevIndex(int index)
- Get index of prev item of linked-list.
- Parameters:
- index - index of current item.
- Returns:
- index of prev item of linked-list.
getPrev
public ListItem getPrev(int index)
- Get previous ListItem of linked-list.
- Parameters:
- index - index of current item
- Returns:
- index of previous item of linked-list.
getPrev
public ListItem getPrev(ListItem li)
- Get prev ListItem of linked-list.
- Parameters:
- li - the listitem
- Returns:
- prev ListItem of
li .
elements
public final synchronized Enumeration elements()
- Returns an enumeration of the components of this ListArray.
- Returns:
- an enumeration of the components of this ListArray.
- See Also:
- Enumeration
All Packages Class Hierarchy This Package Previous Next Index