String to BitSet Conversion

Hello all,

I have been trying to find an efficient way to convert some strings into Bitsets in Java. Unfortunately I'm having trouble mapping the string character values to the Bitsets. Currently I read in all of the Strings which reside in a text file in the format:

a b c f

c d

a d

etc.

I then tokenise the whole file and count the occurrence of each character, put them in an ArrayList and then sort the ArrayList such that the char 'a' (in this case)appears at the top of the list followed by 'b', then 'c' and so on.

The problem I have is how do I map the character 'a' to bit (0) of a BitSet 'b' to bit(1) etc. The easy way to do this would be just to read in each line of text and then assign them in that order but if we examine the above example the char 'd' doesn't appear until line 2 and 'f' has already been mapped to bit (4).

Any help appreciated,

N

[941 byte] By [niall7890a] at [2007-10-1 21:47:51]
# 1
It's not at all clear what you're doing, or what your problem is. Why can't you just map each character to the bit corresponding to its ASCII code?
YAT_Archivista at 2007-7-13 7:50:38 > top of Java-index,Other Topics,Algorithms...