To have an Integer pointing to 3 ordered lists in Java

Posted by Masi on Stack Overflow See other posts from Stack Overflow or by Masi
Published on 2010-03-08T20:18:12Z Indexed on 2010/03/08 20:21 UTC
Read the original article Hit count: 424

Filed under:
|
|
|
|

Which datastructure would you use in the place of X to have efficient merges, sorts and additions as described below?

#1 Possible solution: one HashMap to X -datastructure

Having a HashMap pointing from fileID to some datastructure linking word, wordCount and wordID may be a good solution. However, I have not found a way to implement it.


I am not allowed to use Postgres or any similar tool to keep my data neutralized. I want to have efficient merges, sorts and additions according to fileID, wordID or wordCount for the type below.


I have the type Words which has th field fileID that points to a list of words and to relating pieces of information:

The Type

class Words
===================================
fileID: int 
[list of words] : ArrayList
[list of wordCounts] : ArrayList
[list of wordIDs] : ArrayList

Example of the data in

fileID   word   wordCount   wordID
      instance1 of words
1        He     123         1111
1        llo    321         2
      instance2 of words
2        Van    213         666
2        cou    777         932

Example of needed merge

fileID     wordID                 fileID     wordID
1          2
1          3           wordID=2
2          2           ========>  1          2
2          3                      2          2 

I cannot see any usage of set-operations such as intersections here because order is needed.

Having about three HashMaps makes sorting difficult:

  1. from word to wordID in a given fileID
  2. from wordID to fileID
  3. from wordID to wordCount in a given fileID

© Stack Overflow or respective owner

Related posts about merge

Related posts about sorting