Map Generation can now be turned off.

This commit is contained in:
2022-12-06 03:05:58 +01:00
parent c9fc963670
commit 57280b8285
16 changed files with 1098 additions and 478 deletions
@@ -11,7 +11,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.SET;
#if MAPS_FEATURE
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#endif
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
#if !SAME_TYPE
@@ -19,6 +21,7 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
#endif
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
import speiger.src.collections.objects.collections.ObjectIterable;
#if !TYPE_OBJECT && !VALUE_OBJECT
import speiger.src.collections.objects.collections.ObjectIterator;
#endif
@@ -47,6 +50,22 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
return this;
}
protected ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterable(MAP KEY_VALUE_GENERIC_TYPE map) {
#if MAPS_FEATURE
return MAPS.fastIterable(map);
#else
return map.ENTRY_SET();
#endif
}
protected ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterator(MAP KEY_VALUE_GENERIC_TYPE map) {
#if MAPS_FEATURE
return MAPS.fastIterator(map);
#else
return map.ENTRY_SET().iterator();
#endif
}
@Override
public MAP KEY_VALUE_GENERIC_TYPE copy() {
throw new UnsupportedOperationException();
@@ -63,14 +82,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
#if VALUE_PRIMITIVES
@Override
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
#endif
@Override
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(m);iter.hasNext();) {
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(m);iter.hasNext();) {
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
@@ -101,7 +120,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
#endif
@Override
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
@@ -161,14 +180,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
@Override
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
}
@@ -246,7 +265,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
VALUE_TYPE oldValue = GET_VALUE(key);
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
@@ -298,7 +317,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
Objects.requireNonNull(action);
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
@@ -332,7 +351,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public ITERATOR KEY_GENERIC_TYPE iterator() {
return new ITERATOR KEY_GENERIC_TYPE() {
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
@Override
public boolean hasNext() {
return iter.hasNext();
@@ -383,7 +402,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
@Override
public boolean hasNext() {
return iter.hasNext();
@@ -423,7 +442,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
@Override
public int hashCode() {
int hash = 0;
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);
while(iter.hasNext()) hash += iter.next().hashCode();
return hash;
}
@@ -24,7 +24,6 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.SET;
@@ -607,7 +606,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
int index = findIndex(key);
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
@@ -24,7 +24,6 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.SET;
@@ -568,7 +567,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
int index = findIndex(key);
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
@@ -28,7 +28,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
#endif
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.utils.ARRAYS;
#endif
@@ -215,7 +214,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
KEY_TYPE[] keys = NEW_KEY_ARRAY(map.size());
VALUE_TYPE[] values = NEW_VALUE_ARRAY(keys.length);
int index = 0;
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(map)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(map)) {
keys[index] = entry.ENTRY_KEY();
values[index] = entry.ENTRY_VALUE();
index++;
@@ -27,7 +27,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
@@ -176,7 +175,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
*/
public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
this(map.size());
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(map);iter.hasNext();size++) {
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(map);iter.hasNext();size++) {
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
keys[size] = entry.ENTRY_KEY();
values[size] = entry.ENTRY_VALUE();
@@ -566,7 +565,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
int index = findIndex(key);
VALUE_TYPE newValue = index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
@@ -19,7 +19,6 @@ import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
#endif
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
import speiger.src.collections.objects.maps.interfaces.MAP;
import speiger.src.collections.objects.sets.AbstractObjectSet;
@@ -449,7 +448,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
T key = entry.ENTRY_KEY();
int index = key.ordinal();
VALUE_TYPE newValue = !isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
@@ -33,7 +33,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#if TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET;
#endif
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
@@ -627,7 +626,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
@@ -33,7 +33,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#if TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET;
#endif
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
@@ -630,7 +629,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
@Override
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
Objects.requireNonNull(mappingFunction);
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
KEY_TYPE key = entry.ENTRY_KEY();
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
@@ -12,34 +12,65 @@ import java.util.function.Consumer;
import java.util.function.Function;
#if TYPE_OBJECT
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
import java.util.Comparator;
#endif
#endif
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
#if !TYPE_OBJECT && !TYPE_BOOLEAN
#if !TYPE_OBJECT && !TYPE_BOOLEAN && SORTED_MAP_FEATURE
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif
#endif
#if !TYPE_BOOLEAN
#if LINKED_CUSTOM_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
#endif
#if CUSTOM_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
#endif
#if LINKED_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
#endif
#if MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
#endif
#if IMMUTABLE_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
#endif
#if AVL_TREE_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
#endif
#if RB_TREE_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
#endif
#if ARRAY_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
#endif
#if CONCURRENT_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
#endif
#if TYPE_OBJECT
#if ENUM_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
#endif
#if LINKED_ENUM_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
#endif
#endif
import speiger.src.collections.objects.collections.ObjectIterable;
#if CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE
import speiger.src.collections.PACKAGE.utils.STRATEGY;
#endif
#if MAPS_FEATURE
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#endif
#endif
import speiger.src.collections.PACKAGE.sets.SET;
#if !SAME_TYPE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
@@ -505,7 +536,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
*/
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
#if !TYPE_BOOLEAN
#if MAPS_FEATURE
/**
* Creates a Wrapped Map that is Synchronized
* @return a new Map that is synchronized
@@ -658,6 +689,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
}
#endif
#if MAP_FEATURE
/**
* Helper function to unify code
* @Type(T)
@@ -731,6 +763,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new HASH_MAPKV_BRACES(map);
}
#endif
#if LINKED_MAP_FEATURE
/**
* Helper function to unify code
* @Type(T)
@@ -804,6 +838,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
}
#endif
#if IMMUTABLE_MAP_FEATURE
/**
* Helper function to unify code
* @param keys the keys that should be inserted
@@ -856,7 +892,9 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
}
#endif
#if TYPE_OBJECT
#if ENUM_MAP_FEATURE
/**
* Helper function to unify code
* @param keyType the EnumClass that should be used
@@ -924,6 +962,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new ENUM_MAPKV_BRACES(map);
}
#endif
#if LINKED_ENUM_MAP_FEATURE
/**
* Helper function to unify code
* @param keyType the EnumClass that should be used
@@ -990,7 +1030,10 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
return new LINKED_ENUM_MAPKV_BRACES(map);
}
#endif
#endif
#if CUSTOM_MAP_FEATURE
/**
* Helper function to unify code
* @param strategy the Hash Controller
@@ -1070,6 +1113,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
}
#endif
#if LINKED_CUSTOM_MAP_FEATURE
/**
* Helper function to unify code
* @param strategy the Hash Controller
@@ -1149,6 +1194,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
}
#endif
#if ARRAY_MAP_FEATURE
/**
* Helper function to unify code
* @Type(T)
@@ -1222,7 +1269,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new ARRAY_MAPKV_BRACES(map);
}
#endif
#if RB_TREE_MAP_FEATURE
/**
* Helper function to unify code
* @Type(T)
@@ -1300,6 +1348,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new RB_TREE_MAPKV_BRACES(map, comp);
}
#endif
#if AVL_TREE_MAP_FEATURE
/**
* Helper function to unify code
* @Type(T)
@@ -1376,6 +1426,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
return new AVL_TREE_MAPKV_BRACES(map, comp);
}
#endif
}
/**
@@ -1454,7 +1505,11 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
* @return self
*/
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
#if MAPS_FEATURE
return putAll(MAPS.fastIterable(map));
#else
return putAll(map.ENTRY_SET());
#endif
}
/**
@@ -1483,11 +1538,14 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return this;
}
#if MAP_FEATURE || LINKED_MAP_FEATURE || CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE || AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE || CONCURRENT_MAP_FEATURE
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
e.putAll(keys, values, 0, size);
return e;
}
#endif
#if MAP_FEATURE
/**
* Builds the Keys and Values into a Hash Map
* @return a HASH_MAP
@@ -1496,6 +1554,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new HASH_MAPKV_BRACES(size));
}
#endif
#if LINKED_MAP_FEATURE
/**
* Builds the Keys and Values into a Linked Hash Map
* @return a LINKED_HASH_MAP
@@ -1504,6 +1564,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
}
#endif
#if IMMUTABLE_MAP_FEATURE
/**
* Builds the Keys and Values into a Immutable Hash Map
* @return a IMMUTABLE_HASH_MAP
@@ -1512,6 +1574,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
}
#endif
#if CUSTOM_MAP_FEATURE
/**
* Builds the Keys and Values into a Custom Hash Map
* @param strategy the that controls the keys and values
@@ -1521,6 +1585,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
}
#endif
#if LINKED_CUSTOM_MAP_FEATURE
/**
* Builds the Keys and Values into a Linked Custom Hash Map
* @param strategy the that controls the keys and values
@@ -1530,6 +1596,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
}
#endif
#if CONCURRENT_MAP_FEATURE
/**
* Builds the Keys and Values into a Concurrent Hash Map
* @return a CONCURRENT_HASH_MAP
@@ -1538,6 +1606,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
}
#endif
#if ARRAY_MAP_FEATURE
/**
* Builds the Keys and Values into a Array Map
* @return a ARRAY_MAP
@@ -1546,6 +1616,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return new ARRAY_MAPKV_BRACES(keys, values, size);
}
#endif
#if RB_TREE_MAP_FEATURE
/**
* Builds the Keys and Values into a RedBlack TreeMap
* @return a RB_TREE_MAP
@@ -1563,6 +1635,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
return putElements(new RB_TREE_MAPKV_BRACES(comp));
}
#endif
#if AVL_TREE_MAP_FEATURE
/**
* Builds the Keys and Values into a AVL TreeMap
* @return a AVL_TREE_MAP
@@ -1579,6 +1653,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
}
#endif
}
#endif
}
@@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.maps.interfaces;
import java.util.NavigableMap;
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#if MAPS_FEATURE
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#endif
/**
* A Type Specific Navigable Map interface with a couple helper methods
@@ -37,6 +39,8 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
/** @return a Type Specific Navigable Key Set */
@Override
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
#if MAPS_FEATURE
/**
* Creates a Wrapped NavigableMap that is Synchronized
* @return a new NavigableMap that is synchronized
@@ -59,6 +63,7 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
*/
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
#endif
#if !TYPE_OBJECT
/**
* A Type Specific SubMap method to reduce boxing/unboxing
@@ -1,6 +1,8 @@
package speiger.src.collections.PACKAGE.maps.interfaces;
#if MAPS_FEATURE
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#endif
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
#endif
@@ -102,6 +104,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
@Override
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
#if MAPS_FEATURE
/**
* Creates a Wrapped SortedMap that is Synchronized
* @return a new SortedMap that is synchronized
@@ -127,6 +130,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
@Override
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
#endif
/**
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
* @Type(T)
@@ -10,7 +10,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
#if MAPS_FEATURE
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
#endif
#if !TYPE_OBJECT
import speiger.src.collections.objects.sets.ObjectSortedSet;
#endif
@@ -37,6 +39,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
@Override
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
#if MAPS_FEATURE
/**
* Creates a Wrapped SortedMap that is Synchronized
* @return a new SortedMap that is synchronized
@@ -59,6 +62,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
*/
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
#endif
#if !TYPE_OBJECT
/**
* A Type Specific SubMap method to reduce boxing/unboxing
@@ -3,9 +3,9 @@ package speiger.src.collections.PACKAGE.utils.maps;
#if !TYPE_BOOLEAN
import java.util.Map;
import java.util.Objects;
#if TYPE_OBJECT
#if TYPE_OBJECT && SORTED_MAP_FEATURE
import java.util.Comparator;
#else
#else if !TYPE_OBJECT
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
#endif
@@ -18,27 +18,34 @@ import java.util.function.Function;
import speiger.src.collections.objects.collections.ObjectIterable;
import speiger.src.collections.objects.collections.ObjectIterator;
import speiger.src.collections.objects.sets.ObjectSet;
#if !TYPE_BOOLEAN
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
import speiger.src.collections.objects.utils.ObjectIterators;
import speiger.src.collections.objects.utils.ObjectSets;
#if !TYPE_OBJECT
import speiger.src.collections.objects.sets.ObjectOrderedSet;
#if SORTED_MAP_FEATURE
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif
#endif
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
#endif
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
#if !TYPE_BOOLEAN
#if SORTED_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
#endif
#if ORDERED_MAP_FEATURE
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
#endif
#if SORTED_MAP_FEATURE
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
#endif
#if ORDERED_MAP_FEATURE
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
#endif
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.sets.SET;
import speiger.src.collections.PACKAGE.utils.SETS;
@@ -49,7 +56,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
#endif
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS;
#endif
/**
* A Helper class that provides you with Singleton/Empty/Synchronized/Unmodifyable Maps
@@ -144,6 +150,7 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE synchronize(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedMap ? map : new SynchronizedMapKV_BRACES(map, mutex); }
#if SORTED_MAP_FEATURE
/**
* Helper function that creates a Helper wrapper to synchronize access into the SortedMap.
* @param map the SortedMap that should be synchronized
@@ -166,6 +173,8 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); }
#endif
#if ORDERED_MAP_FEATURE
/**
* Helper function that creates a Helper wrapper to synchronize access into the OrderedMap.
* @param map the OrderedMap that should be synchronized
@@ -188,6 +197,8 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); }
#endif
#if NAVIGABLE_MAP_FEATURE
/**
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
* @param map the NavigableMap that should be synchronized
@@ -210,6 +221,7 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE synchronize(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedNavigableMap ? map : new SynchronizedNavigableMapKV_BRACES(map, mutex); }
#endif
/**
* A Helper function that creates a Helper wrapper to only allow Read Access into the Map
* @param map the map that should be made Unmodifiable
@@ -220,6 +232,7 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); }
#if ORDERED_MAP_FEATURE
/**
* A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap
* @param map the OrderedMap that should be made Unmodifiable
@@ -230,6 +243,8 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); }
#endif
#if SORTED_MAP_FEATURE
/**
* A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap
* @param map the SortedMap that should be made Unmodifiable
@@ -250,6 +265,7 @@ public class MAPS
*/
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); }
#endif
/**
* A Helper function that creates a Unmodifyable Entry
* @param entry the Entry that should be made unmodifiable
@@ -422,6 +438,7 @@ public class MAPS
public void set(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
}
#if SORTED_MAP_FEATURE
/**
* The Unmodifyable Navigable Map implementation that is sued for the unmodifyableMap function
* @Type(T)
@@ -493,6 +510,8 @@ public class MAPS
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
}
#endif
#if ORDERED_MAP_FEATURE
/**
* The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function
* @Type(T)
@@ -545,6 +564,8 @@ public class MAPS
}
}
#endif
#if SORTED_MAP_FEATURE
/**
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
* @Type(T)
@@ -584,6 +605,7 @@ public class MAPS
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
}
#endif
/**
* The Unmodifyable Map implementation that is sued for the unmodifyableMap function
* @Type(T)
@@ -666,7 +688,7 @@ public class MAPS
}
}
#if ORDERED_MAP_FEATURE
/**
* The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation
* @Type(T)
@@ -705,6 +727,7 @@ public class MAPS
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
}
#endif
/**
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
* @Type(T)
@@ -738,6 +761,7 @@ public class MAPS
}
#if SORTED_MAP_FEATURE
/**
* The Synchronized Navigable Map implementation used by the synchronizedMap helper function
* @Type(T)
@@ -856,6 +880,8 @@ public class MAPS
#endif
}
#endif
#if ORDERED_MAP_FEATURE
/**
* The Synchronized Ordered Map implementation used by the synchronizedMap helper function
* @Type(T)
@@ -913,6 +939,8 @@ public class MAPS
}
}
#endif
#if SORTED_MAP_FEATURE
/**
* The Synchronized Sorted Map implementation used by the synchronizedMap helper function
* @Type(T)
@@ -974,6 +1002,7 @@ public class MAPS
#endif
}
#endif
/**
* The Synchronized Map implementation used by the synchronizedMap helper function
* @Type(T)