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
-
IntSet()
-
-
IntSet(int)
- creates an IntSet with the integers 0...nelem-1
-
IntSet(int, int)
- creates an IntSet with the integers start...end (if start <= end)
-
IntSet(int[])
- make from an int[] - all values must be distinct;
-
IntSet(IntSet)
- copy constructor
-
addElement(int)
- add integer.
-
addRange(IntRange)
- add all values from an IntRange
-
addSet(IntSet)
- concatenate sets
-
contains(int)
-
-
debug()
-
-
elementAt(int)
-
-
equals(IntSet)
- element-by-element comparison of sets
-
getElements()
-
-
getIntArray()
-
-
intersectionWith(IntSet)
- intersect two sets (i.e.
-
inverseMap()
- Inverse mapping - see introduction.
-
notIn(IntSet)
- elements only in first set
-
setMax(int)
-
-
setMin(int)
-
-
size()
-
-
sortAscending()
- sort the IntSet; MODIFIES 'this'
-
test()
-
-
toString()
-
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 InvalidArgumentException
- make from an int[] - all values must be distinct;
- Throws: InvalidArgumentException
- values were not distinct
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 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 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
debug
public void debug()
toString
public String toString()
- Overrides:
- toString in class Object
test
public static void test()
All Packages Class Hierarchy This Package Previous Next Index