public final class IndexedValueMap extends Object
Value objects using an
array. If the size of the array grows beyond IndexedValueMap.MAP_FALLBACK_THRESHOLD then
this data structure does a switch to EconomicMap backing. When the data structure is
populated via the copy constructor, or
the IndexedValueMap.putAll(IndexedValueMap) method while being empty, the backing array
or map are not copied, instead the backing array or map from the source are used. They are copied
only on the next modification. Therefore, IndexedValueMap instances must not be passed to
other threads.| Constructor and Description |
|---|
IndexedValueMap()
Construct a new empty map.
|
IndexedValueMap(IndexedValueMap other)
Constructs a new map containing the same mappings as the
other map. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other)
Determine whether the specified object is an
IndexedValueMap and all the mappings
with non-null values are equal in this map and the specified map. |
void |
forEach(LIRInstruction inst,
LIRInstruction.OperandMode mode,
EnumSet<LIRInstruction.OperandFlag> flags,
InstructionValueProcedure proc)
Iterate over all non-null values and, optionally, modify them.
|
Value |
get(int index)
Returns the value to which the specified index is mapped, or
null if the map contains
no mapping for the index. |
int |
hashCode() |
void |
put(int index,
Value value)
Associates the specified value with the specified index in this map.
|
void |
putAll(IndexedValueMap stack)
Copies all of the mappings with non-null value from the specified map to this map.
|
String |
toString()
Get a string representation for all mappings in this map with a non-null value.
|
void |
visitEach(LIRInstruction inst,
LIRInstruction.OperandMode mode,
EnumSet<LIRInstruction.OperandFlag> flags,
InstructionValueConsumer consumer)
Iterate over all non-null values without modifying them.
|
public IndexedValueMap()
public IndexedValueMap(IndexedValueMap other)
other map. Note that the
mappings are not copied, instead the new map uses the same backing as the source map, copying
it only on the next modification. As a result, the backing of the source map has to be copied
on the next modification as well.other - the source map whose mappings are to be placed in this mappublic Value get(int index)
null if the map contains
no mapping for the index.index - the index whose associated value is to be returnednull if the map contains
no mapping for the indexpublic void put(int index,
Value value)
IndexedValueMap.copyOnWrite is
true, the backing array or map are copied. If this map is backed by the array and
this operation requires it to grow above IndexedValueMap.MAP_FALLBACK_THRESHOLD, the
array is copied to the fallback map which becomes the new backing for this map.index - the index with which the specified value is to be associatedvalue - value to be associated with the specified indexpublic void putAll(IndexedValueMap stack)
IndexedValueMap.copyOnWrite is true, the backing array or map are copied. If
this map is backed by the array and this operation requires it to grow above
IndexedValueMap.MAP_FALLBACK_THRESHOLD, the array is copied to the fallback map which
becomes the new backing for this map. If this map is empty, the mappings from the specified
map are not copied, instead the new map uses the same backing as the source map, copying it
only on the next modification. As a result, the backing of the source map has to be copied on
the next modification as well.stack - mappings to be stored in this mappublic boolean equals(Object other)
IndexedValueMap and all the mappings
with non-null values are equal in this map and the specified map.equals in class Objectother - the object to compare this map withtrue if and only if the specified object is an IndexedValueMap and
all the mappings with non-null values are equal in this map and the specified map.public void forEach(LIRInstruction inst, LIRInstruction.OperandMode mode, EnumSet<LIRInstruction.OperandFlag> flags, InstructionValueProcedure proc)
inst - current instructionmode - the operand mode for each valueflags - a set of flags for each valueproc - procedure to apply to each valuepublic void visitEach(LIRInstruction inst, LIRInstruction.OperandMode mode, EnumSet<LIRInstruction.OperandFlag> flags, InstructionValueConsumer consumer)
inst - current instructionmode - the operand mode for each valueflags - a set of flags for each valueconsumer - consumer function to be called for each value