File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

search for a value within list of HashMaps

 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

:roll:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic