public abstract class INArrayRep<ARRAY_BASE_TYPE,REP_ENUM_TYPE,ELEMENT_TYPE> extends Object
Each representation assumes that all read operations are done under a shared latch and all updates (set, copy and compact) are done under an exclusive latch. As a result, the representations themselves do not make any provisions for synchronization.
The callers of all the potentially representation mutating methods:
must be careful to save the result value and use it for subsequent operations, since it could represent the new mutated object.| Constructor and Description |
|---|
INArrayRep() |
| Modifier and Type | Method and Description |
|---|---|
abstract long |
calculateMemorySize()
Returns the current memory size of the underlying representation in
bytes.
|
abstract ARRAY_BASE_TYPE |
compact(IN parent)
Chooses a more compact representation, if that's possible, otherwise
does nothing.
|
abstract ARRAY_BASE_TYPE |
copy(int from,
int to,
int n,
IN parent)
Copies n elements at index denoted by "from" to the index denoted by
"to".
|
abstract ELEMENT_TYPE |
get(int idx)
Returns the element at idx.
|
abstract REP_ENUM_TYPE |
getType() |
abstract ARRAY_BASE_TYPE |
resize(int capacity)
Changes the capacity, either truncating existing elements at the end if
the capacity is reduced, or adding empty elements at the end if the
capacity is enlarged.
|
abstract ARRAY_BASE_TYPE |
set(int idx,
ELEMENT_TYPE e,
IN parent)
Sets the array element at idx to the node.
|
public abstract REP_ENUM_TYPE getType()
public abstract ARRAY_BASE_TYPE set(int idx, ELEMENT_TYPE e, IN parent)
idx - the index to be sete - the array elelement at the idxpublic abstract ELEMENT_TYPE get(int idx)
public abstract ARRAY_BASE_TYPE copy(int from, int to, int n, IN parent)
from - the source (inclusive) of the copyto - the target (inclusive) of the copyn - the number of elements to be copied.public abstract ARRAY_BASE_TYPE compact(IN parent)
WARNING: This method must not change the memory size of the current representation and return 'this', without explicitly adjusting memory usage (via noteRepChange) before returning. Returning a new instance is the trigger for adjusting memory usage in the parent.
public abstract ARRAY_BASE_TYPE resize(int capacity)
public abstract long calculateMemorySize()
Copyright © 2024. All rights reserved.