MCPcopy Create free account
hub / github.com/PCGen/pcgen / clone

Method clone

PCGen-base/code/src/java/pcgen/base/util/TripleKeyMap.java:333–365  ·  view source on GitHub ↗

Clones this TripleKeyMap. The contents of the TripleKeyMap (the keys and values) are not cloned - this is not a truly deep clone. However, the internal structure of the TripleKeyMap is sufficiently cloned in order to protect the internal structure of the original or the clone from being modified by

()

Source from the content-addressed store, hash-verified

331 * exception
332 */
333 @Override
334 public TripleKeyMap<K1, K2, K3, V> clone()
335 throws CloneNotSupportedException
336 {
337 /*
338 * This cast will cause a Generic type safety warning. This is
339 * impossible to avoid, given that super.clone() will not return a
340 * TripleKeyMap with the proper Generic arguments. - Thomas Parker
341 * 1/26/07
342 */
343 @SuppressWarnings("unchecked")
344 TripleKeyMap<K1, K2, K3, V> tkm =
345 (TripleKeyMap<K1, K2, K3, V>) super.clone();
346 /*
347 * This provides a semi-deep clone of the TripleKeyMap, in order to
348 * protect the internal structure of the TripleKeyMap from modification.
349 * Note the key and value objects are not cloned, so this is not truly a
350 * deep clone, but is deep enough to protect the internal structure.
351 */
352 tkm.map = new DoubleKeyMap<>();
353 for (K1 key1 : map.getKeySet())
354 {
355 for (K2 key2 : map.getSecondaryKeySet(key1))
356 {
357 Map<K3, V> local = map.get(key1, key2);
358 for (Map.Entry<K3, V> me : local.entrySet())
359 {
360 tkm.put(key1, key2, me.getKey(), me.getValue());
361 }
362 }
363 }
364 return tkm;
365 }
366
367 /**
368 * Returns a Set of the values stored in this TripleKeyMap for the given

Callers 1

testCloneMethod · 0.95

Calls 7

getKeySetMethod · 0.65
getMethod · 0.65
putMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
getSecondaryKeySetMethod · 0.45
entrySetMethod · 0.45

Tested by 1

testCloneMethod · 0.76