public class IntSet extends Object implements EuclidConstants
Inverse mapping. IntSets can be used to map one set of indexed data to another, for example
RealArray x = someFunction(); To map the other way,
InstSet idx = x.indexSortAscending();
for (int i = 0; i <x.size(); i++) {
y[i] = x[idx[i]];
}
x[i] = y[inv[i]]; the inverse IntSet
can be used
| Modifier and Type | Field and Description |
|---|---|
static Map<Integer,List<List<Integer>>> |
integerMap |
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
IntSet()
constructor.
|
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
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addElement(int value)
add integer Fails if it is outside limits or already exists in set
|
void |
addRange(IntRange ir)
add all values from an IntRange if range is 2,5 adds 2,3,4,5
|
void |
addSet(IntSet is)
concatenate sets.
|
boolean |
contains(int value)
does set contain value.
|
void |
debug()
debug.
|
int |
elementAt(int i)
get element.
|
int[] |
getElements()
get elements.
|
IntArray |
getIntArray()
gets the ints as an IntArray.
|
static List<int[]> |
getPermutations(Integer number)
create all permutations of an integer.
|
IntSet |
getSubscriptedIntSet(IntSet sub)
use another IntSet to subscript this one that is I(new) = I(this)
subscripted by I(sub); Result has dimension of I(sub).
|
IntSet |
intersectionWith(IntSet is)
intersect two sets (that is elements common to both)
|
IntSet |
inverseMap()
Inverse mapping - see introduction if
y[i] = x[this.elementAt(i)];
then the result supports x[i] = y[inv.elementAt(i)]; |
boolean |
isEqualTo(IntSet is)
element-by-element comparison of sets
|
IntSet |
notIn(IntSet is)
elements only in first set
|
void |
setMax(int max)
set maximum allowed value.
|
void |
setMin(int min)
set minimum allowed value.
|
int |
size()
size of array.
|
void |
sortAscending()
sort the IntSet; MODIFIES 'this'
|
String |
toString()
to string.
|
public IntSet()
public IntSet(int nelem)
nelem - public IntSet(int start,
int end)
start - end - public IntSet(IntSet is)
is - public IntSet(int[] is)
throws EuclidRuntimeException
is - EuclidRuntimeException - values were not distinctpublic IntSet getSubscriptedIntSet(IntSet sub) throws EuclidRuntimeException
sub - EuclidRuntimeExceptionpublic boolean isEqualTo(IntSet is)
is - public int[] getElements()
public void setMax(int max)
throws EuclidRuntimeException
max - EuclidRuntimeExceptionpublic void setMin(int min)
min - EuclidRuntimeExceptionpublic int size()
public boolean addElement(int value)
throws EuclidRuntimeException
value - EuclidRuntimeExceptionpublic boolean contains(int value)
value - public int elementAt(int i)
throws ArrayIndexOutOfBoundsException
i - ArrayIndexOutOfBoundsExceptionpublic IntArray getIntArray()
getElements()public void sortAscending()
public void addSet(IntSet is) throws EuclidRuntimeException
is - set to appendEuclidRuntimeException - if there are elements in common or exceed max/minpublic IntSet intersectionWith(IntSet is)
is - public void addRange(IntRange ir)
ir - public IntSet inverseMap() throws ArrayIndexOutOfBoundsException
y[i] = x[this.elementAt(i)];
then the result supports x[i] = y[inv.elementAt(i)];ArrayIndexOutOfBoundsException - the set must contain the integers 0...nelem-1public void debug()
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.