Generic (Jython API documentation)
Date: 2012-08-13

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.python.util
Class Generic

    java.lang.Object
      org.python.util.Generic

    public class Generic

extends Object

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
`static int` | `CHM_CONCURRENCY_LEVEL`
`static int` | `CHM_INITIAL_CAPACITY` Our default ConcurrentHashMap sizes.
`static float` | `CHM_LOAD_FACTOR`

Constructor Summary
`Generic()`

Method Summary
`static
`<K,V> ConcurrentMap<K,V>`
` | `concurrentMap()` Makes a ConcurrentMap using generic types inferred from whatever this is being assigned to.
`static
`<E> Set<E>`
` | `concurrentSet()` Makes a Set, ensuring safe concurrent operations, using generic types inferred from whatever this is being assigned to.
`static
`<T> List<T>`
` | `list()` Makes a List with its generic type inferred from whatever it's being assigned to.
`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`.
`static
`<K,V> Map<K,V>`
` | `map()` Makes a Map using generic types inferred from whatever this is being assigned to.
`static
`<E> Set<E>`
` | `newSetFromMap(Map<E,Boolean> map)` Return a Set backed by the specified Map with the same ordering, concurrency and performance characteristics.
`static
`<E> Set<E>`
` | `set()` Makes a Set using the generic type inferred from whatever this is being assigned to.
`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`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CHM_INITIAL_CAPACITY

    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.

  See Also:
    Constant Field Values

### CHM_LOAD_FACTOR

    public static final float CHM_LOAD_FACTOR

See Also:
  Constant Field Values

### CHM_CONCURRENCY_LEVEL

    public static final int CHM_CONCURRENCY_LEVEL

See Also:
  Constant Field Values

Constructor Detail

### Generic

    public Generic()

Method Detail

### list

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

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

### list

    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`.

### map

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

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

### concurrentMap

    public static <K,V> ConcurrentMap<K,V> concurrentMap()

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

### set

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

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

### set

    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`.

### concurrentSet

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

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

### newSetFromMap

    public static <E> Set<E> newSetFromMap(Map<E,Boolean> map)

  Return a Set backed by the specified Map with the same ordering, concurrency and performance characteristics. The specified Map must be empty at the time this method is invoked. Note that this method is based on Java 6's Collections.newSetFromMap, and will be removed in a future version of Jython (likely 2.6) that will rely on Java 6.

  Parameters:
    `map` - the backing Map
  Returns:
    a Set backed by the Map
  Throws:
    `IllegalArgumentException` - if Map is not empty

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Jython homepage