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
ConstructorsModifierConstructorDescriptionprotected
VectorChain
(VectorStep start) Constructs a chain.VectorChain
(VectorStep start, VectorStep end) Constructs a chain. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index, VectorStep v) Overrides ArrayList method.boolean
add
(VectorChain chain) Adds a VectorChain to this chain.boolean
add
(VectorStep vector) Ads a vector to this chain.boolean
addAll
(int index, Collection<? extends VectorStep> c) Overrides ArrayList method.boolean
addAll
(Collection<? extends VectorStep> c) Overrides ArrayList method.breakAt
(VectorStep vector) /** Attempts to break this chain in two.void
clear()
Overrides ArrayList method.getEnd()
Gets the end of the chain.getStart()
Gets the start of the chain.protected boolean
isAllowed
(VectorStep vector) Determines whether the specified vector is allowed to be added to the end hinge.remove
(int index) Overrides ArrayList method.boolean
Overrides ArrayList method.protected ArrayList<VectorStep>
remove
(VectorStep vector) Removes vectors downstream of and including the specified vector.Removes the end of the chain.void
removeRange
(int from, int to) Overrides ArrayList method.boolean
retainAll
(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, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods 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:
clear
in interfaceCollection<VectorStep>
- Specified by:
clear
in interfaceList<VectorStep>
- Overrides:
clear
in classArrayList<VectorStep>
-
add
Ads a vector to this chain.- Specified by:
add
in interfaceCollection<VectorStep>
- Specified by:
add
in interfaceList<VectorStep>
- Overrides:
add
in 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:
addAll
in interfaceCollection<VectorStep>
- Specified by:
addAll
in interfaceList<VectorStep>
- Overrides:
addAll
in 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:
add
in interfaceList<VectorStep>
- Overrides:
add
in classArrayList<VectorStep>
- Parameters:
index
- the indexv
- the vector to add
-
remove
Overrides ArrayList method.- Specified by:
remove
in interfaceList<VectorStep>
- Overrides:
remove
in classArrayList<VectorStep>
- Parameters:
index
- the index- Returns:
- the object removed
-
remove
Overrides ArrayList method.- Specified by:
remove
in interfaceCollection<VectorStep>
- Specified by:
remove
in interfaceList<VectorStep>
- Overrides:
remove
in classArrayList<VectorStep>
- Parameters:
obj
- the object to remove- Returns:
- false
-
removeRange
public void removeRange(int from, int to) Overrides ArrayList method.- Overrides:
removeRange
in classArrayList<VectorStep>
- Parameters:
from
- indexto
- index
-
retainAll
Overrides ArrayList method.- Specified by:
retainAll
in interfaceCollection<VectorStep>
- Specified by:
retainAll
in interfaceList<VectorStep>
- Overrides:
retainAll
in classArrayList<VectorStep>
- Parameters:
c
- a collection- Returns:
- false
-
addAll
Overrides ArrayList method.- Specified by:
addAll
in interfaceList<VectorStep>
- Overrides:
addAll
in classArrayList<VectorStep>
- Parameters:
index
- the indexc
- the collection to add- Returns:
- true if the collection is successfully added
-
set
Overrides ArrayList method.- Specified by:
set
in interfaceList<VectorStep>
- Overrides:
set
in 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
-