nom.tam.util
Class HashedList

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

public class HashedList
extends Object
implements Collection


Nested Class Summary
 class HashedList.HashedListIterator
          This inner class defines an iterator over the hashed list.
 
Constructor Summary
HashedList()
           
 
Method Summary
 boolean add(Object reference)
          Add an element to the end of the list.
 boolean add(Object key, Object reference)
          Add a keyed element to the end of the list.
 boolean addAll(Collection c)
          Add another collection to this one list.
 void clear()
          Clear the collection
 boolean contains(Object o)
          Does the HashedList contain this element?
 boolean containsAll(Collection c)
          Does the HashedList contain all the elements of this other collection.
 boolean containsKey(Object key)
          Check if the key is included in the list
 Object get(int n)
          Return the n'th entry from the beginning.
 Object get(Object key)
          Return the value of a keyed entry.
 boolean isEmpty()
          Is the HashedList empty?
 Iterator iterator()
          Return an iterator over the entire list.
 HashedList.HashedListIterator iterator(int n)
          Return an iterator starting with the n'th entry.
 HashedList.HashedListIterator iterator(Object key)
          Return an iterator over the list starting with the entry with a given key.
 boolean remove(Object o)
          Remove an object from the list.
 boolean removeAll(Collection c)
          Remove all the elements that are found in another collection.
 boolean removeKey(Object key)
          Remove a keyed object from the list.
 boolean replaceKey(Object oldKey, Object newKey)
          Replace the key of a given element.
 boolean retainAll(Collection c)
          Retain only elements contained in another collection
 int size()
          Return the number of elements in the list.
 Object[] toArray()
          Convert to an array of objects
 Object[] toArray(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(Object reference)
Add an element to the end of the list.

Specified by:
add in interface Collection

add

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


removeKey

public boolean removeKey(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(Object o)
Remove an object from the list.

Specified by:
remove in interface Collection

iterator

public 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 Iterable
Specified by:
iterator in interface Collection

iterator

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

Throws:
NoSuchElementException

iterator

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

Throws:
NoSuchElementException

get

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


get

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

Throws:
NoSuchElementException

replaceKey

public boolean replaceKey(Object oldKey,
                          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(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 Collection

addAll

public boolean addAll(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 Collection

clear

public void clear()
Clear the collection

Specified by:
clear in interface Collection

contains

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

Specified by:
contains in interface Collection

containsAll

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

Specified by:
containsAll in interface Collection

isEmpty

public boolean isEmpty()
Is the HashedList empty?

Specified by:
isEmpty in interface Collection

removeAll

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

Specified by:
removeAll in interface Collection

retainAll

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

Specified by:
retainAll in interface Collection

toArray

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

Specified by:
toArray in interface Collection

toArray

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

Specified by:
toArray in interface Collection


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.