public Object put(Object key, Object value) { if (key_chain.contains(key)) { kc.remove(key); if (kc.isEmpty()) { value_chain.remove(old_value); back_map.remove(old_value); kc = new HashChain(); back_map.put(value, kc); value_chain.add(value); kc.add(key); key_chain.add(key); content_map.put(key, value); kc = new HashChain(); back_map.put(value, kc); value_chain.add(value); kc.add(key);
@Override public void swapWith(E out, E in) { insertBefore(in, out); remove(out); }
public Mapping_Iterator(HashChain c, HashMap<Object, Object> m) { it = c.iterator(); this.m = m; }
public boolean containsKey(Object key) { return key_chain.contains(key); }
/** * <p> * Returns an iterator ranging from <code>head</code> to <code>tail</code>, inclusive. * </p> * * <p> * If <code>tail</code> is the element immediately preceding <code>head</code> in this <code>HashChain</code>, the returned * iterator will iterate 0 times (a special case to allow the specification of an empty range of elements). Otherwise if * <code>tail</code> is not one of the elements following <code>head</code>, the returned iterator will iterate past the * end of the <code>HashChain</code>, provoking a {@link NoSuchElementException}. * </p> * * @throws NoSuchElementException * if <code>head</code> is not an element of the chain. */ @Override @SuppressWarnings("unchecked") public Iterator<E> iterator(E head, E tail) { if (firstItem == null || isEmpty()) { return (Iterator<E>) emptyIterator; } if (head != null && this.getPredOf(head) == tail) { return (Iterator<E>) emptyIterator; } return new LinkIterator<E>(head, tail); }
public boolean remove(Object o) { if (value_chain.contains(o) == false) { return false; } HashChain c = (HashChain) IterableMap.this.back_map.get(o); Iterator it = c.snapshotIterator(); while (it.hasNext()) { Object ko = it.next(); if (IterableMap.this.content_map.get(o) == null) { IterableMap.this.remove(ko); } else if (IterableMap.this.remove(ko) == null) { return false; } } return true; }
@Override public void insertBefore(Chain<E> toInsert, E point) { insertBefore((Collection<E>) toInsert, point); }
@Override public void insertAfter(List<E> toInsert, E point) { insertAfter((Collection<? extends E>) toInsert, point); }
public boolean isEmpty() { return key_chain.isEmpty(); }
public boolean add(T o) { if (o == null) { throw new IllegalArgumentException("Cannot add \"null\" to an IterableSet."); } if (contains(o)) { return false; } return super.add(o); }
/** Adds the given object to this HashChain. */ @Override public boolean add(E item) { addLast(item); return true; }
/** <p>Returns an iterator ranging from <code>head</code> to * <code>tail</code>, inclusive.</p> <p>If <code>tail</code> is the element immediately preceding <code>head</code> in this <code>HashChain</code>, the returned iterator will iterate 0 times (a special case to allow the specification of an empty range of elements). Otherwise if <code>tail</code> is not one of the elements following <code>head</code>, the returned iterator will iterate past the end of the <code>HashChain</code>, provoking a {@link NoSuchElementException}.</p> @throws NoSuchElementException if <code>head</code> is not an element of the chain. */ public Iterator<E> iterator(E head, E tail) { if (head != null && this.getPredOf(head) == tail) { // special case hack, so empty ranges iterate 0 times return new LinkIterator(null, null); } else { return new LinkIterator(head, tail); } }
public PegCallGraph(CallGraph cg) { clinitMethods = new HashSet(); chain = new HashChain(); heads = new ArrayList(); tails = new ArrayList(); methodToSuccs = new HashMap(); methodToPreds = new HashMap(); methodToSuccsTrim = new HashMap(); // buildfortest(); buildChainAndSuccs(cg); // testChain(); // testMethodToSucc(); buildPreds(); // trim(); BROKEN // testMethodToPred(); // testClinitMethods(); }
public Iterator iterator() { return value_chain.iterator(); }
public boolean containsValue(Object value) { return value_chain.contains(value); }