org.semanticweb.elk.util.collections
Class AbstractHashMultimap<Key,Value>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.semanticweb.elk.util.collections.ArrayHashMap<Key,Collection<Value>>
          extended by org.semanticweb.elk.util.collections.AbstractHashMultimap<Key,Value>
Type Parameters:
Key -
Value -
All Implemented Interfaces:
Map<Key,Collection<Value>>, Multimap<Key,Value>
Direct Known Subclasses:
HashListMultimap, HashSetMultimap

public abstract class AbstractHashMultimap<Key,Value>
extends ArrayHashMap<Key,Collection<Value>>
implements Multimap<Key,Value>

Implementation of Multimap backed by an ArrayHashMap

Author:
Frantisek Simancik

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
 
Fields inherited from class org.semanticweb.elk.util.collections.ArrayHashMap
keys, size, values
 
Constructor Summary
AbstractHashMultimap()
           
AbstractHashMultimap(int i)
           
 
Method Summary
 boolean add(Key key, Value value)
          Stores the key-value pair in this multimap
 boolean contains(Key key, Value value)
          Tests if the key-value pair occurs in this multimap
 Collection<Value> get(Object key)
          Returns the collection of values associated with the given key in this multimap
 Collection<Value> getOld(Object key)
           
protected abstract  Collection<Value> newRecord()
           
 boolean remove(Object key, Object value)
          Removes the key-value pair from this multimap
 
Methods inherited from class org.semanticweb.elk.util.collections.ArrayHashMap
clear, containsKey, containsValue, entrySet, isEmpty, keySet, put, remove, size, values
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, putAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.semanticweb.elk.util.collections.Multimap
clear, isEmpty, keySet
 
Methods inherited from interface java.util.Map
equals, hashCode, putAll
 

Constructor Detail

AbstractHashMultimap

public AbstractHashMultimap()

AbstractHashMultimap

public AbstractHashMultimap(int i)
Method Detail

newRecord

protected abstract Collection<Value> newRecord()

contains

public boolean contains(Key key,
                        Value value)
Description copied from interface: Multimap
Tests if the key-value pair occurs in this multimap

Specified by:
contains in interface Multimap<Key,Value>
Parameters:
key - the key of the pair
value - the value of the pair
Returns:
true if this multimap contains the pair, false otherwise

add

public boolean add(Key key,
                   Value value)
Description copied from interface: Multimap
Stores the key-value pair in this multimap

Specified by:
add in interface Multimap<Key,Value>
Parameters:
key - the key of the pair
value - the value of the pair
Returns:
true if the multimap has changed as a result of the operation, fase otherwise

get

public Collection<Value> get(Object key)
Description copied from interface: Multimap
Returns the collection of values associated with the given key in this multimap

Specified by:
get in interface Map<Key,Collection<Value>>
Specified by:
get in interface Multimap<Key,Value>
Overrides:
get in class ArrayHashMap<Key,Collection<Value>>
Parameters:
key - the key for which to retrieve the values
Returns:
the collection of values associated with the given key in this multimap

getOld

public Collection<Value> getOld(Object key)

remove

public boolean remove(Object key,
                      Object value)
Description copied from interface: Multimap
Removes the key-value pair from this multimap

Specified by:
remove in interface Multimap<Key,Value>
Parameters:
key - the key of the pair
value - the value of the pair
Returns:
true if the multimap has changed as a result of the operation, fase otherwise


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.