edu.stanford.nlp.util
Class Generics
java.lang.Object
edu.stanford.nlp.util.Generics
public class Generics
- extends 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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Generics
public Generics()
newArrayList
public static <E> ArrayList<E> newArrayList()
newArrayList
public static <E> ArrayList<E> newArrayList(int size)
newArrayList
public static <E> ArrayList<E> newArrayList(Collection<? extends E> c)
newLinkedList
public static <E> LinkedList<E> newLinkedList()
newLinkedList
public static <E> LinkedList<E> newLinkedList(Collection<? extends E> c)
newHashSet
public static <E> HashSet<E> newHashSet()
newHashSet
public static <E> HashSet<E> newHashSet(int initialCapacity)
newHashSet
public static <E> HashSet<E> newHashSet(Collection<? extends E> c)
newTreeSet
public static <E> TreeSet<E> newTreeSet()
newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
newTreeSet
public static <E> TreeSet<E> newTreeSet(SortedSet<E> s)
newStack
public static <E> Stack<E> newStack()
newBinaryHeapPriorityQueue
public static <E> BinaryHeapPriorityQueue<E> newBinaryHeapPriorityQueue()
newHashMap
public static <K,V> HashMap<K,V> newHashMap()
newHashMap
public static <K,V> HashMap<K,V> newHashMap(int initialCapacity)
newHashMap
public static <K,V> HashMap<K,V> newHashMap(Map<? extends K,? extends V> m)
newWeakHashMap
public static <K,V> WeakHashMap<K,V> newWeakHashMap()
newConcurrentHashMap
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap()
newConcurrentHashMap
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity)
newConcurrentHashMap
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
newTreeMap
public static <K,V> 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,
Object mutex)
newWeakReference
public static <T> WeakReference<T> newWeakReference(T referent)
Stanford NLP Group