|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.torstennahm.integrate.sparse.index.FastIndex
public class FastIndex
Implements Index.
Only the non-zero entries for the index are stored. For performance,
an array is used for storage, which is grown when needed.
According to general index contract, this class is thread-safe.
| Field Summary | |
|---|---|
protected int[] |
entryNums
Array storing the entry number of each entry. |
protected int[] |
entryVals
Array storing the corresponding value of each entry. |
protected int |
hashCode
Hash code. |
protected int |
nonZeroEntries
Number of entries that are not zero. |
| Constructor Summary | |
|---|---|
FastIndex()
Creates a new fast index. |
|
FastIndex(Index index)
Creates an new FastIndex from any Index. |
|
FastIndex(int[] array)
Creates a fast index from an array. |
|
FastIndex(de.torstennahm.math.SparseIntVector vector)
Creates a new FastIndex from a PackedIntVector. |
|
| Method Summary | |
|---|---|
Index |
add(int entryNum,
int add)
Returns a new index with the specified increment at the specified entry. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this index for equality. |
int |
get(int entryNum)
Returns the value for the specified entry. |
int |
hashCode()
Returns the hash code value for this index. |
java.util.Iterator<de.torstennahm.math.IntEntry> |
iterator()
Returns an IntPairIterator for iterating over the index. |
int |
lastEntry()
Returns the index of highest entry whose value is not 0. |
protected static int |
newHash(int hashCode,
int entryNum,
int oldVal,
int newVal)
|
int |
nonZeroEntries()
Returns the number of entries with values not equal to 0. |
Index |
set(int entryNum,
int value)
Returns a new index with the specified new value at the specified entry. |
int |
sum()
Returns the the sum of all entry values. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int nonZeroEntries
protected int[] entryNums
protected int[] entryVals
protected int hashCode
| Constructor Detail |
|---|
public FastIndex()
public FastIndex(Index index)
FastIndex from any Index.
index - index to initialize frompublic FastIndex(de.torstennahm.math.SparseIntVector vector)
FastIndex from a PackedIntVector.
vector - vector to initialize frompublic FastIndex(int[] array)
array - array to initialize from| Method Detail |
|---|
public int nonZeroEntries()
Index
nonZeroEntries in interface Indexpublic int lastEntry()
Index
lastEntry in interface Indexpublic int get(int entryNum)
Index
get in interface IndexentryNum - number of the entry
public Index set(int entryNum,
int value)
Index
set in interface IndexentryNum - number of the entryvalue - new value for the entry
public Index add(int entryNum,
int add)
Index
add in interface IndexentryNum - number of the entryadd - increment for the entry, may be negative
public int sum()
Index
sum in interface Indexpublic java.util.Iterator<de.torstennahm.math.IntEntry> iterator()
IndexIntPairIterator for iterating over the index.
The iterator skips all entries whose value is zero.
iterator in interface Indexiterator in interface java.lang.Iterable<de.torstennahm.math.IntEntry>
protected static int newHash(int hashCode,
int entryNum,
int oldVal,
int newVal)
public int hashCode()
Index
hashCode in interface IndexhashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
IndexIndex interface.
equals in interface Indexequals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||