public class SizableIterable<T> extends Object implements Iterable<T>
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.Constructor and Description |
---|
SizableIterable(Iterable<T> iterable,
int size)
Wraps the given Iterable with the given size.
|
Modifier and Type | Method and Description |
---|---|
Iterator<T> |
iterator() |
int |
size()
Returns the size of the Iterable
|
static <T> int |
sizeOf(Iterable<T> iterable)
Utility method to determine the number of elements in an Iterable.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public int size()
public static <T> int sizeOf(Iterable<T> iterable)
Copyright © 2013–2015 Apache Software Foundation. All rights reserved.