public CollectionOptions build() { return new CollectionOptions( concurrent, forbidsDuplicate, insertionOrdered, mutable); } }
protected <K, V> Map<K,V> newMap(final CollectionOptions opts) { if (opts.insertionOrdered()) { if (opts.concurrent()) { // TODO: something with better performance... // Perhaps supersource ConcurrentSkipListMap, // and remove all the contention-worries that plague its implementation return synchronizedMap(new LinkedHashMap<K, V>()); } else { return new LinkedHashMap<K, V>(); } } if (X_Runtime.isMultithreaded()) { return new ConcurrentHashMap<K,V>(); } else { return new HashMap<K,V>(); } }
public ListOf() { this(CollectionOptions.asMutableList().build()); } public ListOf(CollectionOptions opts) {
protected <K, V> CollectionProxy<K,V> newProxy(final Class<K> keyType, final Class<V> valueType, final CollectionOptions opts) { if (opts.insertionOrdered()) { if (opts.concurrent()) { return new MapOf<K,V>(new ConcurrentSkipListMap<K,V>(), keyType, valueType); } else { return new MapOf<K,V>(new LinkedHashMap<K,V>(), keyType, valueType); } } if (opts.concurrent()) { return new MapOf<K,V>(new ConcurrentHashMap<K,V>(), keyType, valueType); } else { return new MapOf<K,V>(new HashMap<K,V>(), keyType, valueType); } }