Hi Ami

You cannot optimize your search on a range of "values" of a Map object. All you can do is to scan the whole map in sequence.

In order to optimize the search you would need some structure (such a list or a binary tree) where the values are stored sorted (or the binary tree equivalent of sorted). Then perform some binary searches to find the boundaries, then scan only the values between the boundaries (and find the associated keys).

If you really need a Map based on the names and a way to optimize the search, then use two different collections:
--> the Map based on the names
--> a collection in which the values are sorted, based on the values and not on the keys

Hope it helps
Mihai


On 07/01/2012 03:39, ABHISHEK TRIPATHI wrote:
Hey Dev,
I'm facing probem with the Hashmap, can you please help on this ?

HashMap:

Key= collection of Student Names( A,B,C,D,A,D,Q)

Values= Marks (ex. 88,34,53,12,44,56,78,87,54)

Can you please advise best way to get all the Students who have marks between 55 to 65?
thanks,
Ami

--
You received this message because you are subscribed to the Google Groups "JPassion.com: Java Programming" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jpassion_java?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jpassion_java?hl=en.

Reply via email to