java.lang.Object
com.hedera.hashgraph.sdk.LockableList<T>
- Type Parameters:
T- the lockable list type
- All Implemented Interfaces:
Iterable<T>
Internal utility class for a new lockable list type.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.LockableList(ArrayList<T> list) Assign a list of items to this list instance. -
Method Summary
Modifier and TypeMethodDescription(package private) LockableList<T> Add items to this list instance.(package private) LockableList<T> addAll(Collection<? extends T> elements) Add all items to this list instance.(package private) intadvance()Advance to the next item wraps if needed.(package private) LockableList<T> clear()Empty the list.(package private) LockableList<T> ensureCapacity(int capacity) Make sure that this list instance has the requested capacity.(package private) Tget(int index) Get a specific list item.(package private) TExtract the current list.(package private) intgetIndex()What is the current index.getList()Extract the lockable list.(package private) TgetNext()Extract the next item.(package private) booleanisEmpty()Is the list empty?(package private) booleanisLocked()Is the list locked?iterator()(package private) LockableList<T> Remove an item from this list instance.(package private) voidVerify that this list instance is not locked.(package private) LockableList<T> Assign an item at the specified index.(package private) LockableList<T> setIfAbsent(int index, T item) Assign an item to the list if: - item at index is null - index is not greater than size of existing list(package private) LockableList<T> setIndex(int index) Assign the current list index.(package private) LockableList<T> Assign a list to this list instance.(package private) LockableList<T> setLocked(boolean locked) Assign the lock status.shuffle()Shuffle the list items.(package private) intsize()How many items are in the list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LockableList
LockableList()Constructor. -
LockableList
Assign a list of items to this list instance.- Parameters:
list- the lockable list
-
-
Method Details
-
requireNotLocked
void requireNotLocked()Verify that this list instance is not locked. -
ensureCapacity
Make sure that this list instance has the requested capacity.- Parameters:
capacity- the minimum capacity- Returns:
- the updated list
-
setList
Assign a list to this list instance.- Parameters:
list- the lockable list to assign- Returns:
- the updated list
-
getList
Extract the lockable list.- Returns:
- the lockable list
-
add
Add items to this list instance.- Parameters:
elements- the items to add- Returns:
- the updated list
-
addAll
Add all items to this list instance.- Parameters:
elements- the list of items to add- Returns:
- the updated list
-
shuffle
Shuffle the list items.- Returns:
- the updated list
-
remove
Remove an item from this list instance.- Parameters:
element- the element to remove- Returns:
- the updated list
-
getCurrent
T getCurrent()Extract the current list.- Returns:
- the current list item
-
getNext
T getNext()Extract the next item.- Returns:
- the next list item
-
get
Get a specific list item.- Parameters:
index- the index of the item- Returns:
- the item
-
set
Assign an item at the specified index.- Parameters:
index- the index of the itemitem- the item- Returns:
- the updated list
-
setIfAbsent
Assign an item to the list if: - item at index is null - index is not greater than size of existing list- Parameters:
index- the requested indexitem- the item- Returns:
- the updated list
-
advance
int advance()Advance to the next item wraps if needed.- Returns:
- the next index wrapped
-
isEmpty
boolean isEmpty()Is the list empty?- Returns:
- is the list empty
-
isLocked
boolean isLocked()Is the list locked?- Returns:
- is the list locked
-
setLocked
Assign the lock status.- Parameters:
locked- the lock status- Returns:
- the updated list
-
size
int size()How many items are in the list.- Returns:
- the size of the list
-
setIndex
Assign the current list index.- Parameters:
index- the index- Returns:
- the updated list
-
getIndex
int getIndex()What is the current index.- Returns:
- the index of the current item
-
clear
LockableList<T> clear()Empty the list.- Returns:
- an empty list
-
iterator
-