ru.yandex.bolts.collection
Interface CollectionF<E>

All Superinterfaces:
Collection<E>, Iterable<E>, IterableF<E>
All Known Subinterfaces:
ListF<E>, SetF<E>
All Known Implementing Classes:
AbstractCollectionF, AbstractListF, AbstractSetF, ArrayListBase, ArrayListF, DefaultCollectionF, DefaultListF, DefaultSetF, EmptyList, EmptySet, ListMap, ListOf2, Option, Option.None, Option.Some, ReadOnlyArrayList, SetFromMap, SingletonList, SingletonSet, UnmodifiableDefaultCollectionF, UnmodifiableDefaultListF, UnmodifiableDefaultSetF

public interface CollectionF<E>
extends Collection<E>, IterableF<E>

Extended collection. Methods like filter(Function1B), sort() or plus(Collection) are permitted to return this collection if result of operation is a collection equal to this, even if this collection is mutable.

Author:
Stepan Koltsov

Method Summary
 void addAll(E... additions)
          Varargs version of addAll
 Function1V<E> addF()
          Delegate to Collection.add(Object)
 Function1V<E> addOp()
          Deprecated.  
 Function1B<E> containsF()
          Delegate to Collection.contains(Object)
 Function1B<E> containsP()
          Deprecated.  
 CollectionF<E> filter(Function1B<? super E> p)
          Return collection with only elements that match predicate.
 Tuple2<? extends IterableF<E>,? extends IterableF<E>> filter2(Function1B<? super E> p)
          Pair of collection, first contains elements matching p, second contains element matching !p
<B> ListF<B>
flatMap(Function<? super E,? extends Collection<B>> f)
          Flat map
<B> ListF<B>
flatMapO(Function<? super E,Option<B>> f)
          Flat map variant that accept mapper that returns Option instead of Collection
<V> MapF<V,ListF<E>>
groupBy(Function<? super E,? extends V> m)
          Group elements by applying given function to each element.
 IteratorF<E> iterator()
          Elements as iterator
<B> ListF<B>
map(Function<? super E,B> mapper)
          Map
 E max()
          Max element using Comparator.naturalComparator().
 E max(Function2I<? super E,? super E> comparator)
          Max element using given comparator.
 E min()
          Min element using Comparator.naturalComparator().
 E min(Function2I<? super E,? super E> comparator)
          Min element using given comparator.
 CollectionF<E> plus(Collection<? extends E> elements)
          Collection with all elements of this collection and that collection.
 CollectionF<E> plus(E... additions)
          Varargs variant of plus(Collection).
 CollectionF<E> plus(Iterator<? extends E> iterator)
          Collection with all elements of this collection and that collection.
 CollectionF<E> plus1(E e)
          This collection plus one element.
 E single()
          Single element of collection
 Option<E> singleO()
           
 ListF<E> sort()
          Elements sorted by Comparator.naturalComparator()
 ListF<E> sort(Function2I<? super E,? super E> comparator)
          Elements sorted by given comparator
 ListF<E> sortBy(Function<? super E,?> f)
           
 ListF<E> sortByDesc(Function<? super E,?> f)
           
 E[] toArray(Class<E> cl)
          Copy elements to the new array
 boolean[] toBooleanArray()
           
 byte[] toByteArray()
          Copy all elements of this collection to newly allocated byte array.
 char[] toCharArray()
           
 double[] toDoubleArray()
           
 float[] toFloatArray()
           
 int[] toIntArray()
           
 ListF<E> toList()
          Convert this to list
 long[] toLongArray()
           
<K,V> MapF<K,V>
toMap(Function<? super E,Tuple2<K,V>> t)
          Map to list of map entries and construct map
<K> MapF<K,E>
toMapMappingToKey(Function<? super E,K> m)
          Map to list of map keys and construct map.
<V> MapF<E,V>
toMapMappingToValue(Function<? super E,V> m)
          Map to list of map values and construct map.
 short[] toShortArray()
           
<F> CollectionF<F>
uncheckedCast()
          Return this with another type parameter and no type checks.
 SetF<E> unique()
          Return set of elements of this
 CollectionF<E> unmodifiable()
          Return unmodifiable view or unmodifiable copy of this.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface ru.yandex.bolts.collection.IterableF
exists, find, foldLeft, foldRight, forAll, forEach, mkString, mkString, reduceLeft, reduceRight
 

Method Detail

iterator

IteratorF<E> iterator()
Description copied from interface: IterableF
Elements as iterator

Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface IterableF<E>

filter

CollectionF<E> filter(Function1B<? super E> p)
Return collection with only elements that match predicate.


filter2

Tuple2<? extends IterableF<E>,? extends IterableF<E>> filter2(Function1B<? super E> p)
Pair of collection, first contains elements matching p, second contains element matching !p


map

<B> ListF<B> map(Function<? super E,B> mapper)
Map


flatMap

<B> ListF<B> flatMap(Function<? super E,? extends Collection<B>> f)
Flat map


flatMapO

<B> ListF<B> flatMapO(Function<? super E,Option<B>> f)
Flat map variant that accept mapper that returns Option instead of Collection


toMap

<K,V> MapF<K,V> toMap(Function<? super E,Tuple2<K,V>> t)
Map to list of map entries and construct map


toMapMappingToKey

<K> MapF<K,E> toMapMappingToKey(Function<? super E,K> m)
Map to list of map keys and construct map. Elements of this collection are used as values


toMapMappingToValue

<V> MapF<E,V> toMapMappingToValue(Function<? super E,V> m)
Map to list of map values and construct map. Elements of this collection are used as keys


containsP

Function1B<E> containsP()
Deprecated. 


containsF

Function1B<E> containsF()
Delegate to Collection.contains(Object)


toList

ListF<E> toList()
Convert this to list


unique

SetF<E> unique()
Return set of elements of this


sort

ListF<E> sort()
Elements sorted by Comparator.naturalComparator()


sort

ListF<E> sort(Function2I<? super E,? super E> comparator)
Elements sorted by given comparator


sortBy

ListF<E> sortBy(Function<? super E,?> f)

sortByDesc

ListF<E> sortByDesc(Function<? super E,?> f)

groupBy

<V> MapF<V,ListF<E>> groupBy(Function<? super E,? extends V> m)
Group elements by applying given function to each element.


addOp

Function1V<E> addOp()
Deprecated. 


addF

Function1V<E> addF()
Delegate to Collection.add(Object)


plus1

CollectionF<E> plus1(E e)
This collection plus one element.


plus

CollectionF<E> plus(Collection<? extends E> elements)
Collection with all elements of this collection and that collection.


plus

CollectionF<E> plus(Iterator<? extends E> iterator)
Collection with all elements of this collection and that collection.


plus

CollectionF<E> plus(E... additions)
Varargs variant of plus(Collection).


addAll

void addAll(E... additions)
Varargs version of addAll

See Also:
Collection.addAll(Collection)

toArray

E[] toArray(Class<E> cl)
Copy elements to the new array


toByteArray

byte[] toByteArray()
Copy all elements of this collection to newly allocated byte array. Fail if any element of this collection is null or not Byte.


toShortArray

short[] toShortArray()
See Also:
toByteArray()

toIntArray

int[] toIntArray()
See Also:
toByteArray()

toLongArray

long[] toLongArray()
See Also:
toByteArray()

toBooleanArray

boolean[] toBooleanArray()
See Also:
toByteArray()

toCharArray

char[] toCharArray()
See Also:
toByteArray()

toFloatArray

float[] toFloatArray()
See Also:
toByteArray()

toDoubleArray

double[] toDoubleArray()
See Also:
toByteArray()

unmodifiable

CollectionF<E> unmodifiable()
Return unmodifiable view or unmodifiable copy of this.

See Also:
Collections.unmodifiableCollection(Collection)

single

E single()
         throws NoSuchElementException
Single element of collection

Throws:
NoSuchElementException - if this collection is empty or has more then one element.

singleO

Option<E> singleO()
                  throws NoSuchElementException
Throws:
NoSuchElementException - is collection has more then one element.

uncheckedCast

<F> CollectionF<F> uncheckedCast()
Return this with another type parameter and no type checks.

Specified by:
uncheckedCast in interface IterableF<E>

min

E min()
Min element using Comparator.naturalComparator().


min

E min(Function2I<? super E,? super E> comparator)
Min element using given comparator.


max

E max()
Max element using Comparator.naturalComparator().


max

E max(Function2I<? super E,? super E> comparator)
Max element using given comparator.