Class pmr.euclid.IntSet
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.euclid.IntSet

java.lang.Object
   |
   +----pmr.euclid.IntSet

public class IntSet
extends Object
public class IntSet Stores a unique set of ints (i.e. cannot contain duplicate ints. The limits can be set with setMin and setMax. There are operations for combining sets (e.g. NOT, OR) and sets can be built up incrementally.

Inverse mapping. IntSets can be used to map one set of indexed data to another, e.g.

RealArray x = someFunction();
InstSet idx = x.indexSortAscending();
for (int i = 0; i < x.size(); i++) {
y[i] = x[idx[i]];
}
To map the other way, x[i] = y[inv[i]]; the inverse IntSet can be used

Author:
(C) P. Murray-Rust, 1996

Constructor Index

 o IntSet()
 o IntSet(int)
creates an IntSet with the integers 0...nelem-1
 o IntSet(int, int)
creates an IntSet with the integers start...end (if start <= end)
 o IntSet(int[])
make from an int[] - all values must be distinct;
 o IntSet(IntSet)
copy constructor

Method Index

 o addElement(int)
add integer.
 o addRange(IntRange)
add all values from an IntRange
 o addSet(IntSet)
concatenate sets
 o contains(int)
 o debug()
 o elementAt(int)
 o equals(IntSet)
element-by-element comparison of sets
 o getElements()
 o getIntArray()
 o intersectionWith(IntSet)
intersect two sets (i.e.
 o inverseMap()
Inverse mapping - see introduction.
 o notIn(IntSet)
elements only in first set
 o setMax(int)
 o setMin(int)
 o size()
 o sortAscending()
sort the IntSet; MODIFIES 'this'
 o test()
 o toString()

Constructors

 o IntSet
  public IntSet()
 o IntSet
  public IntSet(int nelem)
creates an IntSet with the integers 0...nelem-1
 o IntSet
  public IntSet(int start,
                int end)
creates an IntSet with the integers start...end (if start <= end)
 o IntSet
  public IntSet(IntSet is)
copy constructor
 o IntSet
  public IntSet(int is[]) throws InvalidArgumentException
make from an int[] - all values must be distinct;
Throws: InvalidArgumentException
values were not distinct

Methods

 o equals
  public boolean equals(IntSet is)
element-by-element comparison of sets
 o getElements
  public int[] getElements()
 o setMax
  public void setMax(int max)
 o setMin
  public void setMin(int min)
 o size
  public int size()
 o addElement
  public boolean addElement(int value)
add integer. Fails if it is outside limits or already exists in set
 o contains
  public boolean contains(int value)
 o elementAt
  public int elementAt(int i) throws ArrayIndexOutOfBoundsException
 o getIntArray
  public IntArray getIntArray()
 o sortAscending
  public void sortAscending()
sort the IntSet; MODIFIES 'this'
 o addSet
  public void addSet(IntSet is)
concatenate sets
 o intersectionWith
  public IntSet intersectionWith(IntSet is)
intersect two sets (i.e. elements common to both)
 o notIn
  public IntSet notIn(IntSet is)
elements only in first set
 o addRange
  public void addRange(IntRange ir)
add all values from an IntRange
 o inverseMap
  public IntSet inverseMap() throws ArrayIndexOutOfBoundsException
Inverse mapping - see introduction. if y[i] = x[this.elementAt(i)]; then the result supports x[i] = y[inv.elementAt(i)];
Throws: ArrayIndexOutOfBoundsException
the set must contain the integers 0...nelem-1
 o debug
  public void debug()
 o toString
  public String toString()
Overrides:
toString in class Object
 o test
  public static void test()

All Packages  Class Hierarchy  This Package  Previous  Next  Index