Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

feel thread

Name: Anonymous 2012-06-03 13:58

that feel when your handwritten linked_list in C is 5 seconds faster than the STL

Name: Anonymous 2012-06-05 11:12

>>1,4
Hey OP, here's my list implementation in C++11, minus a few routines.

http://codepad.org/zPovb3LR

Allocation of nodes is outside of the scope of the library, it's left up to the user, that way they can use different allocation strategies. Concrete implementations have their node structs inherit the base list_node type. I use templates and lambda functions to generalize a few algorithms where the actual node type needs to be known.

struct log_sink_node : list_node
{
    log_handler handler;
    void* user_data;
    unsigned int min_level;
    unsigned int max_level;
    char category[196];
};

list_foreach<log_sink_node>(&context->sinks_head, [&](log_sink_node* sink) {
    if ( (sink->category[0] == '\0' || !strcmp(sink->category, record.category))
        && (sink->min_level <= record.level) && (record.level <= sink->max_level)
    ) {
        sink->handler(&record, sink->user_data);
    }
});

list_clear<log_sink_node>(&context->sinks_head, [](log_sink_node* sink) {
    free(sink);
});

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List