ucx/avl.c

Sun, 17 May 2015 18:32:41 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 17 May 2015 18:32:41 +0200
changeset 194
0c1b7676e74c
parent 192
1e51558b9d09
child 195
bec61f067ea0
permissions
-rw-r--r--

finalized AVL tree interface + added implementation skeleton + fixed ucx_ptrcmp()

universe@192 1 /*
universe@192 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@192 3 *
universe@192 4 * Copyright 2015 Olaf Wintermann. All rights reserved.
universe@192 5 *
universe@192 6 * Redistribution and use in source and binary forms, with or without
universe@192 7 * modification, are permitted provided that the following conditions are met:
universe@192 8 *
universe@192 9 * 1. Redistributions of source code must retain the above copyright
universe@192 10 * notice, this list of conditions and the following disclaimer.
universe@192 11 *
universe@192 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@192 13 * notice, this list of conditions and the following disclaimer in the
universe@192 14 * documentation and/or other materials provided with the distribution.
universe@192 15 *
universe@192 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@192 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@192 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@192 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@192 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@192 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@192 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@192 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@192 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@192 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@192 26 * POSSIBILITY OF SUCH DAMAGE.
universe@192 27 */
universe@192 28
universe@192 29 #include "avl.h"
universe@192 30
universe@194 31 UcxAVLTree *ucx_avl_new(cmp_func cmpfunc) {
universe@194 32 return ucx_avl_new_a(cmpfunc, ucx_default_allocator());
universe@194 33 }
universe@194 34
universe@194 35 UcxAVLTree *ucx_avl_new_a(cmp_func cmpfunc, UcxAllocator *allocator) {
universe@194 36 UcxAVLTree *tree = malloc(sizeof(UcxAVLTree));
universe@194 37 if (tree) {
universe@194 38 tree->allocator = allocator;
universe@194 39 tree->cmpfunc = cmpfunc;
universe@194 40 tree->root = NULL;
universe@194 41 tree->userdata = NULL;
universe@194 42 }
universe@194 43
universe@194 44 return tree;
universe@194 45 }
universe@194 46
universe@194 47 void *ucx_avl_get(UcxAVLTree *tree, intptr_t key) {
universe@194 48 return NULL;
universe@194 49 }
universe@194 50
universe@194 51 void* ucx_avl_put(UcxAVLTree *tree, intptr_t key, void *value) {
universe@194 52 return NULL;
universe@194 53 }
universe@194 54
universe@194 55 void* ucx_avl_remove(UcxAVLTree *tree, intptr_t key) {
universe@194 56 return NULL;
universe@194 57 }
universe@194 58

mercurial