Basically I have a dictionary containing all the words of my dictionary in the form of keys, and all with 0 as the value.
To process the document in the form of a bag with the representation of words, I used to copy this dictionary with the corresponding IEqualityComparer and simply checked whether the dictionary contains every word in the document and increases its key.
To get an array of words with a bag, I just used the ToArray method.
It seemed that everything worked fine, but I was told that the dictionary does not guarantee the same order of keys, so the resulting arrays can represent the words in a different order, which makes it useless.
My current idea to solve this problem is to copy all the dictionary keys into an ArrayList, create an array of the required size, and then use the indexOf method to list the arrays to populate the array.
So my question is, is there a better way to solve this problem, it seems to me rude ... and will I have problems because of IEqualityComparer?
source
share