view src/llrb/llrbContext.h @ 24:7494c0b87ec4

implement insert of Non Destructive llrb
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Fri, 01 May 2015 05:20:47 +0900
parents 868c2918b634
children 44879c87c2dc
line wrap: on
line source

/* Context definition for llrb example */

#define ALLOCATE_SIZE 100

enum Code {
    Code1,
    Code2,
    Code3,
    Code4,
    Code5,
    Allocator,
    Put,
    Clone,
    InitNode,
    Compare,
    Insert,
    RotateL,
    RotateR,
    ColorFlip,
    ChangeRef,
    Exit,
};

enum UniqueData {
    Allocate,
    Tree,
};

struct Context {
    int codeNum;
    __code (**code) (struct Context *);
    void* heap_start;
    void* heap;
    union Data* root;
    union Data* current;
    long dataSize;
    int dataNum;
    union Data **data;
};

union Data {
    long count;
    struct Tree {
        union Data* root;
        union Data* current;
        int result;
    } tree;
    /* struct _Node { */
    /*     int key; */
    /*     int value; */
    /*     enum Color { */
    /*         Red, */
    /*         Black, */
    /*     } color; */
    /*     union Data* parent; */
    /*     union Data* left; */
    /*     union Data* right; */
    /* } _node; */
    struct Node {
        int key;
        int value;
        enum Color {
            Red,
            Black,
        } color;
        union Data* left;
        union Data* right;
    } node;
    struct Allocate {
        long size;
        enum Code next;
        enum Code after_put;
        struct Node node;
    } allocate;
};