/** * Create a deep clone of the heap and return it * * @return */ public Heap deepClone() { Heap hp = new Heap(); if (this.heap == null) { hp.setHeap(null); return hp; } // set the clone global element hp.setGlobal(this.getGlobal()); Set<Location> keys = this.getKeySet(); for (Location key : keys) { JSObject old_ov = this.get(key); // create a deep clone of the old object value JSObject new_ov = old_ov.deepClone(); hp.put(key, new_ov); } hp.setStrValueMap((HashMap<String, Location>) this.strValueMap.clone()); hp.setDummyObjectMap((HashMap<String, Location>) this.dummyObjectMap.clone()); return hp; }