Package jadex.commons.collection
Class TwoWayMultiCollection
- java.lang.Object
-
- jadex.commons.collection.MultiCollection
-
- jadex.commons.collection.TwoWayMultiCollection
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map
public class TwoWayMultiCollection extends MultiCollection
The two-way multi-collection allows fast reverse lookup, by containing a second multi-collection, which reversely maps values to keys.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TwoWayMultiCollectionreverseThe reverse multi-collection.-
Fields inherited from class jadex.commons.collection.MultiCollection
map, type
-
-
Constructor Summary
Constructors Modifier Constructor Description TwoWayMultiCollection()Create a two way map.protectedTwoWayMultiCollection(TwoWayMultiCollection reverse)internal constrcutor for connecting two two-way multi-collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object_add(java.lang.Object key, java.lang.Object value)Internal put method, which doesn't affect the reverse collection.protected void_clear()Internal clear method, which doesn't affect the reverse collection.protected java.lang.Object_remove(java.lang.Object key)Internal remove method, which doesn't affect the reverse collection.protected void_remove(java.lang.Object key, java.lang.Object value)Internal remove method, which doesn't affect the reverse collection.java.util.Collection<java.lang.Object>add(java.lang.Object key, java.lang.Object value)Associates the specified value with the specified key in this map (optional operation).voidclear()Removes all mappings from this map.TwoWayMultiCollectiongetReverseMultiCollection()Get the reverse multi-collection.java.util.Collection<java.lang.Object>remove(java.lang.Object key)Removes the mapping for this key from this map if it is present.voidremoveObject(java.lang.Object key, java.lang.Object value)Remove a special object from the collection of a defined key.-
Methods inherited from class jadex.commons.collection.MultiCollection
add, addAll, clone, containsKey, containsValue, createCollection, entrySet, equals, get, getCollection, getKeys, getKeys, getObject, getObjects, getObjects, hashCode, isEmpty, keySet, put, putAll, size, toString, values
-
-
-
-
Field Detail
-
reverse
protected TwoWayMultiCollection reverse
The reverse multi-collection.
-
-
Constructor Detail
-
TwoWayMultiCollection
public TwoWayMultiCollection()
Create a two way map.
-
TwoWayMultiCollection
protected TwoWayMultiCollection(TwoWayMultiCollection reverse)
internal constrcutor for connecting two two-way multi-collection.
-
-
Method Detail
-
getReverseMultiCollection
public TwoWayMultiCollection getReverseMultiCollection()
Get the reverse multi-collection.- Returns:
- The reverse multi-collection.
-
add
public java.util.Collection<java.lang.Object> add(java.lang.Object key, java.lang.Object value)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 mapm.containsKey(k)would return- Overrides:
addin classMultiCollection- Parameters:
key- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- The collection associated to the key.
- Throws:
java.lang.UnsupportedOperationException- if thejava.lang.ClassCastException- if the class of the specified key or value prevents it from being stored in this map.java.lang.IllegalArgumentException- if some aspect of this key or value prevents it from being stored in this map.java.lang.NullPointerException- this map does not permit
-
_add
protected java.lang.Object _add(java.lang.Object key, java.lang.Object value)Internal put method, which doesn't affect the reverse collection.
-
clear
public void clear()
Removes all mappings from this map.- Specified by:
clearin interfacejava.util.Map- Overrides:
clearin classMultiCollection
-
_clear
protected void _clear()
Internal clear method, which doesn't affect the reverse collection.
-
remove
public java.util.Collection<java.lang.Object> remove(java.lang.Object key)
Removes the mapping for this key from this map if it is present. More formally, if this map contains a mapping from key (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)- Specified by:
removein interfacejava.util.Map- Overrides:
removein classMultiCollection- Parameters:
key- key whose mapping is to be removed from the map.- Returns:
- collection associated with specified key, or
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map (optional).java.lang.NullPointerException- if the key is
-
_remove
protected java.lang.Object _remove(java.lang.Object key)
Internal remove method, which doesn't affect the reverse collection.
-
removeObject
public void removeObject(java.lang.Object key, java.lang.Object value)Remove a special object from the collection of a defined key.- Overrides:
removeObjectin classMultiCollection
-
_remove
protected void _remove(java.lang.Object key, java.lang.Object value)Internal remove method, which doesn't affect the reverse collection.
-
-