All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.CharSet

java.lang.Object
    |
    +----structure.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.

See Also:
BitSet

Constructor Index

 o CharSet()
Constructs an empty charset.

Method Index

 o add(char)
Adds character c to set if not already there.
 o clear()
Removes the characters of the set.
 o clone()
Construct a duplicate of the character set.
 o contains(char)
Detects whether c is a member of this set.
 o difference(CharSet)
Computes the difference between this and other charset.
 o equals(Object)
Detect if two sets are equal.
 o intersection(CharSet)
Computes the intersection of this charset and other.
 o isEmpty()
Detect an empty charset.
 o remove(char)
Removes a character from set.
 o subset(CharSet)
Detects if this set within the other.
 o toString()
Compute String representation of charset.
 o union(CharSet)
Constructs a charset that is the union of this and other.

Constructors

 o CharSet
public CharSet()
Constructs an empty charset.

Postcondition:
constructs an empty set of characters

Methods

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

Postcondition:
adds c to set

Parameters:
c - The character to be added to set.
 o remove
public void remove(char c)
Removes a character from set. Does nothing if char not in set.

Postcondition:
removes c from set, if present

Parameters:
c - The character to be removed.
 o contains
public boolean contains(char c)
Detects whether c is a member of this set.

Postcondition:
returns true iff c in set

Parameters:
c - The char sought.
Returns:
True iff c is a member of this set.
 o clear
public void clear()
Removes the characters of the set.

Postcondition:
removes all characters from set

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

Postcondition:
constructs a copy of this set

Returns:
Returns a duplicate of this character set.
Overrides:
clone in class Object
 o union
public Object union(CharSet other)
Constructs a charset that is the union of this and other.

Precondition:
other is not null
Postcondition:
returns new set with characters from this or other

Parameters:
other - The other character set.
Returns:
The result of the union --- contains c if in either set.
 o intersection
public Object intersection(CharSet other)
Computes the intersection of this charset and other.

Precondition:
other is not null
Postcondition:
returns new set with characters from this and other

Parameters:
other - The other character set.
Returns:
The intersection of this and other --- char in result if in both.
 o difference
public Object difference(CharSet other)
Computes the difference between this and other charset.

Precondition:
other is not null
Postcondition:
returns new set with characters from this but not other

Parameters:
other - The other character set.
Returns:
the result of difference --- chars in this but not other.
 o subset
public boolean subset(CharSet other)
Detects if this set within the other.

Precondition:
other is not null
Postcondition:
returns true if this is a subset of other

Parameters:
other - The potential superset.
 o isEmpty
public boolean isEmpty()
Detect an empty charset.

Postcondition:
returns true iff set is empty

Returns:
True if this charset is empty.
 o equals
public boolean equals(Object other)
Detect if two sets are equal.

Precondition:
other is not null
Postcondition:
returns true if this contains same values as other

Parameters:
other - The other set.
Returns:
True if this set and other set are identical.
Overrides:
equals in class Object
 o toString
public String toString()
Compute String representation of charset.

Postcondition:
returns string representation of set

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index