Package com.valhalla.sdk.api.pathing
Class AbstractPath<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.valhalla.sdk.api.pathing.AbstractPath<E>
- Type Parameters:
E- path-node type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>
- Direct Known Subclasses:
LocalPath
Mutable ordered path with reversible traversal direction.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates an empty forward path.protectedAbstractPath(Collection<? extends E> values) Creates a forward path from an optional collection. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinal booleanAppends non-null nodes in argument order.voidaddToFront(E value) Inserts a node at the front.Returns the traversal direction.first()Returns the first node.get(int index) last()Returns the final node.abstract Enext()Returns the next node suitable for the current player location.path()Copies this path into an immutable list.remove(int index) voidreverse()Reverses node order and toggles the traversal direction label.voidsetDirection(PathDirection value) Sets the traversal direction without reordering nodes.intsize()abstract booleanwalk()Advances toward the next suitable path node.Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Constructor Details
-
AbstractPath
protected AbstractPath()Creates an empty forward path. -
AbstractPath
Creates a forward path from an optional collection.- Parameters:
values- initial nodes;nullcreates an empty path
-
-
Method Details
-
get
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>
-
set
-
add
-
remove
-
addAll
Appends non-null nodes in argument order.- Parameters:
values- nodes to append;nullleaves the path unchanged- Returns:
truewhen at least one node was appended
-
addToFront
Inserts a node at the front.- Parameters:
value- non-null node inserted at index zero
-
first
Returns the first node.- Returns:
- first node, or
nullwhen empty
-
last
Returns the final node.- Returns:
- final node, or
nullwhen empty
-
path
Copies this path into an immutable list.- Returns:
- immutable snapshot of the ordered nodes
-
direction
Returns the traversal direction.- Returns:
- current traversal direction
-
setDirection
Sets the traversal direction without reordering nodes.- Parameters:
value- non-null traversal direction
-
reverse
public void reverse()Reverses node order and toggles the traversal direction label. -
next
Returns the next node suitable for the current player location.- Returns:
- next node, or
nullwhen no candidate exists
-
walk
public abstract boolean walk()Advances toward the next suitable path node.- Returns:
truewhen progress is already healthy or a walk action was accepted
-