[GiNaC-list] hash tables and sets

Marko Riedel mriedel at lsi.upc.edu
Wed Oct 11 01:15:10 CEST 2006


Richard B. Kreckel writes:
 > Dear Marko,
 > 
 > You wrote:
 > 
 > >I have another very basic question. Suppose I have an ordinary C
 > >structure (I will use C in my example, rather than Objective C, to
 > >keep it simple) containing some fields e.g.
 > >
 > >typedef struct {
 > >    int a, b;
 > >    char *name;
 > >} mystruct;
 > >
 > >Now I want to add a field to it (at compile time, of course),
 > >containing a set of expressions, using std::set<ex, ex_is_less>, as
 > >you suggested. How would I declare this field? What headers do I need
 > >to import?
 > >  
 > >
 > 
 > #include <ginac/ginac.h>
 > 
 > typedef struct {
 > int a, b;
 > char *name;
 > std::set<GiNaC::ex, GiNaC::ex_is_less> expressionset;
 > } mystruct;
 > 
[...]
 > Nothing. As recommended in an earlier email, use the placement new 
 > istead: new(inst) mystruct. This way, the set ctor will have initialized 
 > expressionset properly. Note, that the compiler has automatically 
 > equipped mystruct with a set of default ctors.
 > 

Thank you for the reply and for your patience. I guess I'm not
explaining myself well. Consider the following problem:

Someone hands me a chunk of memory through a void pointer, like so:

    (void *)ptr.

I want the memory pointed to by "ptr" to hold a newly initialized set
of GiNaC expressions. How do I do this? How do I find out the number
of bytes I will need? At some point in the future, someone will hand
me that same pointer and I will want to free the set of expressions
that it holds. Again, how do I do this?

Thanks!

Best regards,

Marko Riedel

+-------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel at lsi.upc.edu    |
| http://www.geocities.com/markoriedelde/index.html           |
+-------------------------------------------------------------+



More information about the GiNaC-list mailing list