nom.tam.util
Class HashedList

java.lang.Object
  extended by nom.tam.util.HashedList
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection

public class HashedList
extends java.lang.Object
implements java.util.Collection


Constructor Summary
HashedList()
           
 
Method Summary
 boolean add(int pos, java.lang.Object key, java.lang.Object reference)
          Add an element to the list.
 boolean add(java.lang.Object reference)
          Add an element to the end of the list.
 boolean add(java.lang.Object key, java.lang.Object reference)
          Add a keyed element to the end of the list.
 boolean addAll(java.util.Collection c)
          Add another collection to this one list.
 void clear()
          Clear the collection
 boolean contains(java.lang.Object o)
          Does the HashedList contain this element?
 boolean containsAll(java.util.Collection c)
          Does the HashedList contain all the elements of this other collection.
 boolean containsKey(java.lang.Object key)
          Check if the key is included in the list
 java.lang.Object get(int n)
          Return the n'th entry from the beginning.
 java.lang.Object get(java.lang.Object key)
          Return the value of a keyed entry.
 boolean isEmpty()
          Is the HashedList empty?
 java.util.Iterator iterator()
          Return an iterator over the entire list.
 nom.tam.util.HashedList.HashedListIterator iterator(int n)
          Return an iterator starting with the n'th entry.
 nom.tam.util.HashedList.HashedListIterator iterator(java.lang.Object key)
          Return an iterator over the list starting with the entry with a given key.
 boolean remove(int index)
          Remove an object from the list giving the object index..
 boolean remove(java.lang.Object o)
          Remove an object from the list giving just the object value.
 boolean removeAll(java.util.Collection c)
          Remove all the elements that are found in another collection.
 boolean removeKey(java.lang.Object key)
          Remove a keyed object from the list.
 boolean replaceKey(java.lang.Object oldKey, java.lang.Object newKey)
          Replace the key of a given element.
 boolean retainAll(java.util.Collection c)
          Retain only elements contained in another collection
 int size()
          Return the number of elements in the list.
 void sort(java.util.Comparator comp)
          Sort the keys into some desired order.
 java.lang.Object[] toArray()
          Convert to an array of objects
 java.lang.Object[] toArray(java.lang.Object[] o)
          Convert to an array of objects of a specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

HashedList

public HashedList()
Method Detail

add

public boolean add(java.lang.Object reference)
Add an element to the end of the list.

Specified by:
add in interface java.util.Collection

add

public boolean add(java.lang.Object key,
                   java.lang.Object reference)
Add a keyed element to the end of the list.


add

public boolean add(int pos,
                   java.lang.Object key,
                   java.lang.Object reference)
Add an element to the list.

Parameters:
pos - The element before which the current element be placed. If pos is null put the element at the end of the list.
key - The hash key for the new object. This may be null for an unkeyed entry.
reference - The actual object being stored.

removeKey

public boolean removeKey(java.lang.Object key)
Remove a keyed object from the list. Unkeyed objects can be removed from the list using a HashedListIterator or using the remove(Object) method.


remove

public boolean remove(java.lang.Object o)
Remove an object from the list giving just the object value.

Specified by:
remove in interface java.util.Collection

remove

public boolean remove(int index)
Remove an object from the list giving the object index..


iterator

public java.util.Iterator iterator()
Return an iterator over the entire list. The iterator may be used to delete entries as well as to retrieve existing entries. A knowledgeable user can cast this to a HashedListIterator and use it to add as well as delete entries.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection

iterator

public nom.tam.util.HashedList.HashedListIterator iterator(java.lang.Object key)
                                                    throws java.util.NoSuchElementException
Return an iterator over the list starting with the entry with a given key.

Throws:
java.util.NoSuchElementException

iterator

public nom.tam.util.HashedList.HashedListIterator iterator(int n)
                                                    throws java.util.NoSuchElementException
Return an iterator starting with the n'th entry.

Throws:
java.util.NoSuchElementException

get

public java.lang.Object get(java.lang.Object key)
Return the value of a keyed entry. Non-keyed entries may be returned by requesting an iterator.


get

public java.lang.Object get(int n)
                     throws java.util.NoSuchElementException
Return the n'th entry from the beginning.

Throws:
java.util.NoSuchElementException

replaceKey

public boolean replaceKey(java.lang.Object oldKey,
                          java.lang.Object newKey)
Replace the key of a given element.

Parameters:
oldKey - The previous key. This key must be present in the hash.
newKey - The new key. This key must not be present in the hash.
Returns:
if the replacement was successful.

containsKey

public boolean containsKey(java.lang.Object key)
Check if the key is included in the list


size

public int size()
Return the number of elements in the list.

Specified by:
size in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Add another collection to this one list. All entries are added as unkeyed entries to the end of the list.

Specified by:
addAll in interface java.util.Collection

clear

public void clear()
Clear the collection

Specified by:
clear in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Does the HashedList contain this element?

Specified by:
contains in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Does the HashedList contain all the elements of this other collection.

Specified by:
containsAll in interface java.util.Collection

isEmpty

public boolean isEmpty()
Is the HashedList empty?

Specified by:
isEmpty in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Remove all the elements that are found in another collection.

Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Retain only elements contained in another collection

Specified by:
retainAll in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Convert to an array of objects

Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] o)
Convert to an array of objects of a specified type.

Specified by:
toArray in interface java.util.Collection

sort

public void sort(java.util.Comparator comp)
Sort the keys into some desired order.