Re: Generics for a multiplevalue hashmap
 
Alexis Berry <iamrichardjones@gmail.com> writes:
public class MultipleValueHashMap<T, java.util.List<U>> implements Map<T, java.util.List<U>> {
  I'd just use:
Multimap<D,V>
  . When you just implement Map, not HashMap, then why use
  ?Hash? in the name of the class?
  Also, you do not want to implement the map interface, but
  your custom interface, so why do you want to announce that
  you implement Map via an ? implements ? clause at all?
  D is the domain.
  V is the type of the values.
add(d,v) adds the value v to the set of d
  You need to decided whether you want a set or a bag.
  When you use a bag, then ?add(d,v);add(d,v);? will
  increment the multiplicity of v by 2. If you use a
  set, ?add(d,v);add(d,v);? is the same as ?add(d,v);?.
  You could be more flexible with a delegate for the
  collection:
class Multimap<D,V>
{ public Multimap( Container c, ... ){ ... } ... }
  In this case
add(d,v)
  will add v to the container of d (it will create a new
  container, if such a container does not exist yet), using
  the add method of this container, whatever this add method
  does.