|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Immutable public interface JImmutableArray<T>
Immutable sparse array implementation using integers as keys. Keys are traversed in signed integer order by Cursors so negative values are visited before positive values. Implementations are allowed to restrict the range of allowable indexes for performance or other reasons. Implementations should throw IndexOutOfBounds exceptions if presented with an invalid index.
Arrays are sparse meaning that they can contain elements at any valid index with no need to keep them consecutive (like a List). Memory is managed to use no more than necessary for the number of elements currently in the array.
Method Summary | |
---|---|
JImmutableArray<T> |
assign(int index,
T value)
Sets the value associated with a specific index. |
JImmutableArray<T> |
delete(int index)
Deletes the entry for the specified index (if any). |
JImmutableArray<T> |
deleteAll()
|
Holder<T> |
find(int index)
Return a Holder containing the value associated wth the index or an empty Holder if no value is associated with the index. |
Holder<JImmutableMap.Entry<Integer,T>> |
findEntry(int index)
Search for an Entry within the map and return a Holder indicating if the Entry was found and, if it was found, the Entry itself. |
T |
get(int index)
Return the value associated with index or null if no value is associated. |
Map<Integer,T> |
getMap()
Creates an unmodifiable java.util.Map reflecting the values of this PersistentMap. |
T |
getValueOr(int index,
T defaultValue)
Return the value associated with index or defaultValue if no value is associated. |
boolean |
isEmpty()
|
Cursor<Integer> |
keysCursor()
Creates a Cursor to access all of the Map's keys. |
int |
size()
Return the number of entries in the map. |
Cursor<T> |
valuesCursor()
Creates a Cursor to access all of the Map's values. |
Methods inherited from interface org.javimmutable.collections.Insertable |
---|
insert |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Methods inherited from interface org.javimmutable.collections.Cursorable |
---|
cursor |
Method Detail |
---|
@Nullable T get(int index)
get
in interface Indexed<T>
index
- identifies the value to retrieve
@Nullable T getValueOr(int index, @Nullable T defaultValue)
index
- identifies the value to retrievedefaultValue
- value to return if no entry exists for index
@Nonnull Holder<T> find(int index)
index
- identifies the value to retrieve
@Nonnull Holder<JImmutableMap.Entry<Integer,T>> findEntry(int index)
index
- index to search for
@Nonnull JImmutableArray<T> assign(int index, @Nullable T value)
index
- indexvalue
- possibly null value
@Nonnull JImmutableArray<T> delete(int index)
index
- index
int size()
size
in interface Indexed<T>
boolean isEmpty()
@Nonnull JImmutableArray<T> deleteAll()
@Nonnull Map<Integer,T> getMap()
@Nonnull Cursor<Integer> keysCursor()
@Nonnull Cursor<T> valuesCursor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |