Class IdealList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
io.github.thecsdev.tcdcommons.api.util.collections.IdealList<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
,SequencedCollection<E>
Tired of built-in list types that never have the one thing you need?
Well fear not, for this one has everything that I will ever need!
Well fear not, for this one has everything that I will ever need!
Features:
- Resilient to
ConcurrentModificationException
Iterator
capable of handling complex concurrent changes- Features
find(Predicate)
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected final class
AListIterator
implementation forIdealList
.protected final class
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
final boolean
boolean
protected final void
void
clear()
protected final void
boolean
final E
protected final void
forEachNode
(Consumer<IdealList<E>.Node> action) get
(int index) getNode
(int index) getNodeOrDefault
(int index) int
protected final int
indexOfNode
(IdealList<E>.Node node) final boolean
isEmpty()
iterator()
final ListIterator
<E> listIterator
(int index) protected final int
final E
remove
(int index) final boolean
boolean
removeB
(int index) protected final void
removeNode
(int index) int
size()
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, lastIndexOf, removeRange, subList
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, addFirst, addLast, containsAll, getFirst, getLast, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Constructor Details
-
IdealList
public IdealList()
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in classAbstractCollection<E>
-
isEmpty
public final boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceList<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceList<E>
- Overrides:
clear
in classAbstractList<E>
-
indexOf
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceList<E>
- Overrides:
contains
in classAbstractCollection<E>
-
get
- Specified by:
get
in interfaceList<E>
- Specified by:
get
in classAbstractList<E>
- Throws:
IndexOutOfBoundsException
-
set
- Specified by:
set
in interfaceList<E>
- Overrides:
set
in classAbstractList<E>
- Throws:
IndexOutOfBoundsException
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Overrides:
add
in classAbstractList<E>
-
add
public final void add(int index, E element) throws IndexOutOfBoundsException, UnsupportedOperationException - Specified by:
add
in interfaceList<E>
- Overrides:
add
in classAbstractList<E>
- Throws:
IndexOutOfBoundsException
UnsupportedOperationException
-
addB
- Throws:
IndexOutOfBoundsException
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceList<E>
- Overrides:
remove
in classAbstractCollection<E>
-
remove
- Specified by:
remove
in interfaceList<E>
- Overrides:
remove
in classAbstractList<E>
- Throws:
IndexOutOfBoundsException
UnsupportedOperationException
-
removeB
- Throws:
IndexOutOfBoundsException
-
iterator
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classAbstractList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classAbstractList<E>
- Throws:
IndexOutOfBoundsException
-
find
Returns the first containing element that matches a givenPredicate
, ornull
if such an element is not in thisIdealList
.- Parameters:
predicate
- The elementPredicate
.- Throws:
NullPointerException
- if the given predicate isnull
.- See Also:
-
nodeCount
protected final int nodeCount() -
indexOfNode
-
clearNodes
protected final void clearNodes() -
getNode
- Throws:
IndexOutOfBoundsException
-
getNodeOrDefault
-
addNode
protected final void addNode(int index, IdealList<E>.Node node) throws NullPointerException, IndexOutOfBoundsException - Parameters:
index
- The index at which to insert theIdealList<E>.Node
node
- TheIdealList<E>.Node
to insert.- Throws:
NullPointerException
IndexOutOfBoundsException
-
removeNode
- Parameters:
index
- TheIdealList<E>.Node
index.- Throws:
IndexOutOfBoundsException
-
forEachNode
- Parameters:
action
- The action to perform.
-
findNode
-
getFirstNode
-
getLastNode
-