Package org.goplanit.path
Class SimpleDirectedPathImpl
- java.lang.Object
-
- org.goplanit.path.SimpleDirectedPathImpl
-
- All Implemented Interfaces:
Iterable<EdgeSegment>
,SimpleDirectedPath
public class SimpleDirectedPathImpl extends Object implements SimpleDirectedPath
This object represents a simple directed path based on a number of consecutive LinkSegments- Author:
- markr
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleDirectedPathImpl()
Constructorprotected
SimpleDirectedPathImpl(Deque<? extends EdgeSegment> pathEdgeSegments)
Constructorprotected
SimpleDirectedPathImpl(SimpleDirectedPathImpl other)
Copy constructor (shallow copy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(EdgeSegment... edgeSegments)
Append given edge segments to the simple pathboolean
containsSubPath(Collection<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath.boolean
containsSubPath(Iterator<? extends EdgeSegment> subPathIter)
Verify if the path contains the provided subpath.EdgeSegment
getFirstSegment()
Collect first segment on pathEdgeSegment
getLastSegment()
Collect last segment on pathint
hashCode()
Hash code taken over all edge segmentsIterator<EdgeSegment>
iterator()
void
prepend(EdgeSegment... edgeSegments)
Prepend given edge segments to the simple pathlong
size()
The size of the path is given by the number of edge segments it holds-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.path.SimpleDirectedPath
computeLengthKm, isEmpty
-
-
-
-
Constructor Detail
-
SimpleDirectedPathImpl
protected SimpleDirectedPathImpl()
Constructor
-
SimpleDirectedPathImpl
protected SimpleDirectedPathImpl(SimpleDirectedPathImpl other)
Copy constructor (shallow copy)- Parameters:
other
- to copy
-
SimpleDirectedPathImpl
protected SimpleDirectedPathImpl(Deque<? extends EdgeSegment> pathEdgeSegments)
Constructor- Parameters:
pathEdgeSegments
- the path to set (not copied)
-
-
Method Detail
-
iterator
public Iterator<EdgeSegment> iterator()
- Specified by:
iterator
in interfaceIterable<EdgeSegment>
-
size
public long size()
The size of the path is given by the number of edge segments it holds- Specified by:
size
in interfaceSimpleDirectedPath
- Returns:
- size
-
containsSubPath
public boolean containsSubPath(Collection<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath. It is only a subpath of the subpath is present continguously- Specified by:
containsSubPath
in interfaceSimpleDirectedPath
- Parameters:
subPath
- to verify- Returns:
- true when it contains the subpath, false otherwise.
-
containsSubPath
public boolean containsSubPath(Iterator<? extends EdgeSegment> subPathIter)
Verify if the path contains the provided subpath. It is only a subpath of the subpath is present contiguously- Specified by:
containsSubPath
in interfaceSimpleDirectedPath
- Parameters:
subPathIter
- to verify- Returns:
- true when it contains the subpath, false otherwise.
-
getFirstSegment
public EdgeSegment getFirstSegment()
Collect first segment on path- Specified by:
getFirstSegment
in interfaceSimpleDirectedPath
- Returns:
- initial segment
-
getLastSegment
public EdgeSegment getLastSegment()
Collect last segment on path- Specified by:
getLastSegment
in interfaceSimpleDirectedPath
- Returns:
- last segment
-
append
public void append(EdgeSegment... edgeSegments)
Append given edge segments to the simple path- Parameters:
edgeSegments
- to add
-
prepend
public void prepend(EdgeSegment... edgeSegments)
Prepend given edge segments to the simple path- Parameters:
edgeSegments
- to add
-
hashCode
public int hashCode()
Hash code taken over all edge segments- Specified by:
hashCode
in interfaceSimpleDirectedPath
- Overrides:
hashCode
in classObject
- Returns:
- hashcode
-
-