java data structures
I am fairly new to programming, and am writing a simple GUI address book in java. (This is _not_ any kind of homework problem, just for fun).
I have a simple class called Entry.java, which describes each entry into the address book - name, number, address, comments.
In the main class, Address.java, the GUI is drawn, and action events such as "Add entry", "Delete entry" etc. are handled.
The GUI uses tabs to move between different functions of the address book (as in add, delete, search). The first tab displays the entries by first name, last name, and number, a-c, d-f, etc, each again tabbed (sounds a bit confusing, but is actually easy to work with).
I am currently using java's TreeMap to hold all the entries, because they will be ordered, and give fast look up times. I need them to be ordered so that the panel the panel that displays the lists of names, can simply iterate through each name and decide on which subpanel to draw it to (m-0, or x-z for example).
My question is - how might I handle duplicate entries. I am now using the first name as a key to the TreeMap, so they can be ordered by first name. I need to be able to handle mulitple identical first names. If I map the entries using, say, the phone number, I could have multiple identical first names, but then they won't be in the order.
I think I need use a different data structure, say an ArrayList, and then when I want the panel to display the names in order, dump the ArrayList into something else that can order them. But not sure how I could do this - short of write my own implementation of ArrayList and add an sort() method.
Any ideas would be appreciated.