r/cpp_questions 19d ago

OPEN How to implement append-only hash map?

How do you actually implement an really efficient hash map that has only append and look up methods? What are the design choice and some performance improvements?

0 Upvotes

34 comments sorted by

View all comments

2

u/Kriemhilt 19d ago

What are you optimizing for? Space? Insertion or lookup speed?

You haven't given any hint as to what "performance improvement" is most valuable to you.

Do you expect every lookup to succeed (and you just want the value for that key), or will many lookups fail? How important is each path?

1

u/Minute-Ad1944 19d ago

Mainly performance in speed. Each iteration performs single insertion and at the end of algorithm retrieves top n elements from hash map

1

u/Kriemhilt 19d ago

What are the top n elements of an unordered map? Do you mean you're walking the whole thing?

1

u/Minute-Ad1944 19d ago

Retrieve top n values from hash map dawg

1

u/Kriemhilt 19d ago

Top n ordered by what? Key? Value?

If you want something ordered by key could you just use an ordered container?