Find equivalence classes from n-line text file

48 views Asked by At

I have a n-line text file:

1st: 1,2,...1,1

2nd: 1,2,...0,1

3rd: 2,1,...,1,0

4th: 2,2,....,0,1

....

n th:1,2,....,1,1

Each line has 40 numbers, divided by comma. These numbers are indexed from 1 to 40. E.g the 1st line 1,2,...0,1; 1 is indexed 1, 2 is indexed 2, 0 is indexed 39, the last 1 is indexed 40.

I want to create equivalence classes for each index, e.g.

index 1: [1st,2nd][3rd,4th][nth]

index 2: [1st,2nd,4th,nth][3rd]

index 39:[1st,3rd,nth][2nd,4th]

index 40:[1st,2nd,4th,nth][3rd]

I am thinking of using HashMap<Integer,List<String>> but by this way, I need to maintain 40 arraylists in memory. This is difficult because the text file is a little big (n = millions of lines)

Since I am new to Java, I do not know if the above way is efficient or not? Or is there any better way to achieve that. Only idea is sufficient.

Thank you very much.

0

There are 0 answers