class Containers::XORList

Public Class Methods

new() click to toggle source
static VALUE xor_list_init(VALUE self)
{
        return self;
}

Public Instance Methods

each() click to toggle source
static VALUE xor_list_each(VALUE self) {
    xor_list *list = get_xor_list(self);
    node *current = list->front;
    node *prev = NULL, *next = NULL;
    while(current) {
        rb_yield(current->obj);
        next = xor(prev, current->npx);
        prev = current;
        current = next;
    }
    return self;
}
push_front(p1) click to toggle source
static VALUE xor_list_push_front(VALUE self, VALUE obj) {
        xor_list *list = get_xor_list(self);
        node *current = create_node(obj);
        if(list->front) {
                current->npx = xor(NULL, list->front);
                list->front->npx = xor(current, xor(NULL, list->front->npx));
        }
        else {
                list->back = current;
        }
        list->front = current;
        list->size++;
        return obj;
}