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
CharSet()
- Constructs an empty charset.
add(char)
- Adds character c to set if not already there.
clear()
- Removes the characters of the set.
clone()
- Construct a duplicate of the character set.
contains(char)
- Detects whether c is a member of this set.
difference(CharSet)
- Computes the difference between this and other charset.
equals(Object)
- Detect if two sets are equal.
intersection(CharSet)
- Computes the intersection of this charset and other.
isEmpty()
- Detect an empty charset.
remove(char)
- Removes a character from set.
subset(CharSet)
- Detects if this set within the other.
toString()
- Compute String representation of charset.
union(CharSet)
- Constructs a charset that is the union of this and other.
CharSet
public CharSet()
- Constructs an empty charset.
- Postcondition:
- constructs an empty set of characters
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.
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.
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.
clear
public void clear()
- Removes the characters of the set.
- Postcondition:
- removes all characters from set
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
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.
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.
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.
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.
isEmpty
public boolean isEmpty()
- Detect an empty charset.
- Postcondition:
- returns true iff set is empty
- Returns:
- True if this charset is empty.
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
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