M
Mohitz
Hi,
Need views on the following..
I need to design a data structure to store the values of n attributes,
where n is something near 20.
Now, all the attributes are optional. So, at times, i may have to
store the values of all n of them and
at times not.
I can think of the following two options.
1. Design it as a list and store the attribute name and attribute
value both. Use as much memory as needed
But this leads to operation overhead while accessing data.
2. Make a data structure with n attributes. Whenever, you dont have
the value for an attribute, just set it to NULL.
No performance overhead, but memory overhead.
Two questions:
1. Are there any other solutions possible that gives the best of the
two worlds?
2. If yes, what? If no, which of the above two is better??
Thanks
Need views on the following..
I need to design a data structure to store the values of n attributes,
where n is something near 20.
Now, all the attributes are optional. So, at times, i may have to
store the values of all n of them and
at times not.
I can think of the following two options.
1. Design it as a list and store the attribute name and attribute
value both. Use as much memory as needed
But this leads to operation overhead while accessing data.
2. Make a data structure with n attributes. Whenever, you dont have
the value for an attribute, just set it to NULL.
No performance overhead, but memory overhead.
Two questions:
1. Are there any other solutions possible that gives the best of the
two worlds?
2. If yes, what? If no, which of the above two is better??
Thanks