Mercurial > hg > GearsTemplate
view src/llrb/llrbContext.h @ 73:2667c3251a00
implement llrb deletion
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 10 Nov 2015 10:21:37 +0900 |
parents | 5c4b9d116eda |
children | 97387904add9 |
line wrap: on
line source
/* Context definition for llrb example */ #include "stack.h" #define ALLOCATE_SIZE 100 enum Code { Code1, Code2, Code3, Code4, Code5, Find, Not_find, Code6, Allocator, Put, Replace, Insert, Compare, Create, RotateL, RotateR, ColorFlip, FixUp, ChangeRef, Balance1, Balance2, Balance3, Get, FindMin, Delete, Replace_d1, Replace_d2, Replace_d3, Replace_d4, MoveRedL1, MoveRedL2, MoveRedL3, MoveRedR1, MoveRedR2, DeleteMin1, DeleteMin2, Exit, }; enum UniqueData { Allocate, Tree, Node, }; struct Context { enum Code next; int codeNum; __code (**code) (struct Context*); void* heapStart; void* heap; long heapLimit; int dataNum; stack_ptr code_stack; stack_ptr node_stack; union Data **data; }; union Data { struct Comparable { // inteface enum Code compare; union Data* data; } compare; struct Count { enum Code next; long i; } count; struct Tree { enum Code next; struct Node* root; struct Node* current; struct Node* prev; int result; } tree; struct Node { enum Code next; int key; // comparable data segment int value; enum Color { Red, Black, } color; struct Node* left; struct Node* right; } node; struct Allocate { enum Code next; long size; } allocate; };