/** * Create a two way map. */ public TwoWayMultiCollection() { this.reverse = new TwoWayMultiCollection(this); }
Collection coll = getCollection(key); for(Iterator i=coll.iterator(); i.hasNext(); ) reverse._remove(i.next(), key);
/** * Remove a special object from the * collection of a defined key. */ public void removeObject(Object key, Object value) { reverse._remove(value, key); super.removeObject(key, value); }
/** * Removes all mappings from this map. */ public void clear() { super.clear(); reverse._clear(); }
/** * Associates the specified value with the specified key in this map * (optional operation). If the map previously contained a mapping for * this key, the old value is replaced by the specified value. (A map * <tt>m</tt> is said to contain a mapping for a key <tt>k</tt> if and only * if {@link #containsKey(Object) m.containsKey(k)} would return * <tt>true</tt>.)) * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return The collection associated to the key. * * @throws UnsupportedOperationException if the <tt>put</tt> operation is * not supported by this map. * @throws ClassCastException if the class of the specified key or value * prevents it from being stored in this map. * @throws IllegalArgumentException if some aspect of this key or value * prevents it from being stored in this map. * @throws NullPointerException this map does not permit <tt>null</tt> * keys or values, and the specified key or value is * <tt>null</tt>. */ public Collection<Object> add(Object key, Object value) { reverse._add(value, key); return super.add(key, value); }