Package it.unimi.dsi.big.webgraph
Class LazyLongIterators
- java.lang.Object
-
- it.unimi.dsi.big.webgraph.LazyLongIterators
-
public class LazyLongIterators extends java.lang.ObjectA class providing static methods and objects that do useful things with lazy integer iterators.
-
-
Field Summary
Fields Modifier and Type Field Description static LazyLongIteratorEMPTY_ITERATORAn empty lazy iterator.
-
Constructor Summary
Constructors Modifier Constructor Description protectedLazyLongIterators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static it.unimi.dsi.fastutil.longs.LongIteratoreager(LazyLongIterator lazyLongIterator)Returns an eagerIntIteratorenumerating the same elements of a given lazy integer iterator.static LazyLongIteratorlazy(it.unimi.dsi.fastutil.longs.LongIterator eagerLongIterator)Returns aLazyLongIteratorenumerating the same elements of a given eager integer iterator.static long[][]unwrap(LazyLongIterator lazyLongIterator)Unwraps the elements returned by a lazy iterator into a new array.static intunwrap(LazyLongIterator lazyLongIterator, long[] array)Unwraps the elements returned by a lazy iterator into an array.static longunwrap(LazyLongIterator lazyLongIterator, long[][] array)Unwraps the elements returned by a lazy iterator into a big array.static longunwrap(LazyLongIterator lazyLongIterator, long[][] array, long offset, long length)Unwraps the elements returned by a lazy iterator into a big array fragment.static intunwrap(LazyLongIterator lazyLongIterator, long[] array, int offset, int length)Unwraps the elements returned by a lazy iterator into an array fragment.static long[][]unwrapLoosely(LazyLongIterator lazyLongIterator)Unwraps the elements returned by a lazy iterator into a new array that can contain additional entries set to zero.static LazyLongIteratorwrap(long[] array)Returns a lazy integer iterator enumerating the elements of an array.static LazyLongIteratorwrap(long[][] array)Returns a lazy integer iterator enumerating the elements of a big array.static LazyLongIteratorwrap(long[][] array, long length)Returns a lazy long iterator enumerating the given number of elements of a big array.static LazyLongIteratorwrap(long[] array, int length)Returns a lazy long iterator enumerating the given number of elements of an array.
-
-
-
Field Detail
-
EMPTY_ITERATOR
public static final LazyLongIterator EMPTY_ITERATOR
An empty lazy iterator.
-
-
Method Detail
-
unwrap
public static int unwrap(LazyLongIterator lazyLongIterator, long[] array)
Unwraps the elements returned by a lazy iterator into an array.- Parameters:
lazyLongIterator- a lazy long iterator.array- an array.- Returns:
- the number of elements unwrapped into
arraystarting from index 0.
-
unwrap
public static int unwrap(LazyLongIterator lazyLongIterator, long[] array, int offset, int length)
Unwraps the elements returned by a lazy iterator into an array fragment.- Parameters:
lazyLongIterator- a lazy long iterator.array- an array.offset- the index of the first element otarrayto be used.length- the maximum number of elements to be unwrapped.- Returns:
- the number of elements unwrapped into
arraystarting from indexoffset.
-
unwrap
public static long unwrap(LazyLongIterator lazyLongIterator, long[][] array)
Unwraps the elements returned by a lazy iterator into a big array.- Parameters:
lazyLongIterator- a lazy long iterator.array- an array.- Returns:
- the number of elements unwrapped into
arraystarting from index 0.
-
unwrap
public static long unwrap(LazyLongIterator lazyLongIterator, long[][] array, long offset, long length)
Unwraps the elements returned by a lazy iterator into a big array fragment.- Parameters:
lazyLongIterator- a lazy long iterator.array- an array.offset- the index of the first element otarrayto be used.length- the maximum number of elements to be unwrapped.- Returns:
- the number of elements unwrapped into
arraystarting from indexoffset.
-
unwrap
public static long[][] unwrap(LazyLongIterator lazyLongIterator)
Unwraps the elements returned by a lazy iterator into a new array.If you need the resulting array to contain the elements returned by
lazyIntIterator, but some more elements set to zero would cause no harm, consider usingunwrapLoosely(LazyLongIterator), which usually avoids a final call toIntArrays.trim(int[], int).- Parameters:
lazyLongIterator- a lazy long iterator.- Returns:
- an array containing the elements returned by
lazyIntIterator. - See Also:
unwrapLoosely(LazyLongIterator)
-
unwrapLoosely
public static long[][] unwrapLoosely(LazyLongIterator lazyLongIterator)
Unwraps the elements returned by a lazy iterator into a new array that can contain additional entries set to zero.If you need the resulting array to contain exactly the elements returned by
lazyIntIterator, consider usingunwrap(LazyLongIterator), but this method avoids a final call toIntArrays.trim(int[], int).- Parameters:
lazyLongIterator- a lazy long iterator.- Returns:
- an array containing the elements returned by
lazyIntIterator; note that in general it might contains some final zeroes beyond the elements returned bylazyIntIterator, so the number of elements actually written intoarraymust be known externally. - See Also:
unwrap(LazyLongIterator)
-
wrap
public static LazyLongIterator wrap(long[] array, int length)
Returns a lazy long iterator enumerating the given number of elements of an array.- Parameters:
array- an array.length- the number of elements to enumerate.- Returns:
- a lazy integer iterator enumerating the first
lengthelements ofarray.
-
wrap
public static LazyLongIterator wrap(long[][] array, long length)
Returns a lazy long iterator enumerating the given number of elements of a big array.- Parameters:
array- an array.length- the number of elements to enumerate.- Returns:
- a lazy integer iterator enumerating the first
lengthelements ofarray.
-
wrap
public static LazyLongIterator wrap(long[] array)
Returns a lazy integer iterator enumerating the elements of an array.- Parameters:
array- an array.- Returns:
- a lazy integer iterator enumerating the elements of
array.
-
wrap
public static LazyLongIterator wrap(long[][] array)
Returns a lazy integer iterator enumerating the elements of a big array.- Parameters:
array- a big array.- Returns:
- a lazy integer iterator enumerating the elements of
array.
-
eager
public static it.unimi.dsi.fastutil.longs.LongIterator eager(LazyLongIterator lazyLongIterator)
Returns an eagerIntIteratorenumerating the same elements of a given lazy integer iterator.- Parameters:
lazyLongIterator- a lazy integer iterator.- Returns:
- an eager
LongIteratorenumerating the same elements oflazyLongIterator.
-
lazy
public static LazyLongIterator lazy(it.unimi.dsi.fastutil.longs.LongIterator eagerLongIterator)
Returns aLazyLongIteratorenumerating the same elements of a given eager integer iterator.- Parameters:
eagerLongIterator- an eager integer iterator.- Returns:
- a lazy integer iterator enumerating the same elements of
eagerIntIterator.
-
-