view src/llrb/llrbContext.h @ 42:44914699ee9b

refactoring llrb
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 19 May 2015 05:06:25 +0900
parents 44879c87c2dc
children a0a58875c93f
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,
    FixUp,
    ChangeRef,
    Exit,
};

enum UniqueData {
    Allocate,
    Tree,
    Node,
    Next,
};

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;
    enum Code next;
    struct Tree {
        struct Node* root;
        struct Node* current;
        struct Node* prev;
        int result;
    } tree;
    struct Node {
        int key;
        int value;
        enum Color {
            Red,
            Black,
        } color;
        struct Node* left;
        struct Node* right;
    } node;
    struct Allocate {
        long size;
        enum Code next;
    } allocate;
};