Results 1 to 3 of 3
  1. #1
    lumpy is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Default Which data structure to choose ?

    Hello!

    I need some help about choosing the right data structure for my program.

    I have a file with a few thoushand of lines, representing properties of characters (1 line = 1 character). There is the unicode, the UTF-8 code, and other stuff on the same line.
    Now, I need to display these chars one at a time in my GUI and would like to be able, from one char displayed, to display the one before or the one after (by clicking on a forward arrow, or backward arrow). Also, I would like to jump randomly from one to another one.

    Which data structure should I use ? ArrayList ? Linkedlist ? Or a map like hashmap maybe ? I really don't know which one is the best.

    I thought maybe that linkedlist could be good since I want to get the "previous" and the "next" from a given position.

    What's your opinion ?

    Thank you very much people!

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    A List is a good idea if you are moving forwards and backwards sequentially.

    I'm not sure what you mean by "randomly". If you want - for instance - to be able to jump to the information for a particular character, then that suggests a Map of some sort where the character is the Key. There are NavigableMap collections which combine both ideas.

  3. #3
    lumpy is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

Similar Threads

  1. data structure and data base??
    By ahmed13 in forum Advanced Java
    Replies: 8
    Last Post: 03-27-2009, 06:48 AM
  2. data file structure
    By Nicholas Jordan in forum Advanced Java
    Replies: 2
    Last Post: 01-07-2009, 05:16 AM
  3. Stack data structure in Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:34 PM
  4. Queue data structure
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:35 PM
  5. data structure code
    By vgvt in forum New To Java
    Replies: 1
    Last Post: 01-17-2008, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •