HashSet of Strings taking up too much memory, suggestions…?

前端 未结 8 1846
闹比i
闹比i 2020-12-29 08:44

I am currently storing a list of words (around 120,000) in a HashSet, for the purpose of using as a list to check enetered words against to see if they are spelt correctly,

8条回答
  •  旧时难觅i
    2020-12-29 09:43

    The problem is by design: Storing such a huge amount of words in a HashSet for spell-check-reasons isn't a good idea:

    You can either use a spell-checker (example: http://softcorporation.com/products/spellcheck/ ), or you can buildup a "auto-wordcompletion" with a prefix tree ( description: http://en.wikipedia.org/wiki/Trie ).

    There is no way to reduce memory-usage in this design.

提交回复
热议问题