/** * Evaluates the predicate returning the result of the decorated predicate * once the input has been transformed * * @param object the input object which will be transformed * @return true if decorated predicate returns true */ @Override public boolean evaluate(final T object) { final T result = iTransformer.transform(object); return iPredicate.evaluate(result); }
/** * Returns an Enumeration that will enumerate all elements contained * in this iterable. * * @return an Enumeration over the elements of this iterable */ public Enumeration<E> asEnumeration() { return IteratorUtils.asEnumeration(iterator()); }
/** * Returns an array containing all elements of this iterable by traversing * its iterator. * * @param arrayClass the class of array to create * @return an array of the iterable contents * @throws ArrayStoreException if arrayClass is invalid */ public E[] toArray(final Class<E> arrayClass) { return IteratorUtils.toArray(iterator(), arrayClass); }
@Benchmark public long test9_UsingApacheIterableMap() throws IOException { long i = 0; MapIterator<Integer, Integer> it = iterableMap.mapIterator(); while (it.hasNext()) { i += it.next() + it.getValue(); } return i; }
/** * Gets a new list with the contents of the provided iterable. * * @param <E> the element type * @param iterable the iterable to use, may be null * @return a list of the iterator contents */ public static <E> List<E> toList(final Iterable<E> iterable) { return IteratorUtils.toList(emptyIteratorIfNull(iterable)); }
/** * {@inheritDoc} * <p> * Note: uses the index for fast lookup */ @SuppressWarnings("unchecked") @Override public boolean contains(final Object object) { return index.containsKey(keyTransformer.transform((C) object)); }
/** * Returns a new FluentIterable whose iterator will traverse * the elements of this iterable and the other iterables in * alternating order. * * @param others the iterables to interleave, may not be null * @return a new iterable, interleaving this iterable with others * @throws NullPointerException if either of the provided iterables is null */ public FluentIterable<E> zip(final Iterable<? extends E>... others) { return of(IterableUtils.zippingIterable(iterable, others)); }
/** * Returns a new FluentIterable whose iterator will traverse the * elements from this iterable in reverse order. * * @return a new iterable, providing a reversed view of this iterable */ public FluentIterable<E> reverse() { return of(IterableUtils.reversedIterable(iterable)); }
/** * Applies the closure to each element of the provided iterable. * * @param <E> the element type * @param iterable the iterator to use, may be null * @param closure the closure to apply to each element, may not be null * @throws NullPointerException if closure is null */ public static <E> void forEach(final Iterable<E> iterable, final Closure<? super E> closure) { IteratorUtils.forEach(emptyIteratorIfNull(iterable), closure); }
/** * Returns a new FluentIterable whose iterator will loop infinitely * over the elements from this iterable. * * @return a new iterable, providing a looping view of this iterable */ public FluentIterable<E> loop() { return of(IterableUtils.loopingIterable(iterable)); }
/** * Returns a new FluentIterable whose iterator will return a unique view * of this iterable. * * @return a new iterable, providing a unique view of this iterable */ public FluentIterable<E> unique() { return of(IterableUtils.uniqueIterable(iterable)); }
/** * Returns a new FluentIterable whose iterator will return at most * the provided maximum number of elements from this iterable. * * @param maxSize the maximum number of elements * @return a new iterable, providing a bounded view of this iterable * @throws IllegalArgumentException if maxSize is negative */ public FluentIterable<E> limit(final long maxSize) { return of(IterableUtils.boundedIterable(iterable, maxSize)); }
/** * Returns a new FluentIterable whose iterator will first traverse * the elements of the current iterable, followed by the elements * of the provided iterable. * * @param other the other iterable to combine, may not be null * @return a new iterable, combining this iterable with other * @throws NullPointerException if other is null */ public FluentIterable<E> append(final Iterable<? extends E> other) { return of(IterableUtils.chainedIterable(iterable, other)); }
/** * Returns a new FluentIterable whose iterator will only return * elements from this iterable matching the provided predicate. * * @param predicate the predicate used to filter elements * @return a new iterable, providing a filtered view of this iterable * @throws NullPointerException if predicate is null */ public FluentIterable<E> filter(final Predicate<? super E> predicate) { return of(IterableUtils.filteredIterable(iterable, predicate)); }
/** * Returns a new FluentIterable whose iterator will skip the first * N elements from this iterable. * * @param elementsToSkip the number of elements to skip * @return a new iterable, providing a view of this iterable by skipping * the first N elements * @throws IllegalArgumentException if elementsToSkip is negative */ public FluentIterable<E> skip(final long elementsToSkip) { return of(IterableUtils.skippingIterable(iterable, elementsToSkip)); }
/** * Returns a new FluentIterable whose iterator will return all elements * of this iterable transformed by the provided transformer. * * @param <O> the output element type * @param transformer the transformer applied to each element * @return a new iterable, providing a transformed view of this iterable * @throws NullPointerException if transformer is null */ public <O> FluentIterable<O> transform(final Transformer<? super E, ? extends O> transformer) { return of(IterableUtils.transformedIterable(iterable, transformer)); }
/** * Returns a new FluentIterable whose iterator will return an unmodifiable * view of this iterable. * * @return a new iterable, providing an unmodifiable view of this iterable */ public FluentIterable<E> unmodifiable() { return of(IterableUtils.unmodifiableIterable(iterable)); }
/** * Returns a new FluentIterable whose iterator will traverse * the elements of this iterable and the other iterable in * alternating order. * * @param other the other iterable to interleave, may not be null * @return a new iterable, interleaving this iterable with others * @throws NullPointerException if other is null */ public FluentIterable<E> zip(final Iterable<? extends E> other) { return of(IterableUtils.zippingIterable(iterable, other)); }