Matching a string in a Large text file?

前端 未结 2 1554
囚心锁ツ
囚心锁ツ 2021-02-03 13:03

I have a list of strings containing about 7 million items in a text file of size 152MB. I was wondering what could be best way to implement the a function that takes a single

2条回答
  •  名媛妹妹
    2021-02-03 13:38

    Depends what you want to do. When you want to repeat the search for matches again and again, I'd load the whole file into memory (into a HashSet). There it is very easy to search for matches.

提交回复
热议问题