Re: [Libclc-developers] Need help with clc_map.
Status: Planning
Brought to you by:
augestad
|
From: <bo...@me...> - 2003-03-19 19:53:12
|
Hallvard B Furuseth wrote:
> Bjørn Augestad writes:
>
>>I'm trying to implement a map (...)
>>
>>int clc_map_set(clc_map m, const char* key, void* data);
>>int clc_map_iset(clc_map m, int key, void* data);
>>(...)
>>void* clc_map_get(clc_map m, const char* key);
>>(...)
>
>
> I think this is pretty backwards.
Me too. I'm currently thinking about something like:
clc_anytype clc_int2any(int);
int clc_any2int(clc_anytype);
with functions for each datatype, of course.
Then the set/get protos for a map could be
int clc_map_set(clc_map m, clc_anytype key, clc_anytype value);
clc_anytype clc_map_get(clc_map m, clc_anytype key);
and a call: clc_map_set(clc_int2any(123), clc_void2any(foo));
Implemented as a struct containing typeinfo and a union to store stuff.
I really don't want such a solution, as it isn't very idiomatic. May be
nice for private stuff, but IMHO not for libclc.
Do you know of an alterative way?
Let's pick a good hash table
> implementation first (which implementation is best is seems like a good
> thing to ask about on comp.lang.c), and you can implement maps on top of
> that if you want to.
Fine, but that doesn't solve the interface problem dealing with keys of
different types. BTW, the protos I posted was just for setting and
getting values using keys, other protos exist. :-)
[snip]
--
boa
Please join the libclc-developers list
at http://lists.sourceforge.net/lists/listinfo/libclc-developers
|