MCPcopy Create free account
hub / github.com/davidgiven/luje / clone

Method clone

lib/java/util/TreeMap.java:1049–1073  ·  view source on GitHub ↗

Returns a new TreeMap with the same mappings, size and comparator as this instance. @return a shallow copy of this instance. @see java.lang.Cloneable

()

Source from the content-addressed store, hash-verified

1047 * @see java.lang.Cloneable
1048 */
1049 @SuppressWarnings("unchecked")
1050 @Override
1051 public Object clone() {
1052 try {
1053 TreeMap<K, V> clone = (TreeMap<K, V>) super.clone();
1054 clone.entrySet = null;
1055 if (root != null) {
1056 clone.root = root.clone(null);
1057 // restore prev/next chain
1058 Node<K, V> node = minimum(clone.root);
1059 while (true) {
1060 Node<K, V> nxt = successor(node);
1061 if (nxt == null) {
1062 break;
1063 }
1064 nxt.prev = node;
1065 node.next = nxt;
1066 node = nxt;
1067 }
1068 }
1069 return clone;
1070 } catch (CloneNotSupportedException e) {
1071 return null;
1072 }
1073 }
1074
1075 static private <K, V> Node<K, V> successor(Node<K, V> x) {
1076 if (x.right != null) {

Callers 2

cloneMethod · 0.45
cloneMethod · 0.45

Calls 2

minimumMethod · 0.95
successorMethod · 0.95

Tested by

no test coverage detected