1 #!/usr/bin/env python 2 #coding:utf-8 3 # Author: mozman 4 # Created: 08.05.2010 5 # Copyright (c) 2010-2013 by Manfred Moitzi 6 # License: MIT License 7 8 cdef extern from "ctrees.h": 9 ctypedef struct PyObject: 10 pass 11 12 ctypedef struct node_t: 13 node_t *link[2] 14 PyObject *key 15 PyObject *value 16 17 int ct_compare(object key1, object key2) 18 void ct_delete_tree(node_t *root) 19 node_t *ct_find_node(node_t *root, object key) 20 PyObject *ct_get_item(node_t *root, object key) 21 node_t *ct_max_node(node_t *root) 22 node_t *ct_min_node(node_t *root) 23 node_t *ct_succ_node(node_t *root, object key) 24 node_t *ct_prev_node(node_t *root, object key) 25 node_t *ct_floor_node(node_t *root, object key) 26 node_t *ct_ceiling_node(node_t *root, object key) 27 int ct_index_of(node_t *root, object key) 28 node_t *ct_node_at(node_t *root, int index) 29 30 # binary-tree functions 31 int ct_bintree_insert(node_t **root, object key, object value) 32 int ct_bintree_remove(node_t **root, object key) 33 # avl-tree functions 34 int avl_insert(node_t **root, object key, object value) 35 int avl_remove(node_t **root, object key) 36 # rb-tree functions 37 int rb_insert(node_t **root, object key, object value) 38 int rb_remove(node_t **root, object key)