Results 1 to 6 of 6
Thread: collection issue
- 02-07-2011, 08:15 AM #1
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
collection issue
hi friends
i want to store employee data in a collection sorted with employee name. also i want to fetch employees with name starting with a given character.
(for character scroll in window)
i tried TreeMap with Structure <Character, Employee>. but it fails to add duplicate entries for a given character.
i thought of using subset() method of TreeMap to fetch all Employees with a given character.
how to handle this?
thanks in advance.......
- 02-07-2011, 08:58 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Of course it does (fail that is) as that is how maps work. Simply loop through your list and check the names.
- 02-07-2011, 09:09 AM #3
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
any other solution?
- 02-07-2011, 09:13 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Maps and Sets require unique keys; the first character of a name doesn't make a unique key (not even the entire name makes a unique key); possibly you have to create a unique key given the empoyee ID as the minor comparison part, i.e. <name, ID> forms the unique key. Sorted Sets and Maps can iterate over sub sets and maps ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 02-07-2011, 09:15 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
- 02-07-2011, 11:47 AM #6
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
Similar Threads
-
Help me on Collection
By kathir0301 in forum New To JavaReplies: 1Last Post: 12-03-2010, 12:08 PM -
collection
By D.Calladine in forum New To JavaReplies: 1Last Post: 12-02-2010, 03:36 PM -
help for collection api
By javastuden in forum New To JavaReplies: 3Last Post: 02-24-2010, 12:52 PM -
collection framework
By swati.jyoti in forum New To JavaReplies: 8Last Post: 09-01-2009, 04:45 PM -
How to get NamingEnumeration from my collection?
By hencre in forum Advanced JavaReplies: 1Last Post: 10-18-2008, 09:01 PM
Bookmarks