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 TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends T> c) boolean
addAll
(Collection<? extends T> c) begin()
Begin a modification session on this list.void
clear()
commit()
Commit changes to the engine list and create a copy for the UI thread.boolean
boolean
containsAll
(Collection<?> c) get
(int index) int
boolean
isEmpty()
iterator()
int
listIterator
(int index) remove
(int index) boolean
boolean
removeAll
(Collection<?> c) void
removeRange
(int fromIndex, int toIndex) boolean
retainAll
(Collection<?> c) void
Clear the full list and replace its content by the other listint
size()
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, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceList<T>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
subList
-