Boost logo

Boost Users :

From: Steven L. Scott (sls_at_[hidden])
Date: 2004-08-23 10:42:09

I'm working on an application (a data analysis system built in C++) for
which it would be helpful to have nested (multidimensional) containers
other than ordinary arrays. I have defined a generic 'data' class which
I like to store in std::vector<data *>'s. For a very simple example, a
'data' might be a double representing a student's score on an exam, or
in more complex settings it might be some sort of spatial map, or a
multidimensional set of records for a medical patient.

I am interested in structures where 'data' is nested across multiple
levels. For example, test scores are nested within students, students
nested within teachers, nested within school districts, etc. For a
single layer of nesting a std::map<std::string, std::vector<data *> >
seems to be an ideal way to store such data, largely because text
strings can be used to identify subjects:

        dat["johnny"] // returns a std::vector of pointers to johnny's
test scores.

This is often the way that data are stored in files to be analyzed.

I'm looking for some sort of C++ container that is more convenient for
multiply nested data than std::map<std::string, std::map<std::string
.... , std::vector<data *> > > ... >, but which will allow me to write
expressions like:

        dat["LAUSD"]["Central High"]["Ms. Jones' Class"]["Johnny"] //
same vector as above.

Can something like the Boost multi-array package be extended to handle

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at