Please suggest a data structure for representing a list of records in memory
. Each record is made up of:
- User Name
- Points
- Rank (based on Points) - optional field - can be either stored in the record or can be computed dynamically
The data structure should support implementation of the following operations efficiently:
- Insert(record) - might change ranks of existing records
- Delete(record) - might change ranks of existing records
- GetRecord(name) - Probably a hash table will do.
- GetRecord(rank)
- Update(points) - might change ranks of existing records
My main problem is efficient implementation of GetRecord(rank), because ranks can change frequently.
I guess an in-memory DBMS
would be a good solution, but please don't suggest it; please suggest a data structure.