public class SparseClusterArray<E> extends Object implements Iterable<E>
Modifier and Type | Class and Description |
---|---|
protected static class |
SparseClusterArray.Chunk |
protected static class |
SparseClusterArray.ChunkNode |
protected class |
SparseClusterArray.ElementIndexIterator |
protected class |
SparseClusterArray.ElementIterator<T> |
static class |
SparseClusterArray.Entry<E> |
protected static class |
SparseClusterArray.Node
this corresponds to a toplevel cluster (e.g.
|
protected static class |
SparseClusterArray.Root |
static class |
SparseClusterArray.Snapshot<T,E> |
Modifier and Type | Field and Description |
---|---|
protected static int |
BM_ENTRIES |
protected SparseClusterArray.Entry |
changes |
protected static int |
CHUNK_BASEMASK |
static int |
CHUNK_BITS |
static int |
CHUNK_SIZE |
protected static int |
ELEM_MASK |
protected SparseClusterArray.Chunk |
head |
protected SparseClusterArray.Chunk |
lastChunk |
protected static int |
MAX_BM_INDEX |
static int |
MAX_CLUSTER_ENTRIES |
static int |
MAX_CLUSTERS |
static int |
N_ELEM |
static int |
N_SEG |
protected int |
nSet |
protected SparseClusterArray.Root |
root |
static int |
S1 |
static int |
S2 |
static int |
S3 |
static int |
SEG_BITS |
protected static int |
SEG_MASK |
protected boolean |
trackChanges |
Modifier | Constructor and Description |
---|---|
|
SparseClusterArray() |
protected |
SparseClusterArray(SparseClusterArray base)
be careful, this should only be used to get old stored elements during
a Snapshot restore
|
Modifier and Type | Method and Description |
---|---|
int |
cardinality() |
void |
clear() |
SparseClusterArray<E> |
deepCopy(Cloner<E> elementCloner)
deep copy
we need to do this depth first, right-to-left, to maintain the
Chunk list ordering.
|
int |
firstNullIndex(int i,
int length)
find first null element within given range [i, i+length[
|
E |
get(int i) |
SparseClusterArray.Entry<E> |
getChanges() |
IndexIterator |
getElementIndexIterator() |
IndexIterator |
getElementIndexIterator(int fromIndex) |
<T> SparseClusterArray.Snapshot<E,T> |
getSnapshot(Transformer<E,T> transformer)
create a snapshot that can be used to restore a certain state of our array
This is more suitable than cloning in case the array is very sparse, or
the elements contain a lot of transient data we don't want to store
|
boolean |
isTrackingChanges() |
Iterator<E> |
iterator() |
int |
numberOfChunks() |
int |
numberOfElements() |
protected <T> void |
populateSnapshot(SparseClusterArray.Snapshot<E,T> snap,
Transformer<E,T> transformer) |
void |
resetChanges() |
<T> void |
restore(SparseClusterArray.Snapshot<E,T> snap,
Transformer<T,E> transformer) |
void |
revertChanges(SparseClusterArray.Entry<E> changes) |
void |
set(int i,
E e) |
void |
stopTrackingChanges() |
String |
toString() |
void |
trackChanges() |
public static final int CHUNK_BITS
public static final int CHUNK_SIZE
public static final int N_ELEM
protected static final int ELEM_MASK
protected static final int BM_ENTRIES
protected static final int MAX_BM_INDEX
public static final int SEG_BITS
public static final int N_SEG
protected static final int SEG_MASK
public static final int S1
public static final int S2
public static final int S3
protected static final int CHUNK_BASEMASK
public static final int MAX_CLUSTERS
public static final int MAX_CLUSTER_ENTRIES
protected SparseClusterArray.Root root
protected SparseClusterArray.Chunk lastChunk
protected SparseClusterArray.Chunk head
protected int nSet
protected boolean trackChanges
protected SparseClusterArray.Entry changes
public SparseClusterArray()
protected SparseClusterArray(SparseClusterArray base)
public E get(int i)
public void set(int i, E e)
public int firstNullIndex(int i, int length)
public SparseClusterArray<E> deepCopy(Cloner<E> elementCloner)
public <T> SparseClusterArray.Snapshot<E,T> getSnapshot(Transformer<E,T> transformer)
protected <T> void populateSnapshot(SparseClusterArray.Snapshot<E,T> snap, Transformer<E,T> transformer)
public <T> void restore(SparseClusterArray.Snapshot<E,T> snap, Transformer<T,E> transformer)
public void clear()
public void trackChanges()
public void stopTrackingChanges()
public boolean isTrackingChanges()
public SparseClusterArray.Entry<E> getChanges()
public void resetChanges()
public void revertChanges(SparseClusterArray.Entry<E> changes)
public int numberOfElements()
public int numberOfChunks()
public IndexIterator getElementIndexIterator()
public IndexIterator getElementIndexIterator(int fromIndex)
public int cardinality()