Efficient way to store strings

Suppose I have millions of lines. Each line has an int value. I want to get this value from the input line, but I do not want to store all these lines, because they take up a lot of space. I cannot use a hash table due to the need to store all or at least many rows in memory. So, what is a good data structure for my case (I do not need to add or delete any rows, I already have prepared data, and reading is allowed only)

+5
source share
4 answers

Use trie to prevent storing regular substrings.

+4
source

, , CMPH. (gperf , .)

CMPH:

- n m , m n. m n, .

...

CMPH , , API. , . - 100 ,...

+2

Judy, , , , , sourceforge.

+1

Your reason for not using a hash table is not true based on the limited information in your question at present. It is quite effective if used well. It may also have the advantage of not wasting memory saving duplicate strings if this is acceptable for your needs, which further reduces memory consumption if duplicate strings are possible.

Perhaps you can also store the concise form of each row in a hash table if you were oriented on how you perform the search. How many lines are usually?

0
source

All Articles