@Test public void mergeTest() { SampleData dataOne = new SampleData(); dataOne.weights = new int[]{3, 8, 27, 6}; dataOne.strings = new String[]{"Bleh", "Foo", "Snide", "Mesh"}; WeightedList<String> listOne = demoList(dataOne); SampleData dataTwo = new SampleData(); dataTwo.weights = new int[]{8, 2, 9, 21}; dataTwo.strings = new String[]{"Gree", "Fnex", "Moose", "Twa"}; WeightedList<String> listTwo = demoList(dataTwo); WeightedList<String> listMerged = new WeightedList<>(); listMerged.merge(listOne); listMerged.merge(listTwo); int i = 0; i = testList(i, dataOne, listMerged); i = testList(i, dataTwo, listMerged); testListEnd(i, listMerged); }
boolean merge(WeightedList<E> list) { for (Integer oldKey : list.map.keySet()) map.put(maxValue + oldKey, list.map.get(oldKey)); maxValue += list.maxValue; return true; }
WeightedList implements Cloneable { boolean merge(WeightedList<E> list) { for (Integer oldKey : list.map.keySet()) map.put(maxValue + oldKey, list.map.get(oldKey)); maxValue += list.maxValue; return true; } }
WeightedList implements Cloneable { boolean merge(WeightedList<E> list) { for (Integer oldKey : list.map.keySet()) map.put(maxValue + oldKey, list.map.get(oldKey)); maxValue += list.maxValue; return true; }  }
WeightedList implements Cloneable { boolean merge(WeightedList<E> list) { for (Integer oldKey : list.map.keySet()) map.put(maxValue + oldKey, list.map.get(oldKey)); maxValue += list.maxValue; return true; }  int count(); @SuppressWarnings("unchecked") @Override WeightedList<E> clone(); }
WeightedList implements Cloneable { boolean merge(WeightedList<E> list) { for (Integer oldKey : list.map.keySet()) map.put(maxValue + oldKey, list.map.get(oldKey)); maxValue += list.maxValue; return true; }  int count(); @SuppressWarnings("unchecked") @Override WeightedList<E> clone();  }