permute data for a HashMap in Java

Posted by tuxou on Stack Overflow See other posts from Stack Overflow or by tuxou
Published on 2010-05-07T21:53:59Z Indexed on 2010/05/07 21:58 UTC
Read the original article Hit count: 191

Filed under:
|
|

hi

i have a linkedhashmap and i need to permute (change the key of the values) between 2 random values

example :

key 1 value 123 key 2 value 456 key 3 value 789

after random permutation of 2 values

key 1 value 123 key 2 value 789 key 3 value 456

so here I permuted values between key 2 and key 3

thank you;

sample of the code of my map :

    Map map = new LinkedHashMap();
        map =myMap.getLinkedHashMap();

       Set key = map.keySet();

   for(Iterator it = cles.iterator(); it.hasNext();)
    {
        Integer cle =  it.next(); 
        ArrayList values = (ArrayList)map.get(cle);//an arrayList of integers

        int i = 0;
        while(i < values.size())
        {
            //i donno what to do here
            i++;
        }
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about hashmap