@Override public void insertBefore(E toInsert, E point) { if (toInsert == null) { throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); } if (map.containsKey(toInsert)) { throw new RuntimeException("Chain already contains object."); } Link<E> temp = map.get(point); if (temp == null) { throw new RuntimeException("Insertion point not found in chain!"); } stateCount++; Link<E> newLink = temp.insertBefore(toInsert); map.put(toInsert, newLink); }
@Override public void addFirst(E item) { if (item == null) { throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); } stateCount++; Link<E> newLink, temp; if (map.containsKey(item)) { throw new RuntimeException("Chain already contains object."); } if (firstItem != null) { temp = map.get(firstItem); newLink = temp.insertBefore(item); } else { newLink = new Link<E>(item); firstItem = lastItem = item; } map.put(item, newLink); }
public void insertBefore(E toInsert, E point) { if (toInsert == null) throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); if(map.containsKey(toInsert)) throw new RuntimeException("Chain already contains object."); Link temp = map.get(point); if(temp==null) { throw new RuntimeException("Insertion point not found in chain!"); } stateCount++; Link newLink = temp.insertBefore(toInsert); map.put(toInsert, newLink); objectIndexes = null; // RoboVM note: Added }
public void addFirst(E item) { if (item == null) throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); stateCount++; Link newLink, temp; if(map.containsKey(item)) throw new RuntimeException("Chain already contains object."); if(firstItem != null) { temp = map.get(firstItem); newLink = temp.insertBefore(item); } else { newLink = new Link(item); firstItem = lastItem = item; } map.put(item, newLink); objectIndexes = null; // RoboVM note: Added }
public void addFirst(E item) { if (item == null) throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); stateCount++; Link newLink, temp; if(map.containsKey(item)) throw new RuntimeException("Chain already contains object."); if(firstItem != null) { temp = map.get(firstItem); newLink = temp.insertBefore(item); } else { newLink = new Link(item); firstItem = lastItem = item; } map.put(item, newLink); objectIndexes = null; // RoboVM note: Added }
public void insertBefore(E toInsert, E point) { if (toInsert == null) throw new RuntimeException("Bad idea! You tried to insert " + "a null object into a Chain!"); if(map.containsKey(toInsert)) throw new RuntimeException("Chain already contains object."); Link temp = map.get(point); if(temp==null) { throw new RuntimeException("Insertion point not found in chain!"); } stateCount++; Link newLink = temp.insertBefore(toInsert); map.put(toInsert, newLink); objectIndexes = null; // RoboVM note: Added }