| Author |
getting values from linkedHashMap
|
kavuri
Greenhorn
Joined: Sep 30, 2008
Posts: 2
|
|
I have a scenario in my project where i need a collection which don't accept dulicate values and orderd.Then i apparently went for LinkedHashMap.But while i getting values from map i used map.keySet() to get the keys.Thst keys were unordred as set was unordered. How can we get the values from LinkedHashMap in insertion order
|
 |
Nitesh Kant
Bartender
Joined: Feb 25, 2007
Posts: 1638
|
|
Howdy "vamsi"! Welcome to javaranch! We being a very friendly community, do not have much rules but there is a naming policy that we are very strict about! Unfortunately, your display name does not follow the policy. Please change the same according to our policy.
Are you sure that you did not get the keys in the insertion order? By any chance, have you used this constructor with the last argument as "true". If yes, then the map will have entries in the access order. [ October 15, 2008: Message edited by: Nitesh Kant ]
|
apigee, a better way to API!
|
 |
Maurizio Nagni
Ranch Hand
Joined: May 29, 2004
Posts: 75
|
|
Dear Vamsi, could you please better explain your task? You say 1)
i need a collection which don't accept dulicate values and orderd
......in this case ordering is a property given by the Comparable interface 2)
...... in this case LinkedHasMap work as you ask (anyway same key will remain in the same position not promoted in a higher position) so, before of all, which are your needs?
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by vamsi: I have a scenario in my project where i need a collection which don't accept dulicate values and orderd.Then i apparently went for LinkedHashMap.
Actually, this sounds like you might want to use a LinkedHash*Set* instead.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: getting values from linkedHashMap
|
|
|