[solved]Implementation with multiple values for each key?

Discussion in 'Plugin Development' started by civ77, Jan 27, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    civ77

    Is there a Collection Implementation which can store multiple values for a single key? (It doesn't matter what the key is or how it is assigned.)
     
  2. Offline

    nisovin

    Create a new class that stores all the values, then use a normal Map.
     
  3. how about:
    Code:
    Map<String, List<Object>> multipleValuesForSingleKey;
    ?
     
    civ77 likes this.
  4. Offline

    civ77

    how do I get the information that are in the lists?
     
  5. depending if you just want to store values and iterate through them or if they should have a key themselves.
    Code:
    for(Object listObject : multipleValuesForSingleKey.get(keyForList))
    {
      // do whatever with the object...
    }
    otherwise you could do that:
    Code:
    Map<String, Map<String, String>> multipleValuesForSingleKeyWithSubKeys;
    but thats not really efficient. Another way would be the one nisovin mentioned.
     
Thread Status:
Not open for further replies.

Share This Page