49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
/**
|
|
rjp
|
|
Copyright (C) 2018-2020 rexy712
|
|
|
|
This program 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.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef RJP_TREE_H
|
|
#define RJP_TREE_H
|
|
|
|
#include "rjp.h"
|
|
#include "rjp_object_member.h"
|
|
#include "rjp_value.h"
|
|
|
|
#define RJP_TREE_SUCCESS 0
|
|
#define RJP_TREE_ERR_NULL_ROOT 1
|
|
#define RJP_TREE_ERR_NOT_FOUND 2
|
|
|
|
typedef struct RJP_object_iterator RJP_object_iterator;
|
|
typedef struct RJP_tree_node RJP_tree_node;
|
|
struct RJP_tree_node{
|
|
RJP_object_member data;
|
|
RJP_tree_node* parent;
|
|
RJP_tree_node* left;
|
|
RJP_tree_node* right;
|
|
unsigned color:1;
|
|
};
|
|
|
|
RJP_tree_node* irjp_new_node(char* key, RJP_index keylen);
|
|
RJP_tree_node* irjp_tree_insert_value(RJP_tree_node* root, char* key, RJP_index keylen, RJP_value** added, int* status);
|
|
RJP_tree_node* irjp_tree_insert_node(RJP_tree_node *restrict root, RJP_tree_node *restrict newnode);
|
|
RJP_tree_node* irjp_tree_remove_value(RJP_tree_node* restrict root, RJP_tree_node* restrict member, RJP_tree_node** removed_node);
|
|
RJP_tree_node* irjp_tree_search_value(RJP_tree_node* root, const char* key);
|
|
RJP_tree_node* irjp_copy_tree(const RJP_tree_node* root);
|
|
void irjp_free_tree(RJP_tree_node* root);
|
|
|
|
#endif
|