• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about TreeMaps, HashMaps etc. ...

 
Daniel Breitner
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,


I have a question regarding my Model implementation (URLyBird Client):

I want to store the Rooms in a certain order but still be able to access them in a fast way.

Right now I am doing the following:

I keep a TreeMap<Integer, Room> which sorts the rooms by their Room Number.

To allow a fast access, I defined a second map

HashMap<Integer, Integer> which maps the Room Numbers in an order that can be accessed by the Table Model.
If the Table Model wants to have the 5th entry it would be like that :

Integer roomNumber = hashmap.get(5)
Room room = treemap.get(roomNumber);


Is this ok, or how did you do it ?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,

First of all: why would you need a map to sort the rooms by room number (recNo)? I don't think a CSR is interested in a recNo, I guess they would be more interested in a sort on name and/or location. I simply used a List to store the rooms and that's it. If in a next release a request to sort the records is asked, I will implement a TableRowSorter for example. But now that's not needed, so simple don't do it.
Here you can read some details about my approach with the List.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic