net.aavalla.utils.general
Class RetrievalHashSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by net.aavalla.utils.general.RetrievalHashSet<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public class RetrievalHashSet<E>
extends java.util.AbstractSet<E>
implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable

HashSet is an implementation of a Set. All optional operations (adding and removing) are supported. The elements can be any objects.

See Also:
Serialized Form

Constructor Summary
RetrievalHashSet()
          Constructs a new empty instance of HashSet.
RetrievalHashSet(java.util.Collection<? extends E> collection)
          Constructs a new instance of RetrievalHashSet containing the unique elements in the specified collection.
RetrievalHashSet(int capacity)
          Constructs a new instance of RetrievalHashSet with the specified capacity.
RetrievalHashSet(int capacity, float loadFactor)
          Constructs a new instance of RetrievalHashSet with the specified capacity and load factor.
 
Method Summary
 boolean add(E object)
          Adds the specified object to this RetrievalHashSet if not already present.
 void clear()
          Removes all elements from this RetrievalHashSet, leaving it empty.
 java.lang.Object clone()
          Returns a new RetrievalHashSet with the same elements and size as this RetrievalHashSet.
 boolean contains(java.lang.Object object)
          Searches this RetrievalHashSet for the specified object.
 E getKey(E templateKey)
           
 boolean isEmpty()
          Returns true if this RetrievalHashSet has no elements, false otherwise.
 java.util.Iterator<E> iterator()
          Returns an Iterator on the elements of this RetrievalHashSet.
 boolean remove(java.lang.Object object)
          Removes the specified object from this RetrievalHashSet.
 int size()
          Returns the number of elements in this RetrievalHashSet.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

RetrievalHashSet

public RetrievalHashSet()
Constructs a new empty instance of HashSet.


RetrievalHashSet

public RetrievalHashSet(int capacity)
Constructs a new instance of RetrievalHashSet with the specified capacity.

Parameters:
capacity - the initial capacity of this RetrievalHashSet.

RetrievalHashSet

public RetrievalHashSet(int capacity,
                        float loadFactor)
Constructs a new instance of RetrievalHashSet with the specified capacity and load factor.

Parameters:
capacity - the initial capacity.
loadFactor - the initial load factor.

RetrievalHashSet

public RetrievalHashSet(java.util.Collection<? extends E> collection)
Constructs a new instance of RetrievalHashSet containing the unique elements in the specified collection.

Parameters:
collection - the collection of elements to add.
Method Detail

add

public boolean add(E object)
Adds the specified object to this RetrievalHashSet if not already present.

Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.Set<E>
Overrides:
add in class java.util.AbstractCollection<E>
Parameters:
object - the object to add.
Returns:
true when this RetrievalHashSet did not already contain the object, false otherwise

clear

public void clear()
Removes all elements from this RetrievalHashSet, leaving it empty.

Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.Set<E>
Overrides:
clear in class java.util.AbstractCollection<E>
See Also:
isEmpty(), size()

clone

public java.lang.Object clone()
Returns a new RetrievalHashSet with the same elements and size as this RetrievalHashSet.

Overrides:
clone in class java.lang.Object
Returns:
a shallow copy of this RetrievalHashSet.
See Also:
Cloneable

contains

public boolean contains(java.lang.Object object)
Searches this RetrievalHashSet for the specified object.

Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.Set<E>
Overrides:
contains in class java.util.AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this RetrievalHashSet, false otherwise.

isEmpty

public boolean isEmpty()
Returns true if this RetrievalHashSet has no elements, false otherwise.

Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.Set<E>
Overrides:
isEmpty in class java.util.AbstractCollection<E>
Returns:
true if this RetrievalHashSet has no elements, false otherwise.
See Also:
size()

iterator

public java.util.Iterator<E> iterator()
Returns an Iterator on the elements of this RetrievalHashSet.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>
Specified by:
iterator in class java.util.AbstractCollection<E>
Returns:
an Iterator on the elements of this RetrievalHashSet.
See Also:
Iterator

remove

public boolean remove(java.lang.Object object)
Removes the specified object from this RetrievalHashSet.

Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.Set<E>
Overrides:
remove in class java.util.AbstractCollection<E>
Parameters:
object - the object to remove.
Returns:
true if the object was removed, false otherwise.

size

public int size()
Returns the number of elements in this RetrievalHashSet.

Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>
Specified by:
size in class java.util.AbstractCollection<E>
Returns:
the number of elements in this RetrievalHashSet.

getKey

public E getKey(E templateKey)