JaCoP.util
Class SimpleHashSet<E>

java.lang.Object
  extended by JaCoP.util.SimpleHashSet<E>
Type Parameters:
E - Class being stored in SimpleHashSet.

public class SimpleHashSet<E>
extends java.lang.Object

This class provides very simple HashSet functionality. Designed specially for maintaining pending constraints for evaluation. It's implementation was partially based on standard hash set implementation as implemented in java util class.

Version:
3.1
Author:
Radoslaw Szymanek and Krzysztof Kuchcinski

Constructor Summary
SimpleHashSet()
          Constructs an empty HashSet with the default initial capacity (16) and the default load factor (0.75).
SimpleHashSet(int initialCapacity)
          Constructs an empty HashSet with the specified initial capacity and the default load factor (0.75).
SimpleHashSet(int initialCapacity, float loadFactor)
          Constructs an empty HashSet with the specified initial capacity and load factor.
 
Method Summary
 boolean add(E element)
          Adds the specified element to this set.
 void clear()
          Removes all elements from this set.
 java.lang.Object clone()
          Clones this set.
 boolean contains(E element)
          Returns the boolean value which specifies if given element is already in this identity hash set.
 boolean isEmpty()
          Returns true if this set contains no elements.
 E removeFirst()
          Removes and returns an entry removed from the HashSet.
 int size()
          Returns the number of elements in this set.
 java.lang.String toString()
          Returns string representation of the hash set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleHashSet

public SimpleHashSet()
Constructs an empty HashSet with the default initial capacity (16) and the default load factor (0.75).


SimpleHashSet

public SimpleHashSet(int initialCapacity)
Constructs an empty HashSet with the specified initial capacity and the default load factor (0.75).

Parameters:
initialCapacity - the initial capacity.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is negative.

SimpleHashSet

public SimpleHashSet(int initialCapacity,
                     float loadFactor)
Constructs an empty HashSet with the specified initial capacity and load factor.

Parameters:
initialCapacity - The initial capacity.
loadFactor - The load factor.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.
Method Detail

add

public boolean add(E element)
Adds the specified element to this set.

Parameters:
element - element with which the specified value is to be associated.
Returns:
true if object is inserted and false if object was already in the set.

clear

public void clear()
Removes all elements from this set.


clone

public java.lang.Object clone()
Clones this set.

Overrides:
clone in class java.lang.Object

contains

public boolean contains(E element)
Returns the boolean value which specifies if given element is already in this identity hash set.

Parameters:
element - the element whose existence in the hash set is to be checked.
Returns:
the boolean value which specifies if given element exists in a hash set.

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Returns:
true if this set contains no elements.

removeFirst

public E removeFirst()
Removes and returns an entry removed from the HashSet. Returns null if the HashSet contains no entry.

Returns:
the first entry which has been removed.

size

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

Returns:
the number of elements in this set.

toString

public java.lang.String toString()
Returns string representation of the hash set.

Overrides:
toString in class java.lang.Object