org.ws4d.java.structures
Class HashSet

java.lang.Object
  extended by org.ws4d.java.structures.DataStructure
      extended by org.ws4d.java.structures.Set
          extended by org.ws4d.java.structures.HashSet
Direct Known Subclasses:
LinkedSet

public class HashSet
extends Set


Constructor Summary
HashSet()
          Constructor.
HashSet(DataStructure data)
           
HashSet(int initialCapacity)
           
 
Method Summary
 boolean add(java.lang.Object obj)
          Adds a new object to this data structure.
 void clear()
          Clears this data structure by removing all content from it.
 boolean contains(java.lang.Object obj)
          Checks whether obj (or another instance equal to obj in terms of java.lang.Object.equals(Object) ) is already present within this data structure instance and returns true only if this is the case.
 java.lang.Object get(java.lang.Object obj)
          Get the object from this HashSet that is equal to the given object.
 boolean isEmpty()
          Checks whether this instance is empty or not.
 Iterator iterator()
          Returns an iterator over all items stored within this data structure instance.
 boolean remove(java.lang.Object obj)
          Removes obj from this data structure.
 int size()
          Returns the current size of the data structure.
 
Methods inherited from class org.ws4d.java.structures.Set
containsAll, equals, getClassShortName, hashCode
 
Methods inherited from class org.ws4d.java.structures.DataStructure
addAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashSet

public HashSet()
Constructor.


HashSet

public HashSet(DataStructure data)
Parameters:
data -

HashSet

public HashSet(int initialCapacity)
Method Detail

add

public boolean add(java.lang.Object obj)
Description copied from class: DataStructure
Adds a new object to this data structure.

Overrides:
add in class DataStructure
Parameters:
obj - the object to add
Returns:
true if the object was actually added, false in any other case (e.g. adding an object to a set which already contains the same object in terms of java.lang.Object.equals(Object))

get

public java.lang.Object get(java.lang.Object obj)
Get the object from this HashSet that is equal to the given object.

Parameters:
obj -
Returns:
the equal object from this HashSet or null if it does not contained an equal object

iterator

public Iterator iterator()
Description copied from class: DataStructure
Returns an iterator over all items stored within this data structure instance. The iterator will walk through the items in the natural order of this data structure; i.e. for a list-like structure this will be the same order as the one defined by the list.

Specified by:
iterator in class DataStructure
Returns:
an iterator over all stored objects

size

public int size()
Description copied from class: DataStructure
Returns the current size of the data structure.

Specified by:
size in class DataStructure
Returns:
the size of this data structure

isEmpty

public boolean isEmpty()
Description copied from class: DataStructure
Checks whether this instance is empty or not.

Overrides:
isEmpty in class DataStructure
Returns:
true if this data structure is empty, false otherwise

clear

public void clear()
Description copied from class: DataStructure
Clears this data structure by removing all content from it.

Overrides:
clear in class DataStructure

contains

public boolean contains(java.lang.Object obj)
Description copied from class: DataStructure
Checks whether obj (or another instance equal to obj in terms of java.lang.Object.equals(Object) ) is already present within this data structure instance and returns true only if this is the case.

Overrides:
contains in class DataStructure
Parameters:
obj - the object to check the presence of
Returns:
true if obj is contained by this instance, false if not

remove

public boolean remove(java.lang.Object obj)
Description copied from class: DataStructure
Removes obj from this data structure. Returns true if obj was actually present and thus it was really removed (i.e. this instance was modified by the method call).

Overrides:
remove in class DataStructure
Parameters:
obj - the object to remove
Returns:
true only if obj was actually removed