jumbo.euclid
Class IntSet

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

public class IntSet
extends java.lang.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


Constructor Summary
IntSet()
           
IntSet(int nelem)
          creates an IntSet with the integers 0...nelem-1
IntSet(int[] is)
          make from an int[] - all values must be distinct;
IntSet(int start, int end)
          creates an IntSet with the integers start...end (if start <= end)
IntSet(IntSet is)
          copy constructor
IntSet(IntSet ref, IntSet sub)
          use another IntSet to subscript this one; i.e.
 
Method Summary
 boolean addElement(int value)
          add integer.
 void addRange(IntRange ir)
          add all values from an IntRange
 void addSet(IntSet is)
          concatenate sets
 boolean contains(int value)
           
 void debug()
           
 int elementAt(int i)
           
 boolean equals(IntSet is)
          element-by-element comparison of sets
 int[] getElements()
           
 IntArray getIntArray()
           
 IntSet intersectionWith(IntSet is)
          intersect two sets (i.e.
 IntSet inverseMap()
          Inverse mapping - see introduction.
 IntSet notIn(IntSet is)
          elements only in first set
 void setMax(int max)
           
 void setMin(int min)
           
 int size()
           
 void sortAscending()
          sort the IntSet; MODIFIES 'this'
static void test()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntSet

public IntSet()

IntSet

public IntSet(int nelem)
creates an IntSet with the integers 0...nelem-1

IntSet

public IntSet(int start,
              int end)
creates an IntSet with the integers start...end (if start <= end)

IntSet

public IntSet(IntSet is)
copy constructor

IntSet

public IntSet(int[] is)
       throws BadArgumentException
make from an int[] - all values must be distinct;
Throws:
BadArgumentException - values were not distinct

IntSet

public IntSet(IntSet ref,
              IntSet sub)
       throws java.lang.IllegalArgumentException
use another IntSet to subscript this one; i.e. I(this) = I(ref) subscripted by I(sub); Result has dimension of I(sub). If any of I(sub) lies outside 0...refmax-1, throw an error
Method Detail

equals

public boolean equals(IntSet is)
element-by-element comparison of sets

getElements

public int[] getElements()

setMax

public void setMax(int max)

setMin

public void setMin(int min)

size

public int size()

addElement

public boolean addElement(int value)
add integer. Fails if it is outside limits or already exists in set

contains

public boolean contains(int value)

elementAt

public int elementAt(int i)
              throws java.lang.ArrayIndexOutOfBoundsException

getIntArray

public IntArray getIntArray()

sortAscending

public void sortAscending()
sort the IntSet; MODIFIES 'this'

addSet

public void addSet(IntSet is)
concatenate sets

intersectionWith

public IntSet intersectionWith(IntSet is)
intersect two sets (i.e. elements common to both)

notIn

public IntSet notIn(IntSet is)
elements only in first set

addRange

public void addRange(IntRange ir)
add all values from an IntRange

inverseMap

public IntSet inverseMap()
                  throws java.lang.ArrayIndexOutOfBoundsException
Inverse mapping - see introduction. if y[i] = x[this.elementAt(i)]; then the result supports x[i] = y[inv.elementAt(i)];
Throws:
java.lang.ArrayIndexOutOfBoundsException - the set must contain the integers 0...nelem-1

debug

public void debug()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

test

public static void test()