Dear All, can u pls give me the efficient way to solve this. i am having an List in which array of HashMap's. Ex: = List lst = new ArrayList(); HashMap hm = new HashMap(); //say we added some data to this <k,v> - <"no","001"><"subno","01"> etc All the hashmap data contains like this same structure.
here i want to get the HashMap in which the no=001 and subno=01 within the List.how can do this in an efficient way. one thing we can do is get the length of the List and iterate thru the loop. better if we can have some other solution. Thanks & regards, Mahesh
Originally posted by Mahesh Pinnamaneni: ...one thing we can do is get the length of the List and iterate thru the loop...
It seems that you're looking for a way to quickly find a particular HashMap within an ArrayList. Can you store the HashMaps within another HashMap instead of an ArrayList?
If that's not feasible, then you might consider building some sort of quick-lookup object (perhaps containing another HashMap as a "lookup table") with a method to return the desired HashMap's index in the ArrayList. But how "efficient" this might be depends on a lot of variables. In the end, you might be better off iterating through the ArrayList.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org