@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); }
@Override public E getPredOf(E point) throws NoSuchElementException { Link<E> link = map.get(point); if (point == null) { throw new RuntimeException("trying to hash null value."); } try { link = link.getPrevious(); } catch (NullPointerException e) { throw new NoSuchElementException(); } if (link == null) { return null; } else { return link.getItem(); } }
public void addLast(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: " + item); if(lastItem != null) { temp = map.get(lastItem); newLink = temp.insertAfter(item); } else { newLink = new Link(item); firstItem = lastItem = item; } map.put(item, newLink); objectIndexes = null; // RoboVM note: Added }
public void addLast(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: " + item); if(lastItem != null) { temp = map.get(lastItem); newLink = temp.insertAfter(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 E getPredOf(E point) throws NoSuchElementException { Link<E> link = map.get(point); if(point == null) throw new RuntimeException("trying to hash null value."); try { link = link.getPrevious(); } catch (NullPointerException e) { throw new NoSuchElementException(); } if(link == null) return null; else return link.getItem(); }
public E getPredOf(E point) throws NoSuchElementException { Link<E> link = map.get(point); if(point == null) throw new RuntimeException("trying to hash null value."); try { link = link.getPrevious(); } catch (NullPointerException e) { throw new NoSuchElementException(); } if(link == null) return null; else return link.getItem(); }
public void remove() throws IllegalStateException { if(stateCount != iteratorStateCount) throw new ConcurrentModificationException(); stateCount++; iteratorStateCount++; if(!state) throw new IllegalStateException(); else { currentLink.unlinkSelf(); map.remove(currentLink.getItem()); state = false; HashChain.this.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 }
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 remove() throws IllegalStateException { if(stateCount != iteratorStateCount) throw new ConcurrentModificationException(); stateCount++; iteratorStateCount++; if(!state) throw new IllegalStateException(); else { currentLink.unlinkSelf(); map.remove(currentLink.getItem()); state = false; HashChain.this.objectIndexes = null; // RoboVM note: Added } }
public void insertAfter(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."); stateCount++; Link temp = map.get(point); Link newLink = temp.insertAfter(toInsert); map.put(toInsert, newLink); objectIndexes = null; // RoboVM note: Added }
public void insertAfter(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."); stateCount++; Link temp = map.get(point); Link newLink = temp.insertAfter(toInsert); map.put(toInsert, newLink); objectIndexes = null; // RoboVM note: Added }
public void removeLast() { stateCount++; Object item = lastItem; map.get(lastItem).unlinkSelf(); map.remove(item); objectIndexes = null; // RoboVM note: Added }