V
void * clvrmnky()
Greetings,
I'm in the process of refactoring some code, and have determined that I
need a map (or some other dictionary structure) to maintain a small list
of key-value pairs. This is follow-on work from parallel development
done in Java, so I'm working to a spec based on exposed methods.
I've cooked up some prototypes based on linked-lists or tuples, but I
have the feeling I'm missing something.
What online refs do folks here use to see working examples and
discussions of data structures in C? My Google-fu is failing me -- I'm
getting plenty of definitions of maps, and considerations on
implementation, but I'd like a concrete example to compare with my
(rather naive) attempts.
I only have to implemented add(key, value), fetch(key) and getallkeys()
functions for this use, and the map itself will only have a handful of
entries, and we never need to remove them. Both the keys and the values
are wchars (though I'm not against making them void *).
I have no problem just implementing a fix-sized tuple (yes, I know...)
as this is all that is required of the design. Of course, the reason
I'm updating this code is because the original design assumed we've
never need more than a handful of items in a struct...
It may need to be said that this data and the functions to access it are
essentially private to this component. I don't need a general-purpose
library for the entire product (which is mostly in Java, anyway -- hence
my ignorance of implementation).
Thanks.
I'm in the process of refactoring some code, and have determined that I
need a map (or some other dictionary structure) to maintain a small list
of key-value pairs. This is follow-on work from parallel development
done in Java, so I'm working to a spec based on exposed methods.
I've cooked up some prototypes based on linked-lists or tuples, but I
have the feeling I'm missing something.
What online refs do folks here use to see working examples and
discussions of data structures in C? My Google-fu is failing me -- I'm
getting plenty of definitions of maps, and considerations on
implementation, but I'd like a concrete example to compare with my
(rather naive) attempts.
I only have to implemented add(key, value), fetch(key) and getallkeys()
functions for this use, and the map itself will only have a handful of
entries, and we never need to remove them. Both the keys and the values
are wchars (though I'm not against making them void *).
I have no problem just implementing a fix-sized tuple (yes, I know...)
as this is all that is required of the design. Of course, the reason
I'm updating this code is because the original design assumed we've
never need more than a handful of items in a struct...
It may need to be said that this data and the functions to access it are
essentially private to this component. I don't need a general-purpose
library for the entire product (which is mostly in Java, anyway -- hence
my ignorance of implementation).
Thanks.