ru.yandex.bolts.collection
Class CollectionsF

java.lang.Object
  extended by ru.yandex.bolts.collection.CollectionsF
Direct Known Subclasses:
Cf

public class CollectionsF
extends Object

Utilities to create extended collections.

Author:
Stepan Koltsov

Constructor Summary
protected CollectionsF()
           
 
Method Summary
static
<E> ListF<E>
arrayList()
          Create extended mutable array list.
static
<A> ListF<A>
arrayList(A... elements)
          Create extended array list of elements.
static
<A> ListF<A>
arrayList(Collection<A> collection)
          Create extended mutable array list containing given elements.
static
<A> ListF<A>
arrayList(int initialCapacity)
          Create array list with given capacity.
static
<K,V> MapF<K,V>
concurrentHashMap()
          Wrapper around ConcurrentHashMap.
static
<E> IteratorF<E>
emptyIterator()
          Empty iterator.
static
<K,V> MapF<K,V>
hashMap()
          Create hash map.
static
<K,V> MapF<K,V>
hashMap(Iterable<Tuple2<K,V>> entries)
          Create hash map of specified entries.
static
<A> SetF<A>
hashSet()
          Create mutable hash set.
static
<E> SetF<E>
hashSet(Collection<E> collection)
          Create mutable hash set of specified elements.
static
<E> SetF<E>
hashSet(E... elements)
          Create mutable hash set of specified elements.
static
<T> Function1B<Iterator<T>>
hasNextF()
          Iterator.hasNext() as function
static
<K,V> MapF<K,V>
identityHashMap()
          Identity hash map.
static
<E> SetF<E>
identityHashSet()
          Create mutable identity hash set.
static
<E> SetF<E>
identityHashSet(Collection<E> elements)
          Create mutable identity hash set with specified elements.
static
<E> SetF<E>
identityHashSet(E... elements)
          Create mutable identity hash set with specified elements.
static
<T> Function<Iterable<T>,IteratorF<T>>
iteratorF()
          Iterable.iterator() as function
static
<E> ListF<E>
linkedList()
          Create extended linked list.
static
<E> ListF<E>
list()
          Empty immutable list.
static
<E> ListF<E>
list(Collection<E> elements)
          Create list of elements from given collection.
static
<E> ListF<E>
list(E... elements)
          Create list of specified elements.
static
<E> ListF<E>
list(E e)
          Immutable singleton list.
static
<E> ListF<E>
list(E e1, E e2)
          Immutable list with two elements.
static
<A> Function2<ListF<A>,ListF<A>,ListF<A>>
listPlusF()
          Concatenate two lists function
static
<K,V> MapF<K,V>
map()
          Immutable empty map.
static
<K,V> MapF<K,V>
map(Collection<Tuple2<K,V>> pairs)
          Create map from sequence of entries
static
<K,V> MapF<K,V>
map(K key, V value)
          Singleton map.
static
<K,V> MapF<K,V>
map(K key1, V value1, K key2, V value2)
          Map of either 1 or 2 entries.
static
<A,B> Function2<MapF<A,B>,MapF<A,B>,MapF<A,B>>
mapPlusF()
          MapF.plus(MapF) as function.
static ListF<Integer> range(int startInclusive, int endExclusive)
          Immutable list of integer in given range.
static
<T> ListF<T>
repeat(T element, int times)
          Immutable list of element repeated times times.
static
<E> SetF<E>
set()
          Empty set
static
<E> SetF<E>
set(Collection<E> elements)
          Create set of elements from collection.
static
<E> SetF<E>
set(E... elements)
          Create set of specified elements
static
<E> SetF<E>
set(E e1, E e2)
          Create set of specified elements.
static
<E> SetF<E>
set(E e1, E e2, E e3)
          Create set of specified elements.
static
<T> SetF<T>
set(T o)
          Create singleton set
static
<A> Function2<SetF<A>,SetF<A>,SetF<A>>
setPlusF()
          Union of two sets function
static
<T> Function<Collection<T>,Integer>
sizeF()
          Collection.size() as function
static
<T> Function<Collection<T>,Integer>
sizeM()
          Deprecated.  
static
<A> SetF<A>
treeSet()
          Create extended tree set.
static
<E> SetF<E>
treeSet(Collection<E> collection)
          Create tree set of specified elements.
static
<E> SetF<E>
treeSet(E... elements)
          Create tree set of specified elements.
static
<E> CollectionF<E>
wrap(Collection<E> coll)
          Wrap Collection.
static
<E> ListF<E>
wrap(E[] array)
          Wrap array.
static
<E> IteratorF<E>
wrap(Iterator<E> iter)
          Wrap Iterator.
static
<E> ListF<E>
wrap(List<E> list)
          Wrap List.
static
<K,V> MapF<K,V>
wrap(Map<K,V> map)
          Wrap Map.
static MapF<String,String> wrap(Properties ps)
          Wrap Properties.
static
<E> SetF<E>
wrap(Set<E> set)
          Wrap Set.
static
<E> Function<Iterator<E>,IteratorF<E>>
wrapIteratorF()
          x(Iterator) as function
static
<E> Function<Iterator<E>,IteratorF<E>>
wrapIteratorM()
          Deprecated.  
static
<E> Function<List<E>,ListF<E>>
wrapListF()
          x(List) as function
static
<E> Function<List<E>,ListF<E>>
wrapListM()
          Deprecated.  
static
<K,V> Function<Map<K,V>,MapF<K,V>>
wrapMapF()
          x(Map) as function
static
<K,V> Function<Map<K,V>,MapF<K,V>>
wrapMapM()
          Deprecated.  
static
<E> Function<Set<E>,SetF<E>>
wrapSetF()
          x(Set) as function
static
<E> Function<Set<E>,SetF<E>>
wrapSetM()
          Deprecated.  
static
<E> CollectionF<E>
x(Collection<E> collection)
          Wrap collection
static
<E> ListF<E>
x(E[] array)
          Wrap array.
static
<E> IteratorF<E>
x(Iterator<E> iterator)
          Wrap iterator
static
<E> ListF<E>
x(List<E> list)
          Wrap list
static
<K,V> MapF<K,V>
x(Map<K,V> map)
          Wrap map
static MapF<String,String> x(Properties properties)
          Wrap properties as set of String, String pairs
static
<E> SetF<E>
x(Set<E> set)
          Wrap set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionsF

protected CollectionsF()
Method Detail

wrap

public static <E> ListF<E> wrap(List<E> list)
Wrap List.

See Also:
x(List)

wrap

public static <E> SetF<E> wrap(Set<E> set)
Wrap Set.

See Also:
x(Set)

wrap

public static <E> CollectionF<E> wrap(Collection<E> coll)
Wrap Collection.

See Also:
x(Collection)

wrap

public static <E> IteratorF<E> wrap(Iterator<E> iter)
Wrap Iterator.

See Also:
x(Iterator)

wrap

public static <K,V> MapF<K,V> wrap(Map<K,V> map)
Wrap Map.

See Also:
x(Map)

wrap

public static MapF<String,String> wrap(Properties ps)
Wrap Properties.

See Also:
x(Properties)

wrap

public static <E> ListF<E> wrap(E[] array)
Wrap array.

See Also:
x(Object[])

x

public static <E> IteratorF<E> x(Iterator<E> iterator)
Wrap iterator


x

public static <E> CollectionF<E> x(Collection<E> collection)
Wrap collection


x

public static <E> ListF<E> x(List<E> list)
Wrap list


x

public static <E> SetF<E> x(Set<E> set)
Wrap set


x

public static <K,V> MapF<K,V> x(Map<K,V> map)
Wrap map


x

public static MapF<String,String> x(Properties properties)
Wrap properties as set of String, String pairs


x

public static <E> ListF<E> x(E[] array)
Wrap array.

See Also:
Arrays.asList(Object...), list(Object...)

set

public static <E> SetF<E> set()
Empty set


set

public static <T> SetF<T> set(T o)
Create singleton set


set

public static <E> SetF<E> set(E e1,
                              E e2)
Create set of specified elements.

Returns:
set of either 1 or 2 elements

set

public static <E> SetF<E> set(E e1,
                              E e2,
                              E e3)
Create set of specified elements.

Returns:
set of either 1, 2 or 3 elements

set

public static <E> SetF<E> set(E... elements)
Create set of specified elements


set

public static <E> SetF<E> set(Collection<E> elements)
Create set of elements from collection.


hashSet

public static <A> SetF<A> hashSet()
Create mutable hash set.


hashSet

public static <E> SetF<E> hashSet(Collection<E> collection)
Create mutable hash set of specified elements.


hashSet

public static <E> SetF<E> hashSet(E... elements)
Create mutable hash set of specified elements.


identityHashSet

public static <E> SetF<E> identityHashSet()
Create mutable identity hash set.


identityHashSet

public static <E> SetF<E> identityHashSet(Collection<E> elements)
Create mutable identity hash set with specified elements.


