ZeNo
ZeNo

Reputation: 1658

Efficient Data structure which supports search on 2 keys of Node

Suppose I have my node structure as:

struct Employee
{
int age;
int salary;
string title;
...
}

I wanted an efficient data structure by which I can do search query based on age as well as salary. Can somebody suggest me some god data structure for that.

Upvotes: 1

Views: 163

Answers (1)

Andrey
Andrey

Reputation: 60055

This question can be solved in general way. If you have collection of objects and want to have fast access by two or more attributes then create indexes. It is like having list and two dictionaries (sorted lists, etc.) to index elements in original list. But you have to manage consistency of this bundle.

Upvotes: 1

Related Questions