Package com.jgalgo.graph
Interface EdgeIter
-
- All Superinterfaces:
IntIterator
,Iterator<Integer>
,PrimitiveIterator<Integer,IntConsumer>
,PrimitiveIterator.OfInt
public interface EdgeIter extends IntIterator
Iterator used to iterate over edges of a vertex.Each
int
returned byIntIterator.nextInt()
is an ID of an edge iterated by the iterator. The source and target of the last iterated edge are available bysource()
andtarget()
.Graph g = ...; int vertex = ...; for (EdgeIter eit = g.outEdges(vertex).iterator(); eit.hasNext();) { int e = eit.nextInt(); int u = eit.source(); int v = eit.target(); assert vertex == u; System.out.println("Out edge of " + vertex + ": " + e + "(" + u + ", " + v + ")"); }
- Author:
- Barak Ugav
- See Also:
EdgeSet
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.PrimitiveIterator
PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLong
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static EdgeIter
emptyIterator()
Get an empty edge iterator.int
peekNext()
Peek at the next edge of the iterator without advancing it.int
source()
Get the source vertex of the last returned edge.int
target()
Get the target vertex of the last returned edge.-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterator
forEachRemaining, forEachRemaining, next, nextInt, skip
-
Methods inherited from interface java.util.PrimitiveIterator.OfInt
forEachRemaining
-
-
-
-
Method Detail
-
peekNext
int peekNext()
Peek at the next edge of the iterator without advancing it.Similar to
IntIterator.nextInt()
but without advancing the iterator.- Returns:
- the next edge of the iterator
- Throws:
NoSuchElementException
- if there is no 'next' element
-
source
int source()
Get the source vertex of the last returned edge.The behavior is undefined if
IntIterator.nextInt()
was not called yet.- Returns:
- the source vertex of the last returned edge
-
target
int target()
Get the target vertex of the last returned edge.The behavior is undefined if
IntIterator.nextInt()
was not called yet.- Returns:
- the target vertex of the last returned edge
-
emptyIterator
static EdgeIter emptyIterator()
Get an empty edge iterator.- Returns:
- an empty edge iterator
-
-