Maps are now copyable too
This commit is contained in:
parent
dff173222d
commit
61d7a88c82
|
@ -128,6 +128,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
||||||
* It can be compared to Cloneable but with less exception risk
|
* It can be compared to Cloneable but with less exception risk
|
||||||
* @return a Shallow Copy of the collection
|
* @return a Shallow Copy of the collection
|
||||||
|
* @note Wrappers and view collections will not support this feature
|
||||||
*/
|
*/
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy();
|
public COLLECTION KEY_GENERIC_TYPE copy();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,11 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
@ -336,6 +337,23 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_CUSTOM_HASH_MAPKV_BRACES(0, loadFactor, strategy);
|
||||||
|
map.minCapacity = minCapacity;
|
||||||
|
map.mask = mask;
|
||||||
|
map.maxFill = maxFill;
|
||||||
|
map.nullIndex = nullIndex;
|
||||||
|
map.containsNull = containsNull;
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, values.length);
|
||||||
|
map.links = Arrays.copyOf(links, links.length);
|
||||||
|
map.firstIndex = firstIndex;
|
||||||
|
map.lastIndex = lastIndex;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -423,6 +423,20 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new CUSTOM_HASH_MAPKV_BRACES(0, loadFactor, strategy);
|
||||||
|
map.minCapacity = minCapacity;
|
||||||
|
map.mask = mask;
|
||||||
|
map.maxFill = maxFill;
|
||||||
|
map.nullIndex = nullIndex;
|
||||||
|
map.containsNull = containsNull;
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, values.length);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
@ -313,6 +314,23 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_HASH_MAPKV_BRACES(0, loadFactor);
|
||||||
|
map.minCapacity = minCapacity;
|
||||||
|
map.mask = mask;
|
||||||
|
map.maxFill = maxFill;
|
||||||
|
map.nullIndex = nullIndex;
|
||||||
|
map.containsNull = containsNull;
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, values.length);
|
||||||
|
map.links = Arrays.copyOf(links, links.length);
|
||||||
|
map.firstIndex = firstIndex;
|
||||||
|
map.lastIndex = lastIndex;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -384,6 +384,20 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
HASH_MAP KEY_VALUE_GENERIC_TYPE map = new HASH_MAPKV_BRACES(0, loadFactor);
|
||||||
|
map.minCapacity = minCapacity;
|
||||||
|
map.mask = mask;
|
||||||
|
map.maxFill = maxFill;
|
||||||
|
map.nullIndex = nullIndex;
|
||||||
|
map.containsNull = containsNull;
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, values.length);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package speiger.src.collections.PACKAGE.maps.impl.immutable;
|
package speiger.src.collections.PACKAGE.maps.impl.immutable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -103,6 +104,10 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
||||||
/** Amount of Elements stored in the HashMap */
|
/** Amount of Elements stored in the HashMap */
|
||||||
protected int size;
|
protected int size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor for copying the Map
|
||||||
|
*/
|
||||||
|
protected IMMUTABLE_HASH_MAP() {}
|
||||||
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
|
@ -412,6 +417,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
||||||
return valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new IMMUTABLE_HASH_MAPKV_BRACES();
|
||||||
|
map.mask = mask;
|
||||||
|
map.nullIndex = nullIndex;
|
||||||
|
map.containsNull = containsNull;
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, values.length);
|
||||||
|
map.links = Arrays.copyOf(links, links.length);
|
||||||
|
map.firstIndex = firstIndex;
|
||||||
|
map.lastIndex = lastIndex;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -554,6 +554,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ARRAY_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
ARRAY_MAP KEY_VALUE_GENERIC_TYPE map = new ARRAY_MAPKV_BRACES();
|
||||||
|
map.size = size;
|
||||||
|
map.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
map.values = Arrays.copyOf(values, keys.length);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -981,6 +989,11 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubMap copy() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -176,6 +176,15 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public ENUM_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
ENUM_MAP KEY_VALUE_GENERIC_TYPE map = new ENUM_MAPKV_BRACES(keyType);
|
||||||
|
map.size = size;
|
||||||
|
System.arraycopy(present, 0, map.present, 0, Math.min(present.length, map.present.length));
|
||||||
|
System.arraycopy(values, 0, map.values, 0, Math.min(values.length, map.values.length));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new EntrySet();
|
if(entrySet == null) entrySet = new EntrySet();
|
||||||
|
|
|
@ -127,6 +127,18 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_ENUM_MAPKV_BRACES(keyType);
|
||||||
|
map.size = size;
|
||||||
|
System.arraycopy(present, 0, map.present, 0, Math.min(present.length, map.present.length));
|
||||||
|
System.arraycopy(values, 0, map.values, 0, Math.min(values.length, map.values.length));
|
||||||
|
System.arraycopy(links, 0, map.links, 0, Math.min(links.length, map.links.length));
|
||||||
|
map.firstIndex = firstIndex;
|
||||||
|
map.lastIndex = lastIndex;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -610,6 +610,21 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
return new KeyIterator(findNode(key));
|
return new KeyIterator(findNode(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE set = new AVL_TREE_MAPKV_BRACES();
|
||||||
|
set.size = size;
|
||||||
|
if(tree != null) {
|
||||||
|
set.tree = tree.copy();
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE lastFound = null;
|
||||||
|
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
||||||
|
set.first = lastFound;
|
||||||
|
lastFound = null;
|
||||||
|
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
||||||
|
set.last = lastFound;
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
|
@ -1133,7 +1148,8 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NavigableSubMap KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
@Override
|
@Override
|
||||||
|
@ -2323,6 +2339,22 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE entry = new EntryKV_BRACES(key, value, null);
|
||||||
|
entry.state = state;
|
||||||
|
if(left != null) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE newLeft = left.copy();
|
||||||
|
entry.left = newLeft;
|
||||||
|
newLeft.parent = entry;
|
||||||
|
}
|
||||||
|
if(right != null) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE newRight = right.copy();
|
||||||
|
entry.right = newRight;
|
||||||
|
newRight.parent = entry;
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ENTRY_KEY() {
|
public KEY_TYPE ENTRY_KEY() {
|
||||||
return key;
|
return key;
|
||||||
|
|
|
@ -609,6 +609,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
return new KeyIterator(findNode(key));
|
return new KeyIterator(findNode(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RB_TREE_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
RB_TREE_MAP KEY_VALUE_GENERIC_TYPE set = new RB_TREE_MAPKV_BRACES();
|
||||||
|
set.size = size;
|
||||||
|
if(tree != null) {
|
||||||
|
set.tree = tree.copy();
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE lastFound = null;
|
||||||
|
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
||||||
|
set.first = lastFound;
|
||||||
|
lastFound = null;
|
||||||
|
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
||||||
|
set.last = lastFound;
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
|
@ -1187,6 +1202,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NavigableSubMap KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
@Override
|
@Override
|
||||||
|
@ -2391,6 +2408,22 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE entry = new EntryKV_BRACES(key, value, null);
|
||||||
|
entry.state = state;
|
||||||
|
if(left != null) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE newLeft = left.copy();
|
||||||
|
entry.left = newLeft;
|
||||||
|
newLeft.parent = entry;
|
||||||
|
}
|
||||||
|
if(right != null) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE newRight = right.copy();
|
||||||
|
entry.right = newRight;
|
||||||
|
newRight.parent = entry;
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ENTRY_KEY() {
|
public KEY_TYPE ENTRY_KEY() {
|
||||||
return key;
|
return key;
|
||||||
|
|
|
@ -59,6 +59,15 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
||||||
*/
|
*/
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v);
|
public MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Function that does a shallow clone of the Map itself.
|
||||||
|
* This function is more optimized then a copy constructor since the Map does not have to be unsorted/resorted.
|
||||||
|
* It can be compared to Cloneable but with less exception risk
|
||||||
|
* @return a Shallow Copy of the Map
|
||||||
|
* @note Wrappers and view Maps will not support this feature
|
||||||
|
*/
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type Specific method to reduce boxing/unboxing of values
|
* Type Specific method to reduce boxing/unboxing of values
|
||||||
* @param key the key that should be inserted,
|
* @param key the key that should be inserted,
|
||||||
|
|
|
@ -10,6 +10,8 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
*/
|
*/
|
||||||
public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VALUE_GENERIC_TYPE, NavigableMap<CLASS_TYPE, CLASS_VALUE_TYPE>
|
public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VALUE_GENERIC_TYPE, NavigableMap<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
/** @return a Type Specific desendingMap */
|
/** @return a Type Specific desendingMap */
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
|
|
|
@ -75,6 +75,9 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet();
|
public SET KEY_GENERIC_TYPE keySet();
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -277,6 +277,8 @@ public class MAPS
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public SingletonMap KEY_VALUE_GENERIC_TYPE copy() { return new SingletonMapKV_BRACES(key, value); }
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = SETS.singleton(key);
|
if(keySet == null) keySet = SETS.singleton(key);
|
||||||
|
@ -329,6 +331,8 @@ public class MAPS
|
||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() { return VALUE_COLLECTIONS.empty(); }
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() { return VALUE_COLLECTIONS.empty(); }
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() { return ObjectSets.empty(); }
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() { return ObjectSets.empty(); }
|
||||||
|
@Override
|
||||||
|
public EmptyMap KEY_VALUE_GENERIC_TYPE copy() { return this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,6 +419,8 @@ public class MAPS
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { return unmodifiable(map.floorEntry(key)); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { return unmodifiable(map.floorEntry(key)); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return unmodifiable(map.ceilingEntry(key)); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return unmodifiable(map.ceilingEntry(key)); }
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -462,6 +468,8 @@ public class MAPS
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||||
|
@Override
|
||||||
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -501,6 +509,8 @@ public class MAPS
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
|
@ -614,6 +624,8 @@ public class MAPS
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { synchronized(mutex) { return map.floorEntry(key); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { synchronized(mutex) { return map.floorEntry(key); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -718,6 +730,8 @@ public class MAPS
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { synchronized(mutex) { return map.FIRST_ENTRY_VALUE(); } }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { synchronized(mutex) { return map.FIRST_ENTRY_VALUE(); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
||||||
|
@Override
|
||||||
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -831,6 +845,8 @@ public class MAPS
|
||||||
@Override
|
@Override
|
||||||
public int size() { synchronized(mutex) { return super.size(); } }
|
public int size() { synchronized(mutex) { return super.size(); } }
|
||||||
@Override
|
@Override
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
||||||
return keys;
|
return keys;
|
||||||
|
|
Loading…
Reference in New Issue