Class SizableIterable<T>
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.algorithm.generator.SizableIterable<T>
-
- All Implemented Interfaces:
Iterable<T>
public class SizableIterable<T> extends Object implements Iterable<T>
Utility class to make size determinations forIterable
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
Constructors Constructor Description SizableIterable(Iterable<T> iterable, int size)
Wraps the given Iterable with the given size.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<T>
iterator()
int
size()
Returns the size of the Iterablestatic <T> int
sizeOf(Iterable<T> iterable)
Utility method to determine the number of elements in an Iterable.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
size
public int size()
Returns the size of the Iterable- Returns:
- Size of the Iterable
-
sizeOf
public static <T> int sizeOf(Iterable<T> iterable)
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.
-
-