|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.transactional.arrays.TransactionalReferenceArray<E>
E - public final class TransactionalReferenceArray<E>
An Transactional array. The elements in the array are of type
Ref. The elements are created eagerly. In the future some
kind of lazy creation mechanism will be added as well, but for the time being this is the simplest solution.
TransactionalArrayList for
an alternative.
| Constructor Summary | |
|---|---|
TransactionalReferenceArray(int length)
Creates a new TransactionalReferenceArray with the specified length. |
|
| Method Summary | |
|---|---|
boolean |
atomicCompareAndSet(int index,
E expected,
E update)
Executes an atomic compare and set, so this call doesn't look at a running transaction, but essentially runs with its own transaction. |
E |
atomicGet(int index)
Returns the currently stored item at the specified index. |
E |
atomicSet(int index,
E update)
Atomically sets the element at the specified index. |
TransactionalReferenceArray<E> |
copyToBiggerArray(int newLength)
Copies the content of this TransactionalReferenceArray to a bigger TransactionalReferenceArray. |
E |
get(int index)
Gets the element at the specified index. |
int |
length()
Returns the length of this TransactionalReferenceArray . |
E |
set(int index,
E item)
Sets the element at the specified index. |
void |
shiftLeft(int firstIndex,
int lastIndex)
Shifts all the items in the array one to the left (so essentially removes items). |
void |
shiftRight(int firstIndex,
int lastIndex)
Create room |
java.lang.Object[] |
toArray(int size)
Sends back an array containing the value of the references in this TransactionalReferenceArray. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TransactionalReferenceArray(int length)
length - the length of the TransactionalReferenceArray.
java.lang.IllegalArgumentException - if length smaller than 0.| Method Detail |
|---|
public E get(int index)
index - the index of the element to get.
java.lang.IndexOutOfBoundsException - if the index is out of bounds.public E atomicGet(int index)
index - the index of the item to get
java.lang.IndexOutOfBoundsException - if index is out of bounds.
public E set(int index,
E item)
index - the index of the element to set.item - the item to set.
java.lang.IndexOutOfBoundsException - if the index is out of bounds.
public E atomicSet(int index,
E update)
index - the index of the element to atomically set.update - the new value
java.lang.IndexOutOfBoundsException - if the index is out of bounds
public boolean atomicCompareAndSet(int index,
E expected,
E update)
index - the index of the reference where the compare and set action needs to be executed on.expected - the value the reference is expected to have.update - the new value
java.lang.IndexOutOfBoundsException - if index is smaller than 0, or larger than array.size.public int length()
public void shiftLeft(int firstIndex,
int lastIndex)
firstIndex - the first index of the item to shift to the left.lastIndex - the index of the last item (inclusive) to shift to the left.
java.lang.IndexOutOfBoundsException - if firstIndex smaller than 1, or firstIndex larger or equal to
the array.length.
public void shiftRight(int firstIndex,
int lastIndex)
firstIndex - lastIndex - public TransactionalReferenceArray<E> copyToBiggerArray(int newLength)
newLength - the new capacity of the bigger TransactionalReferenceArray
java.lang.IllegalArgumentException - if newCapacity is smaller than the current capacity.public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object[] toArray(int size)
size - the number of items to copy. If the size is smaller than the array length, it will
only copy till that length.
java.lang.IllegalArgumentException - if size smaller than 0 or larger than the length
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||