Class MultiMap<K,​V>

java.lang.Object
org.fastily.jwiki.util.MultiMap<K,​V>
Type Parameters:
K - The type of the key
V - The type of the values, which will be stored in an ArrayList.

public class MultiMap<K,​V>
extends Object
A HashMap which allows multiple values for each key. Duplicate values are permitted.
Author:
Fastily
  • Field Summary

    Fields 
    Modifier and Type Field Description
    HashMap<K,​ArrayList<V>> l
    The backing structure for this MapList.
  • Constructor Summary

    Constructors 
    Constructor Description
    MultiMap()
    Constructor, creates an empty MapList.
  • Method Summary

    Modifier and Type Method Description
    void put​(K k, ArrayList<V> vl)
    Merges an ArrayList of V objects into the value set for a given key.
    void put​(K k, V v)
    Adds a key-value pair to this MapList.
    void touch​(K k)
    Creates a new empty ArrayList for k in this MapList if it did not exist already.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • l

      public final HashMap<K,​ArrayList<V>> l
      The backing structure for this MapList. This is public because a getter would just return a reference to this anyways.
  • Constructor Details

    • MultiMap

      public MultiMap()
      Constructor, creates an empty MapList.
  • Method Details

    • touch

      public void touch​(K k)
      Creates a new empty ArrayList for k in this MapList if it did not exist already. Does nothing otherwise.
      Parameters:
      k - The key to create a new entry for, if applicable.
    • put

      public void put​(K k, V v)
      Adds a key-value pair to this MapList.
      Parameters:
      k - The key to add
      v - The value to add
    • put

      public void put​(K k, ArrayList<V> vl)
      Merges an ArrayList of V objects into the value set for a given key.
      Parameters:
      k - The key to use
      vl - The list of values to merge.