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 TwoWayMultiCollection
reverse
The 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.protected
TwoWayMultiCollection(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).void
clear()
Removes all mappings from this map.TwoWayMultiCollection
getReverseMultiCollection()
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.void
removeObject(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:
add
in 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:
clear
in interfacejava.util.Map
- Overrides:
clear
in 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:
remove
in interfacejava.util.Map
- Overrides:
remove
in 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:
removeObject
in classMultiCollection
-
_remove
protected void _remove(java.lang.Object key, java.lang.Object value)
Internal remove method, which doesn't affect the reverse collection.
-
-