|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
javolution.util.Index
public final class Index
This class represents a unique index which can be used instead of
java.lang.Integer for primitive data types collections.
For example:
class SparseVector<F> {
FastMap<Index, F> _elements = new FastMap<Index, F>();
...
}
Unicity is guaranteed and direct equality (==) can be used
in place of object equality (Index.equals(Object)).
Indices have no adverse effect on the garbage collector (persistent instances), but should not be used for large integer values as that would increase the permanent memory footprint significantly.
RTSJ: Instance of this classes are allocated in
ImmortalMemory. Indices can be pre-allocated at start-up
to avoid run-time allocation delays by configuring
INITIAL_FIRST and/or INITIAL_LAST or through
setMinimumRange(int, int).
| Field Summary | |
|---|---|
static Configurable<java.lang.Integer> |
INITIAL_FIRST
Holds the initial first index value (default -1). |
static Configurable<java.lang.Integer> |
INITIAL_LAST
Holds the initial last index value (default 16). |
static Index |
ZERO
Holds the index zero (value 0). |
| Method Summary | |
|---|---|
int |
compareTo(Index that)
|
double |
doubleValue()
Returns the index value as int. |
boolean |
equals(java.lang.Object obj)
Indicates if this index is equals to the one specified (unicity ensures that this method is equivalent to ==). |
float |
floatValue()
Returns the index value as float. |
FastCollection.Record |
getNext()
Returns the record after this one. |
FastCollection.Record |
getPrevious()
Returns the record before this one. |
int |
hashCode()
Returns the hash code for this index. |
int |
intValue()
Returns the index value as int. |
long |
longValue()
Returns the index value as long. |
protected java.lang.Object |
readResolve()
Ensures index unicity during deserialization. |
static void |
setMinimumRange(int first,
int last)
Creates the indices for the specified range of values if they don't exist. |
java.lang.String |
toString()
Returns the String representation of this index. |
static Index |
valueOf(int i)
Returns the unique index for the specified int value
(creating it as well as the indices toward zero
if they do not exist). |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Configurable<java.lang.Integer> INITIAL_FIRST
-1).
public static final Configurable<java.lang.Integer> INITIAL_LAST
16).
public static final Index ZERO
0).
| Method Detail |
|---|
public static void setMinimumRange(int first,
int last)
first - the first index value.last - the last index value.
java.lang.IllegalArgumentException - if first > lastpublic static Index valueOf(int i)
int value
(creating it as well as the indices toward zero
if they do not exist).
i - the index value.
public final int intValue()
int.
intValue in class java.lang.Numberpublic final long longValue()
long.
longValue in class java.lang.Numberpublic final float floatValue()
float.
floatValue in class java.lang.Numberpublic final double doubleValue()
int.
doubleValue in class java.lang.Numberpublic final java.lang.String toString()
String representation of this index.
toString in class java.lang.Objectpublic final boolean equals(java.lang.Object obj)
==).
equals in class java.lang.Objectthis == objpublic final int hashCode()
hashCode in class java.lang.Object
protected final java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptionpublic int compareTo(Index that)
compareTo in interface java.lang.Comparable<Index>public final FastCollection.Record getNext()
FastCollection.Record
getNext in interface FastCollection.Recordpublic final FastCollection.Record getPrevious()
FastCollection.Record
getPrevious in interface FastCollection.Record
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||