1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
22 // The Persistent Red-Black Tree
28 #include "dbe_types.h"
29 template <class ITEM
> class Vector
;
31 // The number of pointers in a node must be set greater than 2.
32 // The higher the number the faster the search seems to be and
33 // the more memory the tree takes.
41 typedef hrtime_t Time_t
;
46 bool insert (Key_t key
, Time_t ts
, void *item
);
47 bool remove (Key_t key
, Time_t ts
);
48 void *locate (Key_t key
, Time_t ts
);
49 void *locate_exact_match (Key_t key
, Time_t ts
);
50 void *locate_up (Key_t key
, Time_t ts
);
51 Vector
<void *> *values ();
79 LMap (Key_t _key
, void *_item
);
80 LMap (const LMap
& lm
);
84 LMap
*mlist
; // The master list of all nodes
86 Vector
<Time_t
> *times
;
89 Time_t rtts
; // root timestamp
90 Time_t curts
; // last update timestamp
92 LMap
*rb_locate (Key_t key
, Time_t ts
, bool low
);
93 LMap
*rb_new_node (Key_t key
, void *item
);
94 LMap
*rb_new_node (LMap
*lm
);
95 LMap
*rb_copy_node (LMap
*lm
, Direction d
);
96 LMap
*rb_fix_chld (LMap
*prnt
, LMap
*lm
, Direction d
);
97 LMap
*rb_rotate (LMap
*x
, Direction d
);
98 void rb_remove_fixup (LMap
*x
, LMap
*prnt
, Direction d0
);
100 static LMap
*rb_child (LMap
*lm
, Direction d
, Time_t ts
);
101 static Direction
rb_which_chld (LMap
*lm
);
102 static LMap
*rb_neighbor (LMap
*lm
, Time_t ts
);
106 #endif /* _PRBTREE_H */