Finishing ConcurrentHashMap implementation, next tests
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A type specific ConcurrentMap interface that reduces boxing/unboxing.
|
||||
* Since the interface adds nothing new. It is there just for completion sake.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public interface CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE extends ConcurrentMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE compute(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.compute(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfAbsent(CLASS_TYPE key, Function<? super CLASS_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE computeIfPresent(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.computeIfPresent(key, mappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) {
|
||||
MAP.super.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE merge(CLASS_TYPE key, CLASS_VALUE_TYPE value, BiFunction<? super CLASS_VALUE_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
return MAP.super.merge(key, value, mappingFunction);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
@Override
|
||||
public boolean remove(Object key, Object value);
|
||||
@Override
|
||||
public boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue);
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||
|
||||
#else
|
||||
@Primitive
|
||||
@Override
|
||||
public default CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
return MAP.super.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Primitive
|
||||
public default CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean remove(Object key, Object value) {
|
||||
return MAP.super.remove(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue) {
|
||||
return MAP.super.replace(key, oldValue, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||
return MAP.super.replace(key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
@Deprecated
|
||||
public default void replaceAll(BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||
MAP.super.replaceAll(mappingFunction);
|
||||
}
|
||||
}
|
||||
+9
@@ -31,6 +31,7 @@ import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
||||
#if TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||
@@ -1508,6 +1509,14 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
||||
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Keys and Values into a Concurrent Hash Map
|
||||
* @return a CONCURRENT_HASH_MAP
|
||||
*/
|
||||
public CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE concurrentMap() {
|
||||
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Keys and Values into a Array Map
|
||||
* @return a ARRAY_MAP
|
||||
|
||||
Reference in New Issue
Block a user