DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006

    Best data storage method

    Hey, iv just got a simple problem what would be the best method for storing this type of data

    list of words followed by a list of files the word is contained in e.g

    "hello" ["a.txt","b.txt","c.txt"]
    "ok" ["b.txt","d.txt"]
    "yes" ["a.txt","b.txt"]

    would i use hashset -hashmap or is it possible with arraylist

    which i wish to add to this list when i find another word contained in a file so if the word is new then it gets added otherwise if i word contained in a file such as "ok" in "f.txt" it becomes

    "hello" ["a.txt","b.txt","c.txt"]
    "ok" ["b.txt","d.txt","f.txt"]
    "yes" ["a.txt","b.txt"]

    cheers in advance

  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    Depends on what you want to manipulate when you look for the "word" - if it is a list of all of the files which contain the word, and you are pre-processing the list, then a "graph" structure of a list of lists is what I would go with. When a new file is found with the word, a node with that file name as a value would be added to the list associated with that word ... now, you can organize the words in a hashlist in which the word is the index generating the hash, and the associated object being stored the list of files with a name - if you are going to find more frequently than you are going to be generating your table ...

    If you are adventursome, and want to expand your repertoire, take a look at "tries" ... a perfect use of tries is for a glossary ...
    Last edited by nspils; 03-20-2006 at 04:39 PM.

  3. #3
    Join Date
    Jan 2006


    From what I can gather, you should use a HashMap. use your words as the key and value as a Set/List [use set if you do not want duplicate filenames for the same word and if you need duplicate filenames use a list] of file names in a list.


    String key = "hello"
    String value = "sample.txt"
    Map mapWords = new HashMap();
        List listFiles = mapWords.get(key);
        listFiles.add(value );  
    else {
        List listFiles = new ArrayList();
        mapWords.put(key, listValues); 

Similar Threads

  1. OVERSEAS Online Data Entry Information
    By jai in forum Careers
    Replies: 0
    Last Post: 02-20-2003, 11:43 PM
  2. Is inheritance overrated?
    By Phil Weber in forum .NET
    Replies: 67
    Last Post: 12-15-2002, 01:37 AM
  3. Business layer role in data retrieval - criticisms please
    By Jim in forum Architecture and Design
    Replies: 5
    Last Post: 08-30-2002, 07:49 AM
  4. data and multiple forms
    By skrobism in forum VB Classic
    Replies: 1
    Last Post: 01-23-2001, 10:44 PM
  5. DataGrid - Enter data in a cell at run time
    By William Gaddam in forum VB Classic
    Replies: 1
    Last Post: 05-02-2000, 09:19 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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.