identityHashSet

public static <E> SetF<E> identityHashSet(E... elements)
Create mutable identity hash set with specified elements.


treeSet

public static <A> SetF<A> treeSet()
Create extended tree set.


treeSet

public static <E> SetF<E> treeSet(Collection<E> collection)
Create tree set of specified elements.


treeSet

public static <E> SetF<E> treeSet(E... elements)
Create tree set of specified elements.


list

public static <E> ListF<E> list()
Empty immutable list.


list

public static <E> ListF<E> list(E e)
Immutable singleton list.


list

public static <E> ListF<E> list(E e1,
                                E e2)
Immutable list with two elements.


list

public static <E> ListF<E> list(E... elements)
Create list of specified elements. The resulting list is immutable.

See Also:
for real array wrapping

list

public static <E> ListF<E> list(Collection<E> elements)
Create list of elements from given collection.


arrayList

public static <E> ListF<E> arrayList()
Create extended mutable array list.


arrayList

public static <A> ListF<A> arrayList(Collection<A> collection)
Create extended mutable array list containing given elements.


arrayList

public static <A> ListF<A> arrayList(A... elements)
Create extended array list of elements.


arrayList

public static <A> ListF<A> arrayList(int initialCapacity)
Create array list with given capacity.

See Also:
ArrayList.ArrayList(int)

map

public static <K,V> MapF<K,V> map(K key,
                                  V value)
Singleton map.


map

public static <K,V> MapF<K,V> map(K key1,
                                  V value1,
                                  K key2,
                                  V value2)
Map of either 1 or 2 entries.


map

public static <K,V> MapF<K,V> map(Collection<Tuple2<K,V>> pairs)
Create map from sequence of entries


map

public static <K,V> MapF<K,V> map()
Immutable empty map.


linkedList

public static <E> ListF<E> linkedList()
Create extended linked list.


hashMap

public static <K,V> MapF<K,V> hashMap()
Create hash map.

See Also:
HashMap

identityHashMap

public static <K,V> MapF<K,V> identityHashMap()
Identity hash map.

See Also:
IdentityHashMap

hashMap

public static <K,V> MapF<K,V> hashMap(Iterable<Tuple2<K,V>> entries)
Create hash map of specified entries.

See Also:
HashMap

concurrentHashMap

public static <K,V> MapF<K,V> concurrentHashMap()
Wrapper around ConcurrentHashMap.


emptyIterator

public static <E> IteratorF<E> emptyIterator()
Empty iterator.


repeat

public static <T> ListF<T> repeat(T element,
                                  int times)
Immutable list of element repeated times times.


range

public static ListF<Integer> range(int startInclusive,
                                   int endExclusive)
Immutable list of integer in given range.

Returns:
empty list if end < start

mapPlusF

public static <A,B> Function2<MapF<A,B>,MapF<A,B>,MapF<A,B>> mapPlusF()
MapF.plus(MapF) as function.


listPlusF

public static <A> Function2<ListF<A>,ListF<A>,ListF<A>> listPlusF()
Concatenate two lists function


setPlusF

public static <A> Function2<SetF<A>,SetF<A>,SetF<A>> setPlusF()
Union of two sets function


wrapListM

public static <E> Function<List<E>,ListF<E>> wrapListM()
Deprecated. 


wrapListF

public static <E> Function<List<E>,ListF<E>> wrapListF()
x(List) as function


wrapSetM

public static <E> Function<Set<E>,SetF<E>> wrapSetM()
Deprecated. 


wrapSetF

public static <E> Function<Set<E>,SetF<E>> wrapSetF()
x(Set) as function


wrapMapM

public static <K,V> Function<Map<K,V>,MapF<K,V>> wrapMapM()
Deprecated. 


wrapMapF

public static <K,V> Function<Map<K,V>,MapF<K,V>> wrapMapF()
x(Map) as function


wrapIteratorM

public static <E> Function<Iterator<E>,IteratorF<E>> wrapIteratorM()
Deprecated. 


wrapIteratorF

public static <E> Function<Iterator<E>,IteratorF<E>> wrapIteratorF()
x(Iterator) as function


sizeM

public static <T> Function<Collection<T>,Integer> sizeM()
Deprecated. 


sizeF

public static <T> Function<Collection<T>,Integer> sizeF()
Collection.size() as function


hasNextF

public static <T> Function1B<Iterator<T>> hasNextF()
Iterator.hasNext() as function


iteratorF

public static <T> Function<Iterable<T>,IteratorF<T>> iteratorF()
Iterable.iterator() as function