Wednesday, 26 September 2012

MultiKeyMap

It uses multiple keys to store the value.

This MultiKeyMap is not synchronized and is not thread-safe.

Add the jar "commons-collections-3.2.1.jar".

Example is :


MultiKeyMap multiKeyMap = new MultiKeyMap();
multiKeyMap.put("DocumentName","DocumentRef","DocumentAuthor");
multiKeyMap.put("DocumentName1","DocumentRef1","DocumentAuthor1");
multiKeyMap.put("DocumentName2","DocumentRef2","DocumentAuthor2");
multiKeyMap.put("DocumentName3","DocumentRef3","DocumentAuthor3");

// later retireve the value
System.out.println(multiKeyMap.get("DocumentName","DocumentRef"));  
System.out.println(multiKeyMap.get("DocumentName1","DocumentRef1"));
System.out.println(multiKeyMap.get("DocumentName2","DocumentRef2"));
System.out.println(multiKeyMap.get("DocumentName3","DocumentRef3"));

the output is :


DocumentAuthor
DocumentAuthor1
DocumentAuthor2
DocumentAuthor3

No comments:

Post a Comment