blob: 829a57c2b5defad9d3f54cff1bf82f17e0a635a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* @file
*
* @brief Initialize a Red-Black Tree
* @ingroup ClassicRBTrees
*/
/*
* Copyright (c) 2010 Gedare Bloom.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/rbtree.h>
#include <rtems/score/address.h>
void rtems_rbtree_initialize(
rtems_rbtree_control *the_rbtree,
rtems_rbtree_compare compare,
void *starting_address,
size_t number_nodes,
size_t node_size,
bool is_unique
)
{
size_t count;
rtems_rbtree_node *next;
/* could do sanity checks here */
rtems_rbtree_initialize_empty( the_rbtree );
count = number_nodes;
next = starting_address;
while ( count-- ) {
rtems_rbtree_insert( the_rbtree, next, compare, is_unique );
next = (rtems_rbtree_node *) _Addresses_Add_offset( next, node_size );
}
}
|