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.
-
BITS
-
-
bits_
-
-
MASK
-
-
nextPosition_
-
-
Set()
- Construct an empty Set.
-
Set(int)
- Construct a Set with one element.
-
clone()
- Make a copy of current set.
-
difference(Set)
- Modify the current set to the difference of current set
and s (current - s).
-
equals(Set)
- Check if set s equals to current set.
-
fill(int)
- Put elements 0 to n - 1 into the current set.
-
first()
- Find the first element of current set.
-
grow_(int)
-
-
includeElement(int)
- Include element n into the current set.
-
indexedUnion(Set[], Set)
-
-
intersect(Set)
- Modify the current set to the intersection of current set and set s.
-
intersects(Set)
-
-
isElement(int)
- Check if n is an element of currernt set.
-
isEmpty()
- Check if current set is empty.
-
isSubset(Set)
- Check if set s is a subset of current set.
-
next()
- Find the next element of current set.
-
numberOfElements()
- Find the number of elements of current set.
-
removeElement(int)
- Remove element n from the current set.
-
searchNext(int)
- Start at position n to search next element.
-
toShortString()
- Convert set to "(0-2, 5, 9 ..., n)" String format.
-
toString()
- Convert set to "(0, 1, 2, ..., n)" String format.
-
union(Set)
- Modify the current set to the union of current set and set s.
BITS
static final int BITS
MASK
static final int MASK
bits_
private long bits_[]
nextPosition_
private int nextPosition_
Set
public Set()
- Construct an empty Set.
Set
public Set(int element)
- Construct a Set with one element.
grow_
private void grow_(int len)
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.
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.
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.
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.
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.
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
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
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.
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.
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.
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.
clone
public Object clone()
- Make a copy of current set.
- Returns:
- copy of current set.
- Overrides:
- clone in class Object
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.
toString
public String toString()
- Convert set to "(0, 1, 2, ..., n)" String format.
- Returns:
- current set in String format.
- Overrides:
- toString in class Object
toShortString
public String toShortString()
- Convert set to "(0-2, 5, 9 ..., n)" String format.
- Returns:
- current set in String format.
numberOfElements
public int numberOfElements()
- Find the number of elements of current set.
- Returns:
- number of elements.
fill
public void fill(int n)
- Put elements 0 to n - 1 into the current set.
- Parameters:
- n - number of elements to be included
indexedUnion
public void indexedUnion(Set set_list[],
Set index)
intersects
public boolean intersects(Set set)
All Packages Class Hierarchy This Package Previous Next Index