edu.stanford.nlp.util
Class Generics

java.lang.Object
  extended by edu.stanford.nlp.util.Generics

public class Generics
extends java.lang.Object

A collection of utilities to make dealing with Java generics less painful and verbose. For example, rather than declaring

 Map<String, List<Pair<IndexedWord, GrammaticalRelation>>> = new HashMap<String, List<Pair<IndexedWord, GrammaticalRelation>>>()
 
you just call Generics.newHashMap():
 Map<String, List<Pair<IndexedWord, GrammaticalRelation>>> = Generics.newHashMap()
 
Java type-inference will almost always just do the right thing (every once in a while, the compiler will get confused before you do, so you might still occasionally have to specify the appropriate types). This class is based on the examples in Brian Goetz's article Java theory and practice: The pseudo-typedef antipattern.

Author:
Ilya Sherman

Field Summary
static java.lang.String HASH_MAP_CLASSNAME
           
static java.lang.String HASH_MAP_PROPERTY
           
static java.lang.String HASH_SET_CLASSNAME
           
static java.lang.String HASH_SET_PROPERTY
           
 
Method Summary
static
<E> java.util.ArrayList<E>
newArrayList()
           
static
<E> java.util.ArrayList<E>
newArrayList(java.util.Collection<? extends E> c)
           
static
<E> java.util.ArrayList<E>
newArrayList(int size)
           
static
<E> BinaryHeapPriorityQueue<E>
newBinaryHeapPriorityQueue()
           
static
<K,V> java.util.concurrent.ConcurrentHashMap<K,V>
newConcurrentHashMap()
           
static
<K,V> java.util.concurrent.ConcurrentHashMap<K,V>
newConcurrentHashMap(int initialCapacity)
           
static
<K,V> java.util.concurrent.ConcurrentHashMap<K,V>
newConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
           
static
<K,V> java.util.Map<K,V>
newHashMap()
           
static
<K,V> java.util.Map<K,V>
newHashMap(int initialCapacity)
           
static
<K,V> java.util.Map<K,V>
newHashMap(java.util.Map<? extends K,? extends V> m)
           
static
<E> java.util.Set<E>
newHashSet()
           
static
<E> java.util.Set<E>
newHashSet(java.util.Collection<? extends E> c)
           
static
<E> java.util.Set<E>
newHashSet(int initialCapacity)
           
static
<K,V> java.util.IdentityHashMap<K,V>
newIdentityHashMap()
           
static
<E> Index<E>
newIndex()
           
static
<T> Interner<T>
newInterner()
           
static
<E> java.util.LinkedList<E>
newLinkedList()
           
static
<E> java.util.LinkedList<E>
newLinkedList(java.util.Collection<? extends E> c)
           
static
<T1,T2> Pair<T1,T2>
newPair(T1 first, T2 second)
           
static
<E> java.util.Stack<E>
newStack()
           
static
<T> SynchronizedInterner<T>
newSynchronizedInterner(Interner<T> interner)
           
static
<T> SynchronizedInterner<T>
newSynchronizedInterner(Interner<T> interner, java.lang.Object mutex)
           
static
<K,V> java.util.TreeMap<K,V>
newTreeMap()
           
static
<E> java.util.TreeSet<E>
newTreeSet()
           
static
<E> java.util.TreeSet<E>
newTreeSet(java.util.Comparator<? super E> comparator)
           
static
<E> java.util.TreeSet<E>
newTreeSet(java.util.SortedSet<E> s)
           
static
<T1,T2,T3> Triple<T1,T2,T3>
newTriple(T1 first, T2 second, T3 third)
           
static
<K,V> java.util.WeakHashMap<K,V>
newWeakHashMap()
           
static
<T> java.lang.ref.WeakReference<T>
newWeakReference(T referent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HASH_SET_PROPERTY

public static final java.lang.String HASH_SET_PROPERTY
See Also:
Constant Field Values

HASH_SET_CLASSNAME

public static final java.lang.String HASH_SET_CLASSNAME

HASH_MAP_PROPERTY

public static final java.lang.String HASH_MAP_PROPERTY
See Also:
Constant Field Values

HASH_MAP_CLASSNAME

public static final java.lang.String HASH_MAP_CLASSNAME
Method Detail

newArrayList

public static <E> java.util.ArrayList<E> newArrayList()

newArrayList

public static <E> java.util.ArrayList<E> newArrayList(int size)

newArrayList

public static <E> java.util.ArrayList<E> newArrayList(java.util.Collection<? extends E> c)

newLinkedList

public static <E> java.util.LinkedList<E> newLinkedList()

newLinkedList

public static <E> java.util.LinkedList<E> newLinkedList(java.util.Collection<? extends E> c)

newStack

public static <E> java.util.Stack<E> newStack()

newBinaryHeapPriorityQueue

public static <E> BinaryHeapPriorityQueue<E> newBinaryHeapPriorityQueue()

newTreeSet

public static <E> java.util.TreeSet<E> newTreeSet()

newTreeSet

public static <E> java.util.TreeSet<E> newTreeSet(java.util.Comparator<? super E> comparator)

newTreeSet

public static <E> java.util.TreeSet<E> newTreeSet(java.util.SortedSet<E> s)

newHashSet

public static <E> java.util.Set<E> newHashSet()

newHashSet

public static <E> java.util.Set<E> newHashSet(int initialCapacity)

newHashSet

public static <E> java.util.Set<E> newHashSet(java.util.Collection<? extends E> c)

newHashMap

public static <K,V> java.util.Map<K,V> newHashMap()

newHashMap

public static <K,V> java.util.Map<K,V> newHashMap(int initialCapacity)

newHashMap

public static <K,V> java.util.Map<K,V> newHashMap(java.util.Map<? extends K,? extends V> m)

newIdentityHashMap

public static <K,V> java.util.IdentityHashMap<K,V> newIdentityHashMap()

newWeakHashMap

public static <K,V> java.util.WeakHashMap<K,V> newWeakHashMap()

newConcurrentHashMap

public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> newConcurrentHashMap()

newConcurrentHashMap

public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity)

newConcurrentHashMap

public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity,
                                                                                     float loadFactor,
                                                                                     int concurrencyLevel)

newTreeMap

public static <K,V> java.util.TreeMap<K,V> newTreeMap()

newIndex

public static <E> Index<E> newIndex()

newPair

public static <T1,T2> Pair<T1,T2> newPair(T1 first,
                                          T2 second)

newTriple

public static <T1,T2,T3> Triple<T1,T2,T3> newTriple(T1 first,
                                                    T2 second,
                                                    T3 third)

newInterner

public static <T> Interner<T> newInterner()

newSynchronizedInterner

public static <T> SynchronizedInterner<T> newSynchronizedInterner(Interner<T> interner)

newSynchronizedInterner

public static <T> SynchronizedInterner<T> newSynchronizedInterner(Interner<T> interner,
                                                                  java.lang.Object mutex)

newWeakReference

public static <T> java.lang.ref.WeakReference<T> newWeakReference(T referent)


Stanford NLP Group