How to use Multimaps (Map String, ArrayList String )

I was using an array to store player names, userIDs, uniqueIDs, and frag counts, but after reading about multimaps in the tutorials, it seems that would be much more efficient. However, I guess I don't quite understand it. Here's how I wanted things stored in my string array:
String[] connectedUsers = {"user1_name", "user1_userid", "user1_uniqueid", "user1_frags"
                                        "user2_name"...}and here is how I'm attempting to setup and use the 'multimap':
public class Main {
    static Map<String, ArrayList<String>> connectedUsers;
    public void updatePlayers(String name, String status) {
        String[] statusSplit = status.split(" ");
        if (connectedUsers.containsKey(name)) {
            connectedUsers.put(name, statusSplit[0]);
        else {
            connectedUsers.put(name, statusSplit[0]);
    }It's quite obvious I don't understand how this works, but should I even set this multimap up this way? Perhaps I should use a regular map with a string array for the values?

You're cool MrOldie. Its just that alarm bells start ringing in my head when people come on and post as much as you do.
* Created on Jul 28, 2005 by @author Tom Jacobs
package tjacobs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
* ManyMap is a map that allows more than one value to be stored with any key
* <p>
* There are a number of methods in the class that have been deprecated because
* the original functionality of Map has been violated to accomodate the concept
* of the ManyMap
public class ManyMap<T, T2> implements Map<T, T2> {
     private HashMap<T, ArrayList<T2>> mInnerMap;
     public ManyMap() {
          mInnerMap = new HashMap<T, ArrayList<T2>>();
      * @deprecated
     public T2 get(Object obj) {
          ArrayList<T2> ar = _get(obj);
          if (ar == null || ar.size() == 0) {
               return null;
          return ar.get(0);
     public Iterator<T2> getAll(Object obj) {
          ArrayList<T2> ar = _get(obj);
          if (ar == null || ar.size() == 0) {
               return null;
          return ar.iterator();          
     public T2 put(T obj1, T2 obj2) {
          ArrayList<T2> ar = _getNotNull(obj1);
          ar.add(obj2);
          return obj2;
     public Set<Map.Entry<T, T2>> entrySet() {
          TreeSet<Map.Entry<T, T2>> entries = new TreeSet<Map.Entry<T, T2>>();
          Iterator<T> _i = mInnerMap.keySet().iterator();
          while (_i.hasNext()) {
               T key = _i.next();
               Iterator<T2> vals = mInnerMap.get(key).iterator();
               while (vals.hasNext()) {
                    Entry<T, T2> entry = new Entry<T, T2>(key, vals.next());
                    entries.add(entry);
          return entries;
     public int size() {
          return mInnerMap.size();
     public int valuesSize() {
          int vals = 0;
          Iterator<T> _i = mInnerMap.keySet().iterator();
          while (_i.hasNext()) {
               T key = _i.next();
               ArrayList<T2> ar = mInnerMap.get(key);
               vals += ar.size();
          return vals;
     public void clear() {
          mInnerMap.clear();
     public void putAll(Map<? extends T, ? extends T2> map) {
          Iterator _i = map.entrySet().iterator();
          while(_i.hasNext()) {
               Map.Entry<? extends T, ? extends T2> entry = (Map.Entry<? extends T, ? extends T2>) _i.next();
               put(entry.getKey(), entry.getValue());
     public Collection <T2> values() {
          LinkedList ll = new LinkedList();
          Iterator<ArrayList<T2>> _i = mInnerMap.values().iterator();
          while (_i.hasNext()) {
               ll.addAll(_i.next());
          return ll;
     public boolean containsValue(Object val) {
          Iterator<ArrayList<T2>> values = mInnerMap.values().iterator();
          while (values.hasNext()) {
               if (values.next().contains(val)) return true;
          return false;
     public boolean containsKey(Object key) {
          return mInnerMap.containsKey(key);
     public T2 remove(Object obj) {
          Iterator<ArrayList<T2>> values = mInnerMap.values().iterator();
          boolean found = false;
          while (values.hasNext()) {
               if (values.next().remove(obj)) {
                    found = true;
          return found ? (T2)obj : null;
     public boolean isEmpty() {
          return valuesSize() == 0;
     @SuppressWarnings("hiding")
     private class Entry<T, T2> implements Map.Entry<T, T2> {
          T key;
          T2 val;
          public Entry (T obj1, T2 obj2) {
               key = obj1;
               val = obj2;
          public T2 getValue() {
               return val;
          public T getKey() {
               return key;
          public T2 setValue(T2 obj) {
               return val = obj;
     public Set<T> keySet() {
          return mInnerMap.keySet();
     public ArrayList<T2> _get (Object obj) {
          return mInnerMap.get(obj);
     public ArrayList<T2> _getNotNull (T obj) {
          ArrayList<T2> list = _get(obj);
          if (list == null) {
               list = new ArrayList<T2>(1);
               mInnerMap.put(obj, list);
          return list;
}Edited by: tjacobs01 on Aug 19, 2008 12:28 PM

Similar Messages

  • How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?

    Hi All,
    Hope to you a very happy new year,
    I have two differnt LAP 1300 and 1200 in my network and I need to add theme to the WLC,
    I successed to add one of theme by the option 60 in the DHCP pool at the Core SW,
    So my quetion is below:
    How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?
    Thanks in Advanced,
    Ahmed,

    To add to Scott's post.  Option 60 would be useful if you needed to put certain types of AP on specific controllers.  Otherwise, no real need to use it for the most part.
    Though, I do recall an issue a few years ago that some windows machines had issues getting DHCP if option 43 is being returned.
    Now, on an IOS switch, you can only configure one option 60 per DHCP scope
    HTH,
    Steve
    Please remember to rate useful posts, and mark questions as answered

  • How to use Vector or other ArrayList etc to store my JTree??

    How to use Vector or other ArrayList etc to store my JTree??
    Dear friends,
    I have following I posted before, but not get satisfactory answer, so I modify and repost again here.
    I have following code can add classes and students in the JTree,
    in class Computer Science, it has student Bill Brien,
    in Math, no,
    Then I I add Student Nancy, Laura, Peter into Computer Science Class,
    add AAAA, BBB, CCC into Math class,
    I create a new class called Chemistry, then I add DDD int Chemistry;
    so this JTree is dynamically changed,
    [1]. How can I dynamically save my current JTree with all above tree structure and its nodes in a Vector or ArrayList(not sure which one is best)??
    see code below:
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    public class ModelJTreeTest extends JFrame {
      private JTree tree;
      private DefaultTreeModel model;
      private DefaultMutableTreeNode rootNode;
      public ModelJTreeTest() {
        DefaultMutableTreeNode philosophersNode = getPhilosopherTree();
        model = new DefaultTreeModel(philosophersNode);
        tree = new JTree(model);
        JButton addButton = new JButton("Add Class/Students");
        addButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            addPhilosopher();
        JButton removeButton = new JButton("Remove Selected Class/Students");
        removeButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            removeSelectedPhilosopher();
        JPanel inputPanel = new JPanel();
        inputPanel.add(addButton);
        inputPanel.add(removeButton);
        Container container = getContentPane();
        container.add(new JScrollPane(tree), BorderLayout.CENTER);
        container.add(inputPanel, BorderLayout.NORTH);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400, 300);
        setVisible(true);
      private void addPhilosopher() {
        DefaultMutableTreeNode parent = getSelectedNode();
        if (parent == null) {
          JOptionPane.showMessageDialog(ModelJTreeTest.this, "Select Class", "Error",
              JOptionPane.ERROR_MESSAGE);
          return;
        String name = JOptionPane.showInputDialog(ModelJTreeTest.this, "Add Class/Students:");
        model.insertNodeInto(new DefaultMutableTreeNode(name), parent, parent.getChildCount());
      private void removeSelectedPhilosopher() {
        DefaultMutableTreeNode selectedNode = getSelectedNode();
        if (selectedNode != null)
          model.removeNodeFromParent(selectedNode);
      private DefaultMutableTreeNode getSelectedNode() {
        return (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
      private DefaultMutableTreeNode getPhilosopherTree() {
        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Students");
        DefaultMutableTreeNode ancient = new DefaultMutableTreeNode("Computer Science");
        rootNode.add(ancient);
        ancient.add(new DefaultMutableTreeNode("Bill Brian"));
        DefaultMutableTreeNode math = new DefaultMutableTreeNode("Maths");
        rootNode.add(math);  
        DefaultMutableTreeNode physics = new DefaultMutableTreeNode("Physics");
        rootNode.add(physics);
        return rootNode;
      public static void main(String args[]) {
        new ModelJTreeTest();
    }the actual Tree dynamically created somehow looks like following:
                             |            1.Peter
                             |---CS---    2. Nancy
                             |            3. Laura
                             |            4.Brian
                             |
    Root(University): -------|---Math- 1.AAA
                             |            2.BBB
                             |            3.CCC
                             |
                             |
                             |---Chemistry- 1. DDDThanks a lot
    Good weekends

    you can't directly store a tree in a list.Ummm... Just to be contrary... Yes you CAN store a tree in a table.... In fact that's how the windows file system works.
    Having said that... you would be well advised to investigate tree data-structures before resorting to flattening a tree into a list.
    So... Do you have a specific requirement to produce a List? Your umming-and-erring about Vector vs ArrayList makes it sound like you're still at the stage of choosing a datastructure.
    Cheers. Keith.

  • How to use Google Maps by Visual Composer?

    Hi all,
    I'm creating some simple applications by Visual Composer in which I wanna use a Google Maps in VC,
    and i have now successfully got to the STREET, POSTL_CODE, CITY and COUNTRY came from the BAPI.
    (i am trying to use the Bapi_Customer_Getdetail2.)
    but,i didn't get how to connect Table View and Html View.
    I have already checked the below links. but i fail to understand how to do it.
    Re: Google Map and VC
    Help on google maps
    https://wiki.sdn.sap.com/wiki/display/VC/Using%2bGoogle%2bMaps
    I have many unknowns, could you tell me how to use Google Maps by VC.
    (* About Our VC viersion : SAP NetWeaver Visual Composer EHP1 SP2 for SAP NetWeaver 7.1)

    Some thread are say that create the URL fields. like the below messages.
    The STREET, POSTL_CODE, CITY and COUNTRY come from your BAPI. The other variables url* are default values to create the URL that is requiered for walweb.
    URL1 'http://walweb.nl/walweb/picsfromspace/maps.php?LanguageRadio=dutch&AddressInput='
    URL2 '&ZipcodeInput='
    URL3 '&StateInput=&CitycodeInput=&CityInput='
    URL4 '&CountrySelect='
    URL5 '&ZoomSelect=17&PoiInput=hidden&PoiButton=Interessante+Punten'
    Where should I create those fields? at the Table Vies?
    and also i dont get where should i set the below. is that setting at the [[Map Data]]-[[Assigned Value]]??
    STORE@Url1 & @STREET & STORE@Url2 & @POSTL_CODE & STORE@Url3 & @CITY & STORE@Url4 & @COUNTRY & STORE@Url5
    best regards,
    Masahiro Minagawa

  • How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0).

    Hi,
    I am looking for this document: How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0), and not able to find it.
    Can anybody please point me the location, to look for, or post the document.
    Thanks,
    Namadev

    Hi Namadev Chillal  ,
    These r the links containing PDF docs which u r looking for:
    how to create a flat file out of an IDoc-XML by means of an ABAP mapping program and the J2EE File Adapter.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
    Excellent PDF Document on Mapping
    http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
    Mapping Development with the ABAP Workbench
    http://help.sap.com/saphelp_nw04/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/content.htm
    ABAP Mappings
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm

  • Can somebody post link to How to Use ABAP-Mapping in XI 3.0?

    Hello,
    can somebody post a real link to the document How to Use ABAP-Mapping in XI 3.0. All the links to this documnet in the existing posts are not valid.
    Thanks for your information
    Jayson

    Hi
    Following weblog might help you.
    Testing ABAP Mapping - Testing ABAP Mapping
    XML DOM Processing in ABAP part I -  Convert an ABAP table into XML file using SAP DOM Approach.
    /people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
    SDN TV demo to create and test ABAP mapiing - https://media.sdn.sap.com/SDNTV/main.asp?mediaId=128
    How to guide for ABAP mapping.
    https://websmp106.sap-ag.de/~form/sapnet?_SHORTKEY=01200252310000071155&
    Also check these links,
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm
    Testing ABAP Mapping
    Using ABAP XSLT Extensions for XI Mapping
    Thanks
    Gaurav
    Edited by: Gaurav Bhargava on Oct 9, 2008 6:27 AM

  • How TO Use Java Mapping In XI

    Hi Experts,
    please help me ,
    How TO Use Java Mapping In XI?
    Thanks
    Mahesh

    Hi,
    Just refer the following links for java mapping:-
    1./people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs
    2./people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    Regards,
    Ashwin M
    Reward if helpful

  • How to use image maps in ADF 11g

    Can somebody point me to code snippet for using image maps in JSF Page.
    I just want to use image maps in my application..but i don't know how to use image maps in ADF.
    -Deepti

    Hi chris,
    My DataBase script is given in below
    CREATE TABLE XXSR.SR_HIERARCHY
    FORM_ID NUMBER,
    FORM_NAME VARCHAR2(30 BYTE),
    PARENT_FORM_ID NUMBER,
    FORM_LOCATION VARCHAR2(1000 BYTE),
    IMAGE_FILE ORDSYS.ORDIMAGE
    I want to store the image in database from front end using ADF 11g
    -Deepti
    Edited by: 913387 on Feb 24, 2012 5:36 AM

  • How to use Bex Map??

    Hi
    I'm new to using Bex Map.
    Can anyone explain to me step by step how to use Bex Map.
    I have created a cube in RSA1 already. All the data is loaded.
    I know on the object on the business explorer tab there is things that need to be done there.
    Can someone explain to me how? The steps? Also where does one get the actual maps?
    Will reward anyone that shows me in detail how to do it.
    Thanks in advance

    Hi Louis,
    Check this link might be useful:
    http://help.sap.com/saphelp_nw04/helpdata/en/80/1a65dce07211d2acb80000e829fbfe/frameset.htm
    Also check these links:
    http://help.sap.com/saphelp_nw04/helpdata/en/1a/f405387bcc513be10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/07/79053950c48e05e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/63/79053950c48e05e10000000a114084/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0f709eb-2bbd-2a10-7aa0-d484d344e8ec
    Hope this helps...........
    Rgs,
    I.R.K

  • How to use Nokia maps

    Hi,
    I have Nokia 7510 Supernova Model, I would like to know how to use Nokia maps in it. I tried using Navicore Extenal Bluetooth ( Wayfinder), but i couldnt use it. Is there any way to use maps in Nokia.

    Hi mdmalik
    Provided this isn't a typographic error for 7610 Supernova, unfortunately you cannot use Nokia Maps on your S40 device. You could use application such as Nav4All although you would need to download data with asscociated costs:http://www.nav4all.com/site2/www.nav4all.com/index.php
    Happy to have helped forum in a small way with a Support Ratio = 37.0

  • Explain How to use Structure mapping button

    Hi All
    Iam Developing an application "Implementing and Using Exceptions in Guided Procedures"
    Can you please explain How to use Structure mapping button,
    Plz give me steps in details
    Thanks
    Srinivas

    Hi
    Create a project using 0020 as method.
    Max

  • How to use pre-mapping process operator

    Hi,
    I am using OWB version 10.1.0.4.0.
    There are two source tables namely src1_tb(id1,field1,field2), src2_tb(id2,field3,field4) and a target table namely target_tb(id1,id2,field1,field2,field3,field4).
    It's a simple mapping with a join operator. Here, when I try to use a pre-mapping process operator 'LENGTH', with input from outgroup of join operator (field1) and output linked to an added field( VALUE_LENGTH) in Traget Table, it gives error "VLD-2451: Connection to premapping is invalid" and a warning "VLD-1008 :Referenced mapping column VALUE_LENGTH" does not exist"
    Can anyone please let me know how to use pre-mapping process operator.
    Any help will be greatly appreciated.
    Regards,
    Pawan

    yes, a pre-mapping procedure is not what you want here.
    Pre-mapping procedures run once when the mapping initializes and before the actual ETL is run. IT is a place where you could do some custom data cleansing / validation, populate your own audit loggin tables if you wish, or whatever other things you might like to do.
    For what you are describing, you want to pass the field through an expression object. Drop the Expression on the canvas and drag a link from the field in your OUTGRP to the INGRP on the expression This will auto-create the corresponding ingrp attribute in the expression for that field. Then double-click the expression object to bring up it's properties sheet. You will then want to create an OUTGRP attribute called length_value of type number, and set it's Expression property to length(ingrp1.your_Field_name_here). You can then connect from this outgrp field to your field in the target table.
    Cheers,
    Mike

  • How to use Native SQL String

    Hi all,
    How do i use Native SQL String in the Reciver JDBC Adapter.
    Do i need to change the message format could u suggest me some blogs on the same.
    Also please can anyone let me knw if i can use this for stored procedure.

    hi aditya,
    there shud be no format as such. for sql xml format there are specific structure. but for native sql there shudnt be any specific structure.
    as pointed in sap documentaion:
    Instead of an XML document format, a text is expected that represents any valid SQL statement.
    When inserting a line into a table the corresponding document looks as follows:
    INSERT INTO tableName  (column-name1, column-name2, column-name3) VALUES(‘column-value1’, ‘column-value2’, ‘column-value3’)
    so jus make sure that u give a valid sql statement becoz if will be passed as it is to the database and try ur scenario.
    regards,
    latika.

  • How to use Oracle maps in APEX??

    I am developing one application in APEX 3.2. I need to use Oracle Map for the same.
    How to integrate Oracle maps with Apex ?? Can any one help me for this ?
    Thanks

    Nagesh.Patil wrote:
    Hi All,
    I want to use oracle workflows in my apex application.
    can anybody tell me how can I get this ?
    Thanks in advance..
    Database version : 11g XE
    Apex version : 4.0
    Nagesh Patil
    Oracle Workflow is only available as a component of EBS. It has never been available on, and is not certified for Oracle 11g, nor any version of XE.

  • MAP Toolkit - How to use this MAP tool kit for all SQL Server inventory in new work enviornment

    Hi Every one
     Just joined to new job and planning to do Inventory for whole environment so I can get list of all SQL Server installed . I downloaded MAP tool kit just now. So looking for step by step information to use this for SQL Inventory. If anyone have documentation
    or screen shot and can share would be great.
    Also like to run It will be good to run this tool anytime or should run in night time when is less activity? 
    Hoe long generally takes for medium size environment where server count is about 30 ( Dev/Staging/Prod)
    Also any scripts that will give detailed information would be great too..
    Thank you 
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach A.Shah

    Hi Logicinisde,
    According to your description, since the issue regards Microsoft Assessment and Planning Solution Accelerator. I suggestion you post the question in the Solution Accelerators forums at
    http://social.technet.microsoft.com/Forums/en-US/map/threads/ . It is appropriate and more experts will assist you.
    The Microsoft Assessment and Planning (MAP) Toolkit is an agentless inventory, assessment, and reporting tool that can securely assess IT environments for various platform migrations. You can use MAP as part of a comprehensive process for planning and migrating
    legacy database to SQL Server instances.
    There is more information about how to use MAP Tool–Microsoft Assessment and Planning toolkit, you can review the following articles.
    http://blogs.technet.com/b/meamcs/archive/2012/09/24/how-to-use-map-tool-microsoft-assessment-and-planning-toolkit.aspx
    Microsoft Assessment and Planning Toolkit - Technical FAQ:
    http://ochoco.blogspot.in/2009/02/microsoft-assessment-and-planning.html
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

Maybe you are looking for