Class VectorChain
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<VectorStep>,Collection<VectorStep>,List<VectorStep>,RandomAccess
This is an ArrayList that represents a chain of vectors linked tip-to-tail.
- Author:
- Douglas Brown
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVectorChain(VectorStep start) Constructs a chain.VectorChain(VectorStep start, VectorStep end) Constructs a chain. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, VectorStep v) Overrides ArrayList method.booleanadd(VectorChain chain) Adds a VectorChain to this chain.booleanadd(VectorStep vector) Ads a vector to this chain.booleanaddAll(int index, Collection<? extends VectorStep> c) Overrides ArrayList method.booleanaddAll(Collection<? extends VectorStep> c) Overrides ArrayList method.breakAt(VectorStep vector) /** Attempts to break this chain in two.voidclear()Overrides ArrayList method.getEnd()Gets the end of the chain.getStart()Gets the start of the chain.protected booleanisAllowed(VectorStep vector) Determines whether the specified vector is allowed to be added to the end hinge.remove(int index) Overrides ArrayList method.booleanOverrides ArrayList method.protected ArrayList<VectorStep>remove(VectorStep vector) Removes vectors downstream of and including the specified vector.Removes the end of the chain.voidremoveRange(int from, int to) Overrides ArrayList method.booleanretainAll(Collection<?> c) Overrides ArrayList method.set(int index, VectorStep obj) Overrides ArrayList method.Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, removeIf, replaceAll, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
VectorChain
Constructs a chain.- Parameters:
start- the start vector
-
VectorChain
Constructs a chain.- Parameters:
start- the start vectorend- the end vector
-
-
Method Details
-
getEnd
Gets the end of the chain.- Returns:
- the end vector
-
getStart
Gets the start of the chain.- Returns:
- the start vector
-
removeEnd
Removes the end of the chain.- Returns:
- the removed end
-
breakAt
/** Attempts to break this chain in two. If successful, the specified vector becomes the tail vector of a new chain.- Parameters:
vector- the vector- Returns:
- the new chain, if any
-
clear
public void clear()Overrides ArrayList method.- Specified by:
clearin interfaceCollection<VectorStep>- Specified by:
clearin interfaceList<VectorStep>- Overrides:
clearin classArrayList<VectorStep>
-
add
Ads a vector to this chain.- Specified by:
addin interfaceCollection<VectorStep>- Specified by:
addin interfaceList<VectorStep>- Overrides:
addin classArrayList<VectorStep>- Parameters:
vector- the vector to add- Returns:
- true if the vector is successfully added
-
add
Adds a VectorChain to this chain.- Parameters:
chain- the chain to add- Returns:
- true if successfully added
-
addAll
Overrides ArrayList method.- Specified by:
addAllin interfaceCollection<VectorStep>- Specified by:
addAllin interfaceList<VectorStep>- Overrides:
addAllin classArrayList<VectorStep>- Parameters:
c- the collection to add- Returns:
- true if at least one item in the collection is successfully added
-
add
Overrides ArrayList method.- Specified by:
addin interfaceList<VectorStep>- Overrides:
addin classArrayList<VectorStep>- Parameters:
index- the indexv- the vector to add
-
remove
Overrides ArrayList method.- Specified by:
removein interfaceList<VectorStep>- Overrides:
removein classArrayList<VectorStep>- Parameters:
index- the index- Returns:
- the object removed
-
remove
Overrides ArrayList method.- Specified by:
removein interfaceCollection<VectorStep>- Specified by:
removein interfaceList<VectorStep>- Overrides:
removein classArrayList<VectorStep>- Parameters:
obj- the object to remove- Returns:
- false
-
removeRange
public void removeRange(int from, int to) Overrides ArrayList method.- Overrides:
removeRangein classArrayList<VectorStep>- Parameters:
from- indexto- index
-
retainAll
Overrides ArrayList method.- Specified by:
retainAllin interfaceCollection<VectorStep>- Specified by:
retainAllin interfaceList<VectorStep>- Overrides:
retainAllin classArrayList<VectorStep>- Parameters:
c- a collection- Returns:
- false
-
addAll
Overrides ArrayList method.- Specified by:
addAllin interfaceList<VectorStep>- Overrides:
addAllin classArrayList<VectorStep>- Parameters:
index- the indexc- the collection to add- Returns:
- true if the collection is successfully added
-
set
Overrides ArrayList method.- Specified by:
setin interfaceList<VectorStep>- Overrides:
setin classArrayList<VectorStep>- Parameters:
index- the indexobj- the object- Returns:
- the element previously at index
-
isAllowed
Determines whether the specified vector is allowed to be added to the end hinge.- Parameters:
vector- the vector- Returns:
- true if allowed
-
remove
Removes vectors downstream of and including the specified vector.- Parameters:
vector- the vector- Returns:
- the list of vectors removed
-