T
- type of objects to store in this mappublic class FastAccessNumberMap<T> extends Object implements Iterable<T>
pageSize*maxPageCount
at the cost of high memory use. Values are kept in dynamically
allocated pages, each of a fixed size.
It can be thought of as a big array that is split up into pages of a fixed size. This is useful if you want to use a sparse set of indexes since you don't have to allocate the full array immediately. If you are going to fill all indexes then it is more practical to use a normal array or list.
If you try to access an index outside of the max page count then an overflow hash map is used as a fallback mechanism. In that case access will be slower than O(1).
Constructor and Description |
---|
FastAccessNumberMap()
Constructs a map with O(1) access up to index 5000.
|
FastAccessNumberMap(int pageSize,
int maxPageCount)
Constructs a map with O(1) access up to index
pageSize*maxPageCount . |
Modifier and Type | Method and Description |
---|---|
T |
get(long index)
Get the value at an index.
|
Iterator<T> |
iterator() |
void |
put(long index,
T value)
Store a value at an index.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public FastAccessNumberMap()
public FastAccessNumberMap(int pageSize, int maxPageCount)
pageSize*maxPageCount
.pageSize
- page sizemaxPageCount
- max page countCopyright © 2019. All rights reserved.