net.innig.collect
Class InnigCollections

java.lang.Object
  extended by net.innig.collect.InnigCollections

public class InnigCollections
extends java.lang.Object

Innig collection utilities.

Maturity: This is not a mature API, and the implementation is completely experimental. The radix sort works, but is quite slow.
Plans: This class will eventually contain synchronized and immutable support for MultiMap. The radix sort will either improve or disappear.


Field Summary
static MultiMap EMPTY_MULTIMAP
           
 
Constructor Summary
InnigCollections()
           
 
Method Summary
static
<E> void
addAll(java.util.Collection<E> c, java.util.Enumeration<? extends E> e)
           
static
<E> void
addAll(java.util.Collection<E> c, java.util.Iterator<? extends E> i)
           
static
<E> java.util.Iterator<E>
asIterator(java.util.Enumeration<E> e)
           
static
<K,V> MultiMap<K,V>
emptyMultimap()
           
static
<K,V> MultiMap<V,K>
inverse(java.util.Map<K,V> map)
          Returns a multi-map which maps the values of the input to its keys.
static
<K,V> MultiMap<V,K>
inverse(MultiMap<K,V> multiMap)
          Returns a multi-map which maps the values of the input to its keys.
static
<I,O> java.util.Iterator<O>
map(java.util.Iterator<I> iter, Mapper<I,O> mapper)
           
static void radixSort(java.util.List list, Radix radix)
          Applies a linear-time radix sorting algorithm to a list.
static
<E> java.util.Collection<E>
select(java.util.Collection<E> c, Selector<? super E> selector)
           
static
<E> java.util.Iterator<E>
select(java.util.Iterator<E> iter, Selector<? super E> selector)
           
static
<E> java.util.List<E>
select(java.util.List<E> l, Selector<? super E> selector)
           
static
<E> java.util.Set<E>
select(java.util.Set<E> s, Selector<? super E> selector)
           
static
<E> java.util.SortedSet<E>
select(java.util.SortedSet<E> s, Selector<? super E> selector)
           
static
<E> java.util.SortedSet<E>
sort(java.util.Collection<E> objects, java.util.Comparator<? super E> comparator)
           
static
<K,V> MultiMap<K,V>
synchronizedMultiMap(MultiMap<K,V> mm)
           
static
<K,V> MultiMap<K,V>
synchronizedMultiMap(MultiMap<K,V> mm, java.lang.Object sync)
           
static
<E> java.util.List<E>
toList(java.util.Enumeration<E> e)
           
static
<E> java.util.List<E>
toList(java.util.Iterator<E> i)
           
static
<E> java.util.Set<E>
toSet(E... array)
           
static
<E> java.util.Set<E>
uniqueCollectionAsSet(java.util.Collection<E> c)
          Given a collection whose elements are already unique, returns a Set backed by that collection.
static
<K,V> MultiMap<K,V>
unmodifiableMultiMap(MultiMap<K,V> mm)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_MULTIMAP

public static final MultiMap EMPTY_MULTIMAP
Constructor Detail

InnigCollections

public InnigCollections()
Method Detail

emptyMultimap

public static <K,V> MultiMap<K,V> emptyMultimap()

unmodifiableMultiMap

public static <K,V> MultiMap<K,V> unmodifiableMultiMap(MultiMap<K,V> mm)

synchronizedMultiMap

public static <K,V> MultiMap<K,V> synchronizedMultiMap(MultiMap<K,V> mm)

synchronizedMultiMap

public static <K,V> MultiMap<K,V> synchronizedMultiMap(MultiMap<K,V> mm,
                                                       java.lang.Object sync)

uniqueCollectionAsSet

public static <E> java.util.Set<E> uniqueCollectionAsSet(java.util.Collection<E> c)
Given a collection whose elements are already unique, returns a Set backed by that collection. This method is intended for situations where an algorithm produces an inherently unique collection of elements, and using a normal implementation of Set would introduce expensive and redundant uniqueness checks.

Note that if you pass a collection whose elements are not unique, or modify the backing collection after passing it in to add duplicates, you will break the contract of the Set interface. Use this method wisely -- be sure that the collection you're passing in does, in fact, have unique elements.

Note that this method performs a uniqueness check if and only if you are running with assertions enabled.


addAll

public static <E> void addAll(java.util.Collection<E> c,
                              java.util.Iterator<? extends E> i)

addAll

public static <E> void addAll(java.util.Collection<E> c,
                              java.util.Enumeration<? extends E> e)

toList

public static <E> java.util.List<E> toList(java.util.Iterator<E> i)

toList

public static <E> java.util.List<E> toList(java.util.Enumeration<E> e)

toSet

public static <E> java.util.Set<E> toSet(E... array)

asIterator

public static <E> java.util.Iterator<E> asIterator(java.util.Enumeration<E> e)

select

public static <E> java.util.Iterator<E> select(java.util.Iterator<E> iter,
                                               Selector<? super E> selector)

select

public static <E> java.util.Collection<E> select(java.util.Collection<E> c,
                                                 Selector<? super E> selector)

select

public static <E> java.util.List<E> select(java.util.List<E> l,
                                           Selector<? super E> selector)

select

public static <E> java.util.Set<E> select(java.util.Set<E> s,
                                          Selector<? super E> selector)

select

public static <E> java.util.SortedSet<E> select(java.util.SortedSet<E> s,
                                                Selector<? super E> selector)

map

public static <I,O> java.util.Iterator<O> map(java.util.Iterator<I> iter,
                                              Mapper<I,O> mapper)

sort

public static <E> java.util.SortedSet<E> sort(java.util.Collection<E> objects,
                                              java.util.Comparator<? super E> comparator)

radixSort

public static void radixSort(java.util.List list,
                             Radix radix)
Applies a linear-time radix sorting algorithm to a list. This algorithm is extremely efficient for very large lists for which a radix is available. It's not particularly good for small lists, however, which are better served by sort(Collection,Comparator).


inverse

public static <K,V> MultiMap<V,K> inverse(MultiMap<K,V> multiMap)
Returns a multi-map which maps the values of the input to its keys.


inverse

public static <K,V> MultiMap<V,K> inverse(java.util.Map<K,V> map)
Returns a multi-map which maps the values of the input to its keys.