5
Last change
on this file since 2548d14 was
edf640f,
checked in by Sebastian Huber <sebastian.huber@…>, on 08/31/15 at 11:11:04
|
rbtree: Add _RBTree_Replace_node()
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreRBTree |
---|
5 | * |
---|
6 | * @brief _RBTree_Replace_node() implementation. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2015 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #if HAVE_CONFIG_H |
---|
24 | #include "config.h" |
---|
25 | #endif |
---|
26 | |
---|
27 | #include <rtems/score/rbtree.h> |
---|
28 | |
---|
29 | void _RBTree_Replace_node( |
---|
30 | RBTree_Control *the_rbtree, |
---|
31 | RBTree_Node *victim, |
---|
32 | RBTree_Node *replacement |
---|
33 | ) |
---|
34 | { |
---|
35 | RBTree_Node *parent = _RBTree_Parent( victim ); |
---|
36 | RBTree_Node **link; |
---|
37 | RBTree_Node *child; |
---|
38 | |
---|
39 | if (parent != NULL) { |
---|
40 | if ( victim == _RBTree_Left( parent ) ) { |
---|
41 | link = _RBTree_Left_reference( parent ); |
---|
42 | } else { |
---|
43 | link = _RBTree_Right_reference( parent ); |
---|
44 | } |
---|
45 | } else { |
---|
46 | link = _RBTree_Root_reference( the_rbtree ); |
---|
47 | } |
---|
48 | *link = replacement; |
---|
49 | |
---|
50 | child = _RBTree_Left( victim ); |
---|
51 | if ( child != NULL ) { |
---|
52 | RB_PARENT( child, Node ) = replacement; |
---|
53 | } |
---|
54 | |
---|
55 | child = _RBTree_Right( victim ); |
---|
56 | if ( child != NULL ) { |
---|
57 | RB_PARENT( child, Node ) = replacement; |
---|
58 | } |
---|
59 | |
---|
60 | *replacement = *victim; |
---|
61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.