Jump to content
Sign in to follow this  
PolywickStudio

Does this data structure exist? TDataStructure<TKey, TKey, TValue, TPayLoad> ?

Recommended Posts

I have question.

 

I need a data structure that looks like this:

 

DataStructure<TKey1, TKey2, TValue, TPayLoad>

 

Where

 

- there the data is sorted by 2 keys.

- the value can be any (e.g., integer, string).

- there is a ternary Payload which stores non-sorted data.

 

I want to the data to have 2 primary key indexes, TKey1 or TKey2.

 

I query TKey1 = '1', I get all values of (TKey1 = 1) for the data.

I query TKey2 = '2', I get all values of (TKey2 = 1) for the data.

 

Problem.

1. I use TDictionary and THashList, Not sure how to store TKey1, TKey2, and TValue1 with TPayLoad.

I could use TDictionary<TPair<TKey1, TKey2>, TPair(TValue1, TPayload>);

- how to search by partial, where I special only one part of TPair?

 

2. I tried TObjectList, I cannot order by TKey2, just TKey1 and store everything inside an Object.

It gets slow trying to do filtered-search and retrieve filtered by TKey1 or TKey2.

 

3. I tried TList, but I want to get an order by TKey1 and TKey2, I need to keep sorting it as often.

 

4. I need to keep TKey1, TKey2 as ordered lists to quickly index/query TValue.

 

Any ideas?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post

tDictionary alone will not allow you to store more values for the same key (it seems you need it: "I get all values of (TKey1 = 1) for the data. ").

You could use two dictionaries:

tDictionary<tKey1, tObjectList>

tDictionary<tKey2, tObjectList>

 

In these object lists, there will be all objects with corresponding values of the tKey1, resp. tKey2.

 

Edited by Vandrovnik

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×