All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class relaaja.netlayout.VGJ.Set

java.lang.Object
   |
   +----relaaja.netlayout.VGJ.Set

public class Set
extends Object
implements Cloneable
This class is similar to Java's BitSet class (only it is not full of bugs). It is used to represent an ordered set of non-negative integers. The set automatically grows as more spaces are needed.

Here is the source.


Variable Index

 o BITS
 o bits_
 o MASK
 o nextPosition_

Constructor Index

 o Set()
Construct an empty Set.
 o Set(int)
Construct a Set with one element.

Method Index

 o clone()
Make a copy of current set.
 o difference(Set)
Modify the current set to the difference of current set and s (current - s).
 o equals(Set)
Check if set s equals to current set.
 o fill(int)
Put elements 0 to n - 1 into the current set.
 o first()
Find the first element of current set.
 o grow_(int)
 o includeElement(int)
Include element n into the current set.
 o indexedUnion(Set[], Set)
 o intersect(Set)
Modify the current set to the intersection of current set and set s.
 o intersects(Set)
 o isElement(int)
Check if n is an element of currernt set.
 o isEmpty()
Check if current set is empty.
 o isSubset(Set)
Check if set s is a subset of current set.
 o next()
Find the next element of current set.
 o numberOfElements()
Find the number of elements of current set.
 o removeElement(int)
Remove element n from the current set.
 o searchNext(int)
Start at position n to search next element.
 o toShortString()
Convert set to "(0-2, 5, 9 ..., n)" String format.
 o toString()
Convert set to "(0, 1, 2, ..., n)" String format.
 o union(Set)
Modify the current set to the union of current set and set s.

Variables

 o BITS
 static final int BITS
 o MASK
 static final int MASK
 o bits_
 private long bits_[]
 o nextPosition_
 private int nextPosition_

Constructors

 o Set
 public Set()
Construct an empty Set.

 o Set
 public Set(int element)
Construct a Set with one element.

Methods

 o grow_
 private void grow_(int len)
 o searchNext
 public int searchNext(int n)
Start at position n to search next element.

Parameters:
n - start position of searching
Returns:
element -- if an element found, or -1 -- if no element found.
 o isEmpty
 public boolean isEmpty()
Check if current set is empty.

Returns:
true -- if current set is empty, or false -- if current set is not empty.
 o first
 public int first()
Find the first element of current set.

Returns:
element -- the first element of the set, or -1 -- if set is empty.
 o next
 public int next()
Find the next element of current set.

Returns:
element -- the next element of the set, or -1 -- if there is no next element.
 o isElement
 public boolean isElement(int n)
Check if n is an element of currernt set.

Parameters:
n - element to be checked
Returns:
true -- n is an element of current set, or flase -- n is not an element of current set.
 o includeElement
 public void includeElement(int n)
Include element n into the current set. This routine doesn't check if element n exists.

Parameters:
n - element to be included
 o removeElement
 public void removeElement(int n) throws NoSuchElementException
Remove element n from the current set. This routine doesn't check if element n exists.

Parameters:
n - element to removed
 o isSubset
 public boolean isSubset(Set s)
Check if set s is a subset of current set.

Parameters:
s - subset to be checked
Returns:
true -- s is a subset of current set, or false -- s is not a subset of current set.
 o intersect
 public void intersect(Set s)
Modify the current set to the intersection of current set and set s.

Parameters:
s - set to be checked
Returns:
the intersection of current set and set s.
 o union
 public void union(Set s)
Modify the current set to the union of current set and set s.

Parameters:
s - set to be united
Returns:
the union of current set and set s.
 o difference
 public void difference(Set s)
Modify the current set to the difference of current set and s (current - s).

Parameters:
s - set to be checked
Returns:
the difference of current set - set s.
 o clone
 public Object clone()
Make a copy of current set.

Returns:
copy of current set.
Overrides:
clone in class Object
 o equals
 public boolean equals(Set s)
Check if set s equals to current set.

Parameters:
s - set to be check
Returns:
true -- set s is equal to current set, or false -- set s is not equal to current set.
 o toString
 public String toString()
Convert set to "(0, 1, 2, ..., n)" String format.

Returns:
current set in String format.
Overrides:
toString in class Object
 o toShortString
 public String toShortString()
Convert set to "(0-2, 5, 9 ..., n)" String format.

Returns:
current set in String format.
 o numberOfElements
 public int numberOfElements()
Find the number of elements of current set.

Returns:
number of elements.
 o fill
 public void fill(int n)
Put elements 0 to n - 1 into the current set.

Parameters:
n - number of elements to be included
 o indexedUnion
 public void indexedUnion(Set set_list[],
                          Set index)
 o intersects
 public boolean intersects(Set set)

All Packages  Class Hierarchy  This Package  Previous  Next  Index