net.cscott.jutil

Class AbstractMultiMap<K,V>

public abstract class AbstractMultiMap<K,V> extends AbstractMap<K,V> implements MultiMap<K,V>

This class provides a skeletal implementation of the MultiMap interface, to minimize the effort requires to implement this interface.

Version: $Id: AbstractMultiMap.java,v 1.5 2006-10-30 21:58:57 cananian Exp $

Author: C. Scott Ananian

Method Summary
booleanadd(K key, V value)
Ensures that this contains an association from key to value.
booleanaddAll(K key, Collection<? extends V> values)
Adds to the current mappings: associations for key to each value in values.
booleanaddAll(MultiMap<? extends K,? extends V> mm)
Add all mappings in the given multimap to this multimap.
abstract voidclear()
abstract booleancontains(Object a, Object b)
booleancontainsKey(Object key)
booleancontainsValue(Object value)
abstract MultiMapSet<K,V>entrySet()
booleanequals(Object o)
Vget(Object key)
abstract Collection<V>getValues(K key)
inthashCode()
booleanisEmpty()
Vput(K key, V value)
Associates the specified value with the specified key in this map.
voidputAll(Map<? extends K,? extends V> t)
Copies the mappings from the specified map to this map.
abstract Vremove(Object key)
abstract booleanremove(Object key, Object value)
booleanremoveAll(K key, Collection<?> values)
Removes from the current mappings: associations for key to any value in values.
booleanretainAll(K key, Collection<?> values)
Removes from the current mappings: associations for key to any value not in values.
intsize()
StringtoString()

Method Detail

add

public boolean add(K key, V value)
Ensures that this contains an association from key to value. (MultiMap specific operation).

Returns: true if this mapping changed as a result of the call

addAll

public boolean addAll(K key, Collection<? extends V> values)
Adds to the current mappings: associations for key to each value in values. (MultiMap specific operation).

Returns: true if this mapping changed as a result of the call

addAll

public boolean addAll(MultiMap<? extends K,? extends V> mm)
Add all mappings in the given multimap to this multimap.

clear

public abstract void clear()

contains

public abstract boolean contains(Object a, Object b)

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

entrySet

public abstract MultiMapSet<K,V> entrySet()

equals

public boolean equals(Object o)

get

public V get(Object key)

getValues

public abstract Collection<V> getValues(K key)

hashCode

public int hashCode()

isEmpty

public boolean isEmpty()

put

public V put(K key, V value)
Associates the specified value with the specified key in this map. If the map previously contained any mappings for this key, all of the old values are replaced. Returns some value that was previous associated with the specified key, or null if no values were associated previously.

putAll

public void putAll(Map<? extends K,? extends V> t)
Copies the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map. Note that putAll(mm) where mm is a MultiMap will NOT add all of the mappings in mm; it will only add all of the Keys in mm, mapping each Key to one of the Values it mapped to in mm. To add all of the mappings from another MultiMap, use addAll.

remove

public abstract V remove(Object key)

remove

public abstract boolean remove(Object key, Object value)

removeAll

public boolean removeAll(K key, Collection<?> values)
Removes from the current mappings: associations for key to any value in values. (MultiMap specific operation).

Returns: true if this mapping changed as a result of the call

retainAll

public boolean retainAll(K key, Collection<?> values)
Removes from the current mappings: associations for key to any value not in values. (MultiMap specific operation).

Returns: true if this mapping changed as a result of the call

size

public int size()

toString

public String toString()
Copyright (c) 2006 C. Scott Ananian