Package de.linusdev.lutils.llist
Class LLinkedList<O>
java.lang.Object
de.linusdev.lutils.llist.LLinkedList<O>
- Type Parameters:
O- element class
- All Implemented Interfaces:
Iterable<O>,Collection<O>,List<O>
A thread safe linked list implementation. It can only be traversed in a single direction.
Tt can not be traversed in reverse. That is because every node only stores the next element, but not
the previous element.
This list allows modification during iteration. Whether the modification applies during the iteration depends solely on the order, in which the iteration and modification events happen.
For more complex operations, which must be thread safe, this list also provides a
This list allows modification during iteration. Whether the modification applies during the iteration depends solely on the order, in which the iteration and modification events happen.
For more complex operations, which must be thread safe, this list also provides a
doSynchronized
method, which executes the given Function synchronized on this list's lock. Which means, no modifying operations
can be started by other threads, while the lock is being hold. Reading operations are still possible by all threads.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, @NotNull Collection<? extends O> c) booleanaddAll(@NotNull Collection<? extends O> c) voidclear()booleanbooleancontainsAll(@NotNull Collection<?> c) <R> RdoSynchronized(@NotNull Function<LLinkedList<O>, R> function) Executes given consumer synchronized on this list's lock.get(int index) intbooleanisEmpty()@NotNull LLinkedListIterator<O>iterator()int@NotNull ListIterator<O>@NotNull ListIterator<O>listIterator(int index) This List cannot be traversed in reverse.remove(int index) booleanbooleanremoveAll(@NotNull Collection<?> c) booleanretainAll(@NotNull Collection<?> c) intsize()subList(int fromIndex, int toIndex) @NotNull Object @NotNull []toArray()<T> @NotNull T @NotNull []toArray(T @NotNull [] a) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Constructor Details
-
LLinkedList
public LLinkedList()
-
-
Method Details
-
doSynchronized
Executes given consumer synchronized on this list's lock. SeeLLinkedListfor more information.- Parameters:
function-Function- See Also:
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
@NotNull public <T> @NotNull T @NotNull [] toArray(T @NotNull [] a) -
add
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<O>- Specified by:
containsAllin interfaceList<O>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<O>
-
listIterator
- Specified by:
listIteratorin interfaceList<O>
-
listIterator
This List cannot be traversed in reverse.- Specified by:
listIteratorin interfaceList<O>- Throws:
UnsupportedOperationException- always
-
subList
-
toString
-