|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectNumber
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<Integer> |
INITIAL_FIRST
Holds the initial first index value (default -1 ). |
static Configurable<Integer> |
INITIAL_LAST
Holds the initial last index value (default 31 ). |
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(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 . |
static List<Index> |
rangeOf(int start,
int end)
Returns all the indices greater or equal to start
but less than end . |
protected 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. |
String |
toString()
Returns the String representation of this index. |
Text |
toText()
Returns the textual representation of this real-time object (equivalent to toString except that the returned value
can be "stack" allocated and
supports fast concatenation). |
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). |
static List<Index> |
valuesOf(int... indices)
Returns the list of all the indices specified. |
Methods inherited from class Number |
---|
byteValue, shortValue |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Index ZERO
0
).
public static final Configurable<Integer> INITIAL_FIRST
-1
).
public static final Configurable<Integer> INITIAL_LAST
31
).
Method Detail |
---|
public static void setMinimumRange(int first, int last)
first
- the first index value.last
- the last index value.
IllegalArgumentException
- if first > last
public 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 static List<Index> rangeOf(int start, int end)
start
but less than end
.
start
- the start index.end
- the end index.
[start .. end[
public static List<Index> valuesOf(int... indices)
indices
- the indices values.
{indices[0], indices[1], ...}
public int intValue()
int
.
intValue
in class Number
public long longValue()
long
.
longValue
in class Number
public float floatValue()
float
.
floatValue
in class Number
public double doubleValue()
int
.
doubleValue
in class Number
public String toString()
String
representation of this index.
toString
in class Object
TextFormat.getInstance(Cursor.class).formatToString(_value)
public final boolean equals(Object obj)
==
).
equals
in class Object
this == obj
public final int hashCode()
hashCode
in class Object
protected final Object readResolve() throws ObjectStreamException
ObjectStreamException
public final int compareTo(Index that)
compareTo
in interface Comparable<Index>
public final FastCollection.Record getNext()
FastCollection.Record
getNext
in interface FastCollection.Record
public final FastCollection.Record getPrevious()
FastCollection.Record
getPrevious
in interface FastCollection.Record
public Text toText()
Realtime
toString
except that the returned value
can be "stack"
allocated and
supports fast concatenation).
toText
in interface Realtime
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |