Hi,
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these. For instance, lets say the class has four attributes
a1,a2,a3,a4; and primary key is a1+a4, now I can construct a view that
has subset of objects of this class by doing a search on these objects
that have specific values for attribute a3, and this can give me back
multiple objects and I want to combine the objects that have same
value for a2 into one ; this looks like a classic database
implementation but I dont have real database in my case, instead I have
set of objects and the query I am doing is on these objects based on
combination of attributes of the class. Any pointers on how to do this
using STL classes would be appreciated. I am looking into using
associative containers.. Is this already implemented by someone? I dont
care too much about efficiency since I wont have more than 100 of these
objects...
Thanks,
Sunil. 10 5270
Try a STL map type, keyed on an object that is a combination of a1 and
a4.
sunil wrote: I have a container that holds objects of same type (user defined class), where each object has multiple attributes. These objects have primary key (similar to a database) formed by combination of two attributes, but I want to support multiple views of data by looking at different combination of attributes and in some cases I might want to combine these. For instance, lets say the class has four attributes a1,a2,a3,a4; and primary key is a1+a4...
sqlite is trivial to install and run. It works off a data file and can do
arbitrarily complex SQL statements, such as joins.
--
Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
sunil wrote: Hi, I have a container that holds objects of same type (user defined class), where each object has multiple attributes. These objects have primary key (similar to a database) formed by combination of two attributes, but I want to support multiple views of data by looking at different combination of attributes and in some cases I might want to combine these.
[...]
this looks like a classic database implementation but I dont have real database in my case, instead I have set of objects and the query I am doing is on these objects based on combination of attributes of the class. Any pointers on how to do this using STL classes would be appreciated. I am looking into using associative containers.. Is this already implemented by someone? I dont care too much about efficiency since I wont have more than 100 of these objects... Thanks, Sunil.
Boost.MultiIndex library can do this sort of thing: http://www.boost.org/libs/multi_index/doc/index.html
Also there is relational Template Library (RTL) in boost sandbox: http://tinyurl.com/zwe2o
regards
Andy Little
On Tue, 09 May 2006 17:56:39 GMT, I waved a wand and this message
magically appeared from Roland Pibinger:
[ Boost stuff snipped ] Have you actually used one of those libraries?
All I got was a headache!
-- http://www.munted.org.uk
Take a nap, it saves lives.
Thank you all for input, I looked at boost multi-index library and they
seem to have done a nice job. I cannot use it though due to some
restrictions on third party software. I think I can implement for my
case using maps and multimaps.....
Sunil
sunil wrote: Thank you all for input, I looked at boost multi-index library and they seem to have done a nice job. I cannot use it though due to some restrictions on third party software.
Excuse me? Boost's license is free with no restrictions. Our lawyer just
recently approved it for our shrink-wrap and turn-key solutions.
Maybe your boss likes paying expensive programmers to sit around reinventing
wheels all day. How's your C++ compiler coming along?
--
Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Yves Dhondt |
last post by:
Hello,
I've got the following UML design :
C
|
A _____|______ B
So 2 objects A and B are connected through a relation C. (For example an
employment scheme : person A1 worked for company...
|
by: xixi |
last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer
pool size to accommadate better performance, say size 200000, if i
have multiple connection to the same database from...
|
by: Sushil |
last post by:
Hi gurus
I was reading FAQ
"alloca cannot be written portably, and is difficult to implement on
machines without a conventional stack."
I understand that the standard does not mandate...
|
by: Strange Cat |
last post by:
Hi everyone!
I'm about to start a new project and I'd like to hear from someone more
experienced than me.
What I'm requested to do is:
Display an autorefreshing page that gets data from a...
|
by: tomgee |
last post by:
I saw it many times,
// T.h:
class T
{
public:
static T* instance();
private:
T() {}
|
by: Ralph |
last post by:
Hi,
I was reading effictive C++ and some other books again and they all tell
you about hiding implementation details (proxy/pimpl/inheritance) but
they never really explain when to use it.
I...
|
by: iaminsik |
last post by:
I implemented a TRIE in memory by myself in C.
But, as you know, when a size of data increases, loading time of data
becomes longer.
I want to implement a TRIE in file, which means division of...
|
by: C++Liliput |
last post by:
Hi,
I was looking at the implementation of operator new and operator
new in gcc source code and found that the implementation is exactly
the same. The only difference is that the size_t argument...
|
by: bizt |
last post by:
Hi,
I have a process where every so often I refresh a table's data using a
setTimeout() .. and when its no longer needed, a clearTimeout().
The following is a simple example of how this is...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |