Package it.unimi.dsi.big.webgraph
Class NodeIterator
- java.lang.Object
-
- it.unimi.dsi.big.webgraph.NodeIterator
-
- All Implemented Interfaces:
it.unimi.dsi.fastutil.longs.LongIterator,java.util.Iterator<java.lang.Long>,java.util.PrimitiveIterator<java.lang.Long,java.util.function.LongConsumer>,java.util.PrimitiveIterator.OfLong
- Direct Known Subclasses:
ArcLabelledNodeIterator
public abstract class NodeIterator extends java.lang.Object implements it.unimi.dsi.fastutil.longs.LongIteratorThis interface extendsLongIteratorand is used to scan a graph, that is, to read its nodes and their successor lists sequentially. TheLongIterator.nextLong()method returns the node that will be scanned. After a call to this method, callingsuccessors()orsuccessorBigArray()will return the list of successors.Implementing subclasses can override either
successors()orsuccessorBigArray(), but at least one of them must be implemented.
-
-
Field Summary
Fields Modifier and Type Field Description static NodeIteratorEMPTYAn empty node iterator.
-
Constructor Summary
Constructors Constructor Description NodeIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description NodeIteratorcopy(long upperBound)Creates a copy of this iterator that will never return nodes ≥ the specified bound; the copy must be accessible by a different thread.abstract longoutdegree()Returns the outdegree of the current node.longskip(long n)Skips the given number of elements.long[][]successorBigArray()Returns a reference to an array containing the successors of the current node.LazyLongIteratorsuccessors()Returns a lazy iterator over the successors of the current node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
EMPTY
public static final NodeIterator EMPTY
An empty node iterator.
-
-
Method Detail
-
outdegree
public abstract long outdegree()
Returns the outdegree of the current node.- Returns:
- the outdegree of the current node.
-
successors
public LazyLongIterator successors()
Returns a lazy iterator over the successors of the current node. The iteration terminates when -1 is returned.- Returns:
- a lazy iterator over the successors of the current node.
- Implementation Specification:
- This implementation just wraps the array returned by
successorBigArray().
-
successorBigArray
public long[][] successorBigArray()
Returns a reference to an array containing the successors of the current node.The returned array may contain more entries than the outdegree of the current node. However, only those with indices from 0 (inclusive) to the outdegree of the current node (exclusive) contain valid data.
- Returns:
- an array whose first elements are the successors of the current node; the array must not be modified by the caller.
- Implementation Specification:
- This implementation just unwrap the iterator returned by
successors().
-
copy
public NodeIterator copy(long upperBound)
Creates a copy of this iterator that will never return nodes ≥ the specified bound; the copy must be accessible by a different thread. Optional operation (it should be implemented by all classes that allow to scan the graph more than once).- Parameters:
upperBound- the upper bound.- Returns:
- a copy of this iterator, with the given upper bound.
- Implementation Specification:
- This implementation just throws an
UnsupportedOperationException. It should be kept in sync with the result ofImmutableGraph.hasCopiableIterators().
-
skip
public long skip(long n)
Skips the given number of elements.The effect of this call is exactly the same as that of calling
LongIterator.nextLong()forntimes (possibly stopping ifIterator.hasNext()becomes false).This method is a big version of
LongIterator.skip(int).- Parameters:
n- the number of elements to skip.- Returns:
- the number of elements actually skipped.
- See Also:
LongIterator.nextLong()
-
-