Class SizableIterable<T>
java.lang.Object
org.apache.tinkerpop.gremlin.algorithm.generator.SizableIterable<T>
- All Implemented Interfaces:
Iterable<T>
Utility class to make size determinations for
Iterable for efficient.
If the number of elements in an Iterable is known, then the Iterable can be wrapped in this class to make
determining the size a constant time operation rather than an iteration over the whole Iterable.
Some generators need to know the number of vertices prior to generation. Using this class can speed up the generator.- Author:
- Matthias Broecheler (me@matthiasb.com)
-
Constructor Summary
ConstructorsConstructorDescriptionSizableIterable(Iterable<T> iterable, int size) Wraps the given Iterable with the given size. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SizableIterable
Wraps the given Iterable with the given size. NOTE: the size MUST be the size of the Iterable. This is not verified.
-
-
Method Details
-
size
public int size()Returns the size of the Iterable- Returns:
- Size of the Iterable
-
iterator
-
sizeOf
Utility method to determine the number of elements in an Iterable. Checks if the given Iterable is an instance of a Collection or SizableIterable before iterating to improve performance.- Returns:
- The size of the given Iterable.
-