open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
aa_tree.h
Go to the documentation of this file.
1/** This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 *
5 * Copyright 2020 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
6 */
7
8#ifndef AA_TREE_H_
9#define AA_TREE_H_
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
20
21struct aa_entry {
22 struct aa_entry *left;
23 struct aa_entry *right;
24 unsigned int level;
25};
26
27struct aa_head {
28 struct aa_entry *root;
29 enum aa_cmp (*cmp)(const void* a, const void* b);
30 /* Offset from the container element to the aa_entry and the key */
31 unsigned int entry_offset;
32 unsigned int key_offset;
33};
34
35/** The AA-Tree allows duplicate entries. The first matching key is returned in
36 * aa_find. */
37
38void aa_init(struct aa_head *head,
39 enum aa_cmp (*cmp)(const void*, const void*),
40 unsigned int entry_offset, unsigned int key_offset);
41void aa_insert(struct aa_head *head, void *elem);
42void aa_remove(struct aa_head *head, void *elem);
43void * aa_find(const struct aa_head *head, const void *key);
44void * aa_min(const struct aa_head *head);
45void * aa_max(const struct aa_head *head);
46void * aa_next(const struct aa_head *head, const void *elem);
47void * aa_prev(const struct aa_head *head, const void *elem);
48
49#ifdef __cplusplus
50} /* extern "C" */
51#endif
52
53#endif /* AA_TREE_H_ */
void * aa_prev(const struct aa_head *head, const void *elem)
void * aa_find(const struct aa_head *head, const void *key)
void * aa_min(const struct aa_head *head)
void aa_insert(struct aa_head *head, void *elem)
void aa_init(struct aa_head *head, enum aa_cmp(*cmp)(const void *, const void *), unsigned int entry_offset, unsigned int key_offset)
The AA-Tree allows duplicate entries.
void aa_remove(struct aa_head *head, void *elem)
void * aa_max(const struct aa_head *head)
void * aa_next(const struct aa_head *head, const void *elem)
aa_cmp
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition aa_tree.h:15
@ AA_CMP_LESS
Definition aa_tree.h:16
@ AA_CMP_MORE
Definition aa_tree.h:18
@ AA_CMP_EQ
Definition aa_tree.h:17
Definition aa_tree.h:21
unsigned int level
Definition aa_tree.h:24
struct aa_entry * left
Definition aa_tree.h:22
struct aa_entry * right
Definition aa_tree.h:23
struct aa_entry * root
Definition aa_tree.h:28
unsigned int entry_offset
Definition aa_tree.h:31
enum aa_cmp(* cmp)(const void *a, const void *b)
Definition aa_tree.h:29
unsigned int key_offset
Definition aa_tree.h:32