This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linked List Implementation

On 27/11/17 12:02, Florian Weimer wrote:
These interfaces are old and somewhat difficult to use, but I expect it will be difficult to get consensus for a new set of interfaces because everyone looks for something different in a container library.

As a data structure developer, I'm very interested to find out what other people are expecting from APIs.

For me, there is a struct for state, a struct per element, each element has two void pointers, one to the key, one to the value. The per-element struct is normally a member of the user struct which is to placed into data structure, the the value is set to be the address of that user data structure.

The caller performs all allocations, so he can use heap, stack, globals, etc.

There's an init() and a cleanup() for the main state struct, and the data structure functions themselves (link to list, insert to btree, etc, depending on the data structure).

Where reasonably possible, APIs are macros, as often very little work is being done.

Data structures are either single threaded, and the user handles locking, or lock-free (in which case, heaven help us all :-)

And that's it - that's what I've come to, after all these years.

I'd love to find some new ideas, things I've totally missed, use cases I had no idea about.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]