public class Generics extends Object
Map<String,ClassicCounter<List<String>>> = new HashMap<String,ClassicCounter<List<String>>>()
you just call Generics.newHashMap()
:
Map<String,ClassicCounter<List<String>>> = 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.Modifier and Type | Field and Description |
---|---|
static String |
HASH_MAP_CLASSNAME |
static String |
HASH_MAP_PROPERTY |
static String |
HASH_SET_CLASSNAME |
static String |
HASH_SET_PROPERTY |
Modifier and Type | Method and Description |
---|---|
static <E> ArrayList<E> |
newArrayList() |
static <E> ArrayList<E> |
newArrayList(Collection<? extends E> c) |
static <E> ArrayList<E> |
newArrayList(int size) |
static <E> BinaryHeapPriorityQueue<E> |
newBinaryHeapPriorityQueue() |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap() |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap(int initialCapacity) |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel) |
static <K,V> Map<K,V> |
newHashMap() |
static <K,V> Map<K,V> |
newHashMap(int initialCapacity) |
static <K,V> Map<K,V> |
newHashMap(Map<? extends K,? extends V> m) |
static <E> Set<E> |
newHashSet() |
static <E> Set<E> |
newHashSet(Collection<? extends E> c) |
static <E> Set<E> |
newHashSet(int initialCapacity) |
static <K,V> IdentityHashMap<K,V> |
newIdentityHashMap() |
static <K> Set<K> |
newIdentityHashSet() |
static <E> Index<E> |
newIndex() |
static <T> Interner<T> |
newInterner() |
static <E> LinkedList<E> |
newLinkedList() |
static <E> LinkedList<E> |
newLinkedList(Collection<? extends E> c) |
static <T1,T2> Pair<T1,T2> |
newPair(T1 first,
T2 second) |
static <E> Stack<E> |
newStack() |
static <T> SynchronizedInterner<T> |
newSynchronizedInterner(Interner<T> interner) |
static <T> SynchronizedInterner<T> |
newSynchronizedInterner(Interner<T> interner,
Object mutex) |
static <K,V> TreeMap<K,V> |
newTreeMap() |
static <E> TreeSet<E> |
newTreeSet() |
static <E> TreeSet<E> |
newTreeSet(Comparator<? super E> comparator) |
static <E> TreeSet<E> |
newTreeSet(SortedSet<E> s) |
static <T1,T2,T3> Triple<T1,T2,T3> |
newTriple(T1 first,
T2 second,
T3 third) |
static <K,V> WeakHashMap<K,V> |
newWeakHashMap() |
static <T> WeakReference<T> |
newWeakReference(T referent) |
public static final String HASH_SET_PROPERTY
public static final String HASH_SET_CLASSNAME
public static final String HASH_MAP_PROPERTY
public static final String HASH_MAP_CLASSNAME
public static <E> ArrayList<E> newArrayList()
public static <E> ArrayList<E> newArrayList(int size)
public static <E> ArrayList<E> newArrayList(Collection<? extends E> c)
public static <E> LinkedList<E> newLinkedList()
public static <E> LinkedList<E> newLinkedList(Collection<? extends E> c)
public static <E> Stack<E> newStack()
public static <E> BinaryHeapPriorityQueue<E> newBinaryHeapPriorityQueue()
public static <E> TreeSet<E> newTreeSet()
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
public static <E> Set<E> newHashSet()
public static <E> Set<E> newHashSet(int initialCapacity)
public static <E> Set<E> newHashSet(Collection<? extends E> c)
public static <K,V> Map<K,V> newHashMap()
public static <K,V> Map<K,V> newHashMap(int initialCapacity)
public static <K,V> IdentityHashMap<K,V> newIdentityHashMap()
public static <K> Set<K> newIdentityHashSet()
public static <K,V> WeakHashMap<K,V> newWeakHashMap()
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap()
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity)
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
public static <K,V> TreeMap<K,V> newTreeMap()
public static <E> Index<E> newIndex()
public static <T1,T2> Pair<T1,T2> newPair(T1 first, T2 second)
public static <T1,T2,T3> Triple<T1,T2,T3> newTriple(T1 first, T2 second, T3 third)
public static <T> Interner<T> newInterner()
public static <T> SynchronizedInterner<T> newSynchronizedInterner(Interner<T> interner)
public static <T> SynchronizedInterner<T> newSynchronizedInterner(Interner<T> interner, Object mutex)
public static <T> WeakReference<T> newWeakReference(T referent)