Sachin
Sachin

Reputation: 173

what can be the best data structure to hold recursive, multi valued and repeated key-value paired data?

Basically its loading of xml data but it has following 3 properties to be satisfied

  1. repetitive (key value pair can repeat)
  2. multivalued (single key have multiple value)

In both cases I need to preserve the order of data.

Upvotes: 3

Views: 275

Answers (4)

Alexandre C.
Alexandre C.

Reputation: 56956

It depends on your complexity requirements (or your expected data complexity), but I used once a multimap<Key, list<Value> > for some project.

Upvotes: 1

Puppy
Puppy

Reputation: 146930

No single data structure will satisfy all of these properties. You will have to use inheritance and mix data structures at runtime.

Upvotes: 0

Neera
Neera

Reputation: 1587

You can consider using composite design pattern. This link has some relevant information for this context.

Upvotes: 0

MikeAinOz
MikeAinOz

Reputation: 128

I'm not a C++ programmer but this looks like a linked list of linked lists to me.

Upvotes: 0

Related Questions