Top Description Fields Constructors Methods
org.python.util

public Class Generic

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .HashMap, .HashSet, .LinkedHashSet, .IdentityHashMap, .List, .Map, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap

Static methods to make instances of collections with their generic types inferred from what they're being assigned to. The idea is stolen from Sets, Lists and Maps from Google Collections.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
CHM_INITIAL_CAPACITY

Our default ConcurrentHashMap sizes.

public static final float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <K, V> ConcurrentMap<K, V>
concurrentMap()

Makes a ConcurrentMap using generic types inferred from whatever this is being assigned to.

public static <E> Set<E>
concurrentSet()

Makes a Set, ensuring safe concurrent operations, using generic types inferred from whatever this is being assigned to.

public static <K, V> Map<K, V>
identityHashMap()

Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.

public static <K, V> Map<K, V>
identityHashMap(int capacity)

Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.

public static <E> Set<E>
linkedHashSet()

Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.

public static <E> Set<E>
linkedHashSet(int capacity)

Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.

public static <T> List<T>
list()

Makes a List with its generic type inferred from whatever it's being assigned to.

public static <T> List<T>
list(int capacity)

Makes a List with its generic type inferred from whatever it's being assigned to.

public static <T, U extends T> List<T>
list(U... contents)

Makes a List with its generic type inferred from whatever it's being assigned to filled with the items in contents.

public static <K, V> Map<K, V>
map()

Makes a Map using generic types inferred from whatever this is being assigned to.

public static <E> Set<E>
set()

Makes a Set using the generic type inferred from whatever this is being assigned to.

public static <T, U extends T> Set<T>
set(U... contents)

Makes a Set using the generic type inferred from whatever this is being assigned to filled with the items in contents.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHM_CONCURRENCY_LEVELback to summary
public static final int CHM_CONCURRENCY_LEVEL
CHM_INITIAL_CAPACITYback to summary
public static final int CHM_INITIAL_CAPACITY

Our default ConcurrentHashMap sizes. Only concurreny level differs from ConcurrentHashMap's defaults: it's significantly lower to reduce allocation cost.

CHM_LOAD_FACTORback to summary
public static final float CHM_LOAD_FACTOR

Constructor Detail

Genericback to summary
public Generic()

Method Detail

concurrentMapback to summary
public static <K, V> ConcurrentMap<K, V> concurrentMap()

Makes a ConcurrentMap using generic types inferred from whatever this is being assigned to.

concurrentSetback to summary
public static <E> Set<E> concurrentSet()

Makes a Set, ensuring safe concurrent operations, using generic types inferred from whatever this is being assigned to.

identityHashMapback to summary
public static <K, V> Map<K, V> identityHashMap()

Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to.

identityHashMapback to summary
public static <K, V> Map<K, V> identityHashMap(int capacity)

Makes an IdentityHashMap using generic types inferred from whatever this is being assigned to. Sets initial capacity accordingly.

linkedHashSetback to summary
public static <E> Set<E> linkedHashSet()

Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to.

linkedHashSetback to summary
public static <E> Set<E> linkedHashSet(int capacity)

Makes a LinkedHashSet using the generic type inferred from whatever this is being assigned to. Sets initial capacity accordingly.

listback to summary
public static <T> List<T> list()

Makes a List with its generic type inferred from whatever it's being assigned to.

listback to summary
public static <T> List<T> list(int capacity)

Makes a List with its generic type inferred from whatever it's being assigned to. Sets initial capacity accordingly.

listback to summary
public static <T, U extends T> List<T> list(U... contents)

Makes a List with its generic type inferred from whatever it's being assigned to filled with the items in contents.

Annotations
@SafeVarargs
mapback to summary
public static <K, V> Map<K, V> map()

Makes a Map using generic types inferred from whatever this is being assigned to.

setback to summary
public static <E> Set<E> set()

Makes a Set using the generic type inferred from whatever this is being assigned to.

setback to summary
public static <T, U extends T> Set<T> set(U... contents)

Makes a Set using the generic type inferred from whatever this is being assigned to filled with the items in contents.

Annotations
@SafeVarargs