org.tritonus.share
Class StringHashedSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by org.tritonus.share.ArraySet<E>
                  extended by org.tritonus.share.StringHashedSet<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess, java.util.Set<E>

public class StringHashedSet<E>
extends ArraySet<E>

A set where the elements are uniquely referenced by their string representation as given by the objects toString() method. No 2 objects with the same toString() can be in the set.

The contains(Object elem) and get(Object elem) methods can be called with Strings as elem parameter. For get(Object elem), the object that has been added is returned, and not its String representation.

Though it's possible to store Strings as objects in this class, it doesn't make sense as you could use ArraySet for that equally well.

You shouldn't use the ArrayList specific functions like those that take index parameters.

It is not possible to add null elements.

See Also:
Serialized Form

Constructor Summary
StringHashedSet()
           
StringHashedSet(java.util.Collection<E> c)
           
 
Method Summary
 boolean add(E elem)
           
 boolean contains(java.lang.Object elem)
           
 E get(java.lang.Object elem)
           
 
Methods inherited from class org.tritonus.share.ArraySet
add, set
 
Methods inherited from class java.util.ArrayList
addAll, addAll, clear, clone, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode
 

Constructor Detail

StringHashedSet

public StringHashedSet()

StringHashedSet

public StringHashedSet(java.util.Collection<E> c)
Method Detail

add

public boolean add(E elem)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.List<E>
Specified by:
add in interface java.util.Set<E>
Overrides:
add in class ArraySet<E>

contains

public boolean contains(java.lang.Object elem)
Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.List<E>
Specified by:
contains in interface java.util.Set<E>
Overrides:
contains in class java.util.ArrayList<E>

get

public E get(java.lang.Object elem)