Package it.unimi.dsi.webgraph.labelling
Class ArcLabelledNodeIterator
- java.lang.Object
-
- it.unimi.dsi.webgraph.NodeIterator
-
- it.unimi.dsi.webgraph.labelling.ArcLabelledNodeIterator
-
- All Implemented Interfaces:
it.unimi.dsi.fastutil.ints.IntIterator
,java.util.Iterator<java.lang.Integer>
,java.util.PrimitiveIterator<java.lang.Integer,java.util.function.IntConsumer>
,java.util.PrimitiveIterator.OfInt
public abstract class ArcLabelledNodeIterator extends NodeIterator
An iterator returning nodes, their successors and labels on the arcs.The purpose of this abstract implementation is to override covariantly the return type of of
NodeIterator.successors()
, so that it has to be aArcLabelledNodeIterator.LabelledArcIterator
, and provide a general implementation of a newlabelArray()
method that returns the labels of the arcs going out of the current node as an array.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ArcLabelledNodeIterator.LabelledArcIterator
An iterator returning successor and the labels of the arcs toward them.
-
Field Summary
-
Fields inherited from class it.unimi.dsi.webgraph.NodeIterator
EMPTY
-
-
Constructor Summary
Constructors Constructor Description ArcLabelledNodeIterator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ArcLabelledNodeIterator
copy(int upperBound)
Creates a copy of this iterator that will never return nodes ≥ the specified bound; the copy must be accessible by a different thread.Label[]
labelArray()
Returns a reference to an array containing the labels of the arcs going out of the current node in the same order as the order in which the corresponding successors are returned bysuccessors()
.abstract ArcLabelledNodeIterator.LabelledArcIterator
successors()
Returns a lazy iterator over the successors of the current node.protected static Label[]
unwrap(ArcLabelledNodeIterator.LabelledArcIterator iterator, int howMany)
Returns a new array of labels filled with exactlyhowMany
labels from the given iterator.-
Methods inherited from class it.unimi.dsi.webgraph.NodeIterator
outdegree, successorArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
successors
public abstract ArcLabelledNodeIterator.LabelledArcIterator successors()
Description copied from class:NodeIterator
Returns a lazy iterator over the successors of the current node. The iteration terminates when -1 is returned.This implementation just wraps the array returned by
NodeIterator.successorArray()
.- Overrides:
successors
in classNodeIterator
- Returns:
- a lazy iterator over the successors of the current node.
-
labelArray
public Label[] labelArray()
Returns a reference to an array containing the labels of the arcs going out of the current node in the same order as the order in which the corresponding successors are returned bysuccessors()
.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 labels of the arcs going out of the current node; the array must not be modified by the caller.
- Implementation Specification:
- This implementation just unwrap the iterator returned by
successors()
and writes in a newly allocated array copies of the labels returned byArcLabelledNodeIterator.LabelledArcIterator.label()
.
-
unwrap
protected static Label[] unwrap(ArcLabelledNodeIterator.LabelledArcIterator iterator, int howMany)
Returns a new array of labels filled with exactlyhowMany
labels from the given iterator. Note that the iterator is required to have at least as many labels as needed.- Parameters:
iterator
- the iterator.howMany
- the number of labels.- Returns:
- the new array where labels are copied.
-
copy
public ArcLabelledNodeIterator copy(int 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).- Overrides:
copy
in classNodeIterator
- 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()
.
-
-