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.
|
static class |
CollectionFactory.ThreadSafeConditionalCopySet<T>
this class behaves like ConditionalCopySet except it is designed to be
threadsafe; multiple thread access is regulated by a readwritelock;
modifications will create a copy based on SyncSet.
|
Constructor and Description |
---|
CollectionFactory() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
createList() |
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> 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> Set<T> |
getThreadSafeCopyOnRequestSet(Set<T> source) |
static void |
setExpectedThreads(int value) |
static void |
sortOptionally(List<? extends OWLObject> toReturn)
Sort the input collection; if the ordering is unstable and an error is
thrown (due to the use of TimSort in JDK 1.7 and newer), catch it and
leave the collection unsorted.
|
static <T extends Comparable<T>> |
sortOptionallyComparables(List<T> toReturn)
Sort the input collection; if the ordering is unstable and an error is
thrown (due to the use of TimSort in JDK 1.7 and newer), catch it and
leave the collection unsorted.
|
public static <T extends Comparable<T>> void sortOptionallyComparables(List<T> toReturn)
T
- collection typetoReturn
- list to sortpublic static void sortOptionally(List<? extends OWLObject> toReturn)
toReturn
- list to sortpublic static void setExpectedThreads(int value)
value
- the number of expected threads that will access threadsafe
collections; useful for increasing the concurrency in
ConcurrentHashMapspublic static int getExpectedThreads()
public static <T> Set<T> createSet()
T
- axiom typepublic static <T> List<T> createList()
T
- content typepublic static <T> List<T> createSyncList()
T
- content typepublic 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 typepublic static <T> Set<T> createSet(T... elements)
T
- axiom typeelements
- values 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(Collection<T> source)
T
- axiom typesource
- source collectionpublic static <T> Set<T> getCopyOnRequestSetFromImmutableCollection(Collection<T> source)
T
- axiom typesource
- the source collectionCopyright © 2017 The University of Manchester. All Rights Reserved.