structure5
Class CharSet

java.lang.Object
  extended by structure5.CharSet

public class CharSet
extends Object

Implementation of a set of characters whose ASCII values are between 0 and 255, inclusive. This set is specialized for use with characters. It is implemented using the BitSet class. This class's interface differs from the structure.Set, Bitset, and Set interfaces, so care must be taken to invoke the proper methods.

See Also:
structure.BitSet, BitSet

Constructor Summary
CharSet()
          Constructs an empty charset.
 
Method Summary
 void add(char c)
          Adds character c to set if not already there.
 void clear()
          Removes the characters of the set.
 Object clone()
          Construct a duplicate of the character set.
 boolean contains(char c)
          Detects whether c is a member of this set.
 Object difference(CharSet other)
          Computes the difference between this and other charset.
 boolean equals(Object other)
          Detect if two sets are equal.
 Object intersection(CharSet other)
          Computes the intersection of this charset and other.
 boolean isEmpty()
          Detect an empty charset.
 void remove(char c)
          Removes a character from set.
 boolean subset(CharSet other)
          Detects if this set within the other.
 String toString()
          Compute String representation of charset.
 Object union(CharSet other)
          Constructs a charset that is the union of this and other.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharSet

public CharSet()
Constructs an empty charset.

Method Detail

add

public void add(char c)
Adds character c to set if not already there.

Parameters:
c - The character to be added to set.

remove

public void remove(char c)
Removes a character from set. Does nothing if char not in set.

Parameters:
c - The character to be removed.

contains

public boolean contains(char c)
Detects whether c is a member of this set.

Parameters:
c - The char sought.
Returns:
True iff c is a member of this set.

clear

public void clear()
Removes the characters of the set.


clone

public Object clone()
Construct a duplicate of the character set.

Overrides:
clone in class Object
Returns:
Returns a duplicate of this character set.

union

public Object union(CharSet other)
Constructs a charset that is the union of this and other.

Parameters:
other - The other character set.
Returns:
The result of the union --- contains c if in either set.

intersection

public Object intersection(CharSet other)
Computes the intersection of this charset and other.

Parameters:
other - The other character set.
Returns:
The intersection of this and other --- char in result if in both.

difference

public Object difference(CharSet other)
Computes the difference between this and other charset.

Parameters:
other - The other character set.
Returns:
the result of difference --- chars in this but not other.

subset

public boolean subset(CharSet other)
Detects if this set within the other.

Parameters:
other - The potential superset.

isEmpty

public boolean isEmpty()
Detect an empty charset.

Returns:
True if this charset is empty.

equals

public boolean equals(Object other)
Detect if two sets are equal.

Overrides:
equals in class Object
Parameters:
other - The other set.
Returns:
True if this set and other set are identical.

toString

public String toString()
Compute String representation of charset.

Overrides:
toString in class Object
Returns:
String representing this charset.