[all packages] [package pizza.util] [class hierarchy] [index]

public class pizza.util.Set<A>

(source file: pizza/util/Set.pizza)
java.lang.Object
   |
   +----pizza.util.Set<A>

The pure class interface.
public class Set<A>
  implements java.io.Serializable, Cloneable

Constuctor Index

O Set()
Constructs a new, empty set
O Set(int)
Constructs a new, empty set with the specified initial capacity.
O Set(int, float)
Constructs a new, empty hashtable with the specified initial capacity and the specified

Methods

O clear()
Clears the set so that it has no more elements in it.
O clone()
Creates a clone of the set
O contains(A)
Returns true if the collection contains an element for the elem.
O elements()
Returns an enumeration of the elements
O isEmpty()
Returns true if the set contains no elements.
O put(A)
Puts the specified element into the set
O rehash()
Rehashes the content of the table into a bigger table. This method is called automatically
O remove(A)
Removes the element corresponding to the elem
O size()
Returns the number of elements contained in the set.
O toString()
Converts to a rather lengthy String.

Constructors

O Set
public Set(int initialCapacity,
           float loadFactor);
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial number of buckets
loadFactor - a number between 0.0 and 1.0, it defines the threshold for rehashing the hashtable into a bigger one.
Throws:
IllegalArgumentException -If the initial capacity is less than or equal to zero.
IllegalArgumentException -If the load factor is less than or equal to zero.

O Set

public Set(int initialCapacity);
Constructs a new, empty set with the specified initial capacity.

Parameters:
initialCapacity - the initial number of buckets

O Set

public Set();
Constructs a new, empty set. A default capacity and load factor is used. Note that the set will automatically grow when it gets full.

Methods

O size
public int size();
Returns the number of elements contained in the set.

O isEmpty

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

O elements

public synchronized Enumeration<A> elements();
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

See also:
keys, Enumeration

O contains

public synchronized boolean contains(A elem);
Returns true if the collection contains an element for the elem.

Parameters:
elem - the elem that we are looking for
See also:
contains

O rehash

protected void rehash();
Rehashes the content of the table into a bigger table. This method is called automatically when the set's size exceeds the threshold.

O put

public synchronized void put(A elem);
Puts the specified element into the set

O remove

public synchronized boolean remove(A elem);
Removes the element corresponding to the elem. Does nothing if the elem is not present. return true iff `elem' was in set.

Parameters:
elem - the elem that needs to be removed

O clear

public synchronized void clear();
Clears the set so that it has no more elements in it.

O clone

public synchronized Object clone();
Creates a clone of the set. A shallow copy is made, the keys and elements themselves are NOT cloned. This is a relatively expensive operation.

Overrides:
clone in class Object

O toString

public synchronized String toString();
Converts to a rather lengthy String.

Overrides:
toString in class Object


[all packages] [package pizza.util] [class hierarchy] [index]
pizza.util.Set.html