public class CollectionFactory extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CollectionFactory.ConditionalCopySet<T>
a set implementation that uses a delegate collection for all read-only operations and makes a
copy if changes are attempted.
|
Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
copy(Collection<T> source) |
static <T> Set<T> |
copyMutable(Collection<T> source) |
static <T> Set<T> |
createLinkedSet() |
static <T> List<T> |
createList() |
static <T> List<T> |
createList(T... elements) |
static <K,V> Map<K,V> |
createMap() |
static <T> Set<T> |
createSet() |
static <T> Set<T> |
createSet(Collection<T> c) |
static <T> Set<T> |
createSet(int initialCapacity) |
static <T> Set<T> |
createSet(T... elements) |
static <T> Set<T> |
createSet(T element) |
static <T> List<T> |
createSyncList() |
static <K,V> ConcurrentHashMap<K,V> |
createSyncMap() |
static <T> Set<T> |
createSyncSet() |
static <K,V> Map<K,WeakReference<V>> |
createSyncWeakMap() |
static <T> Set<T> |
getCopyOnRequestSet(Collection<T> source) |
static <T> Set<T> |
getCopyOnRequestSetFromImmutableCollection(Collection<T> source) |
static <T> Set<T> |
getCopyOnRequestSetFromMutableCollection(Collection<T> source) |
static int |
getExpectedThreads() |
static <T> List<T> |
list(Iterable<T> i) |
static <T> List<T> |
list(T... i) |
static <T> List<T> |
list(T i) |
static void |
setExpectedThreads(int value) |
public static int getExpectedThreads()
public static void setExpectedThreads(int value)
value
- the number of expected threads that will update threadsafe collections; useful
for increasing the concurrency in ConcurrentHashMap instances created by this factorypublic static <T> Set<T> createSet()
T
- axiom typepublic static <T> Set<T> createLinkedSet()
T
- axiom typepublic static <T> List<T> createList()
T
- axiom type@SafeVarargs public static <T> List<T> createList(T... elements)
T
- axiom typeelements
- values to add to the listpublic static <T> List<T> createSyncList()
T
- content typepublic static <T> List<T> list(Iterable<T> i)
T
- typei
- iterable@SafeVarargs public static <T> List<T> list(T... i)
T
- typei
- iterablepublic static <T> List<T> list(T i)
T
- typei
- iterablepublic static <T> Set<T> createSet(Collection<T> c)
T
- axiom typec
- values to add to the setpublic static <T> Set<T> createSet(int initialCapacity)
T
- axiom typeinitialCapacity
- initial capacity for the new setpublic static <K,V> Map<K,V> createMap()
K
- key typeV
- value typepublic static <K,V> Map<K,WeakReference<V>> createSyncWeakMap()
K
- key typeV
- value type@SafeVarargs public static <T> Set<T> createSet(T... elements)
T
- axiom typeelements
- values to add to the setpublic static <T> Set<T> createSet(T element)
T
- axiom typeelement
- value to add to the setpublic static <T> Set<T> createSyncSet()
T
- set typepublic static <K,V> ConcurrentHashMap<K,V> createSyncMap()
K
- key typeV
- value typepublic static <T> Set<T> getCopyOnRequestSet(Collection<T> source)
T
- axiom typesource
- the collection to lazily copypublic static <T> Set<T> getCopyOnRequestSetFromMutableCollection(@Nullable Collection<T> source)
T
- axiom typesource
- source collectionpublic static <T> Set<T> copy(@Nullable Collection<T> source)
T
- axiom typesource
- the source collection, expected to be immutablepublic static <T> Set<T> copyMutable(@Nullable Collection<T> source)
T
- axiom typesource
- the source collection, expected to be mutable; the backing list is created
immediatelypublic static <T> Set<T> getCopyOnRequestSetFromImmutableCollection(@Nullable Collection<T> source)
T
- axiom typesource
- the source collection, expected to be immutableCopyright © 2020 The University of Manchester. All rights reserved.