BarryServer : Git

All the code for all my projects
// BarryServer : Git / libBLOC / blob / 56139959c274c6a38f5d0fd0f3909a6b39f1ca1b / tree / tree.h

// Related

libBLOC

Barry Initial commit b3106d3 (2 years, 11 months ago)
/*
 * Copyright (C) 2023 Barry
 *
 * This file is part of Barry's Little Objects in C Library (libBLOC).
 *
 * libBLOC is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * libBLOC is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * libBLOC.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef TREE_H
#define TREE_H

#include <BLOC/iterator.h>

/* Structure for a Tree Node */
struct TreeNode {
	struct IterableEntry header;
	struct TreeNode *left, *right;
};

/* Structure for an object Tree */
struct Tree {
	struct Iterable header;
	struct TreeNode *root;
	struct ObjectType *type;
	int (*compare)(void *, void *);
};

unsigned int _tree_count(struct TreeNode *root);
struct TreeNode *_tree_rotate_left(struct TreeNode *root);
struct TreeNode *_tree_rotate_right(struct TreeNode *root);

#endif