Package heronarts.lx.utils
Class LXEngineThreadArrayList<T>
java.lang.Object
heronarts.lx.utils.LXEngineThreadArrayList<T>
- Type Parameters:
T- Type of object stored by the list
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>,RandomAccess,SequencedCollection<T>
The LXEngineArrayList is a utility class that offers similar semantics to CopyOnWriteArrayList,
but for the scenario in which it's understood that only the LXEngine thread ever writes to the
list, while the UI thread may be frequently reading the list. A single persistent underlying ArrayList
is used to represent the engine's copy of the list, and a copy is prepared for the UI thread
on-demand. Transaction-like semantics are available for complex edit operations that may perform
multiple changes before generating a new UI-thread copy.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends T> c) booleanaddAll(Collection<? extends T> c) begin()Begin a modification session on this list.voidclear()commit()Commit changes to the engine list and create a copy for the UI thread.booleanbooleancontainsAll(Collection<?> c) get(int index) intbooleanisEmpty()iterator()intlistIterator(int index) remove(int index) booleanbooleanremoveAll(Collection<?> c) voidremoveRange(int fromIndex, int toIndex) booleanretainAll(Collection<?> c) voidClear the full list and replace its content by the other listintsize()subList(int fromIndex, int toIndex) Object[]toArray()<V> V[]toArray(V[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
changed
-
-
Constructor Details
-
LXEngineThreadArrayList
public LXEngineThreadArrayList()
-
-
Method Details
-
begin
Begin a modification session on this list. Changes will not update the UI copy unil commit() is called.- Returns:
- this
-
commit
Commit changes to the engine list and create a copy for the UI thread.- Returns:
- this
-
set
Clear the full list and replace its content by the other list- Parameters:
contents- List contents
-
getUIThreadList
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
public <V> V[] toArray(V[] a) -
add
-
remove
-
removeRange
public void removeRange(int fromIndex, int toIndex) -
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
subList
-