Maps are now copyable too
This commit is contained in:
+33
@@ -609,6 +609,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
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
|
||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
||||
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 previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
@Override
|
||||
public NavigableSubMap KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||
@Override
|
||||
@@ -2391,6 +2408,22 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
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
|
||||
public KEY_TYPE ENTRY_KEY() {
|
||||
return key;
|
||||
|
||||
Reference in New Issue
Block a user