version 1.1.2.1, 2011/06/07 11:06:34
|
version 1.3, 2011/08/29 12:00:57
|
Line 43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
Line 43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
SUCH DAMAGE. |
SUCH DAMAGE. |
*/ |
*/ |
|
/* |
|
* |
|
* AVL tree implementation, changes in other trees and file are |
|
* Copyrighted 2011 Michael Pounov <misho@elwix.org> |
|
* All rights reserved. |
|
* |
|
*/ |
/* $OpenBSD: tree.h,v 1.12 2009/03/02 09:42:55 mikeb Exp $ */ |
/* $OpenBSD: tree.h,v 1.12 2009/03/02 09:42:55 mikeb Exp $ */ |
/* |
/* |
* Copyright 2002 Niels Provos <provos@citi.umich.edu> |
* Copyright 2002 Niels Provos <provos@citi.umich.edu> |
Line 128 struct { \
|
Line 135 struct { \
|
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ |
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ |
(head)->sph_root = tmp; \ |
(head)->sph_root = tmp; \ |
} while (0) |
} while (0) |
| |
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ |
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ |
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ |
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ |
SPLAY_LEFT(tmp, field) = (head)->sph_root; \ |
SPLAY_LEFT(tmp, field) = (head)->sph_root; \ |
Line 374 struct { \
|
Line 381 struct { \
|
} while (0) |
} while (0) |
|
|
#ifndef RB_AUGMENT |
#ifndef RB_AUGMENT |
#define RB_AUGMENT(x) do {} while (0) | #define RB_AUGMENT(x) (void)(x) |
#endif |
#endif |
|
|
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ |
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ |
Line 418 struct { \
|
Line 425 struct { \
|
} while (0) |
} while (0) |
|
|
/* Generates prototypes and inline functions */ |
/* Generates prototypes and inline functions */ |
#define RB_PROTOTYPE(name, type, field, cmp) \ | #define RB_PROTOTYPE(name, type, field, cmp) \ |
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) |
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) |
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ |
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ |
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) |
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) |
Line 510 name##_RB_REMOVE_COLOR(struct name *head, struct type
|
Line 517 name##_RB_REMOVE_COLOR(struct name *head, struct type
|
if (RB_RIGHT(tmp, field) == NULL || \ |
if (RB_RIGHT(tmp, field) == NULL || \ |
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ |
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ |
struct type *oleft; \ |
struct type *oleft; \ |
if ((oleft = RB_LEFT(tmp, field)))\ | if ((oleft = RB_LEFT(tmp, field))) \ |
RB_COLOR(oleft, field) = RB_BLACK;\ |
RB_COLOR(oleft, field) = RB_BLACK;\ |
RB_COLOR(tmp, field) = RB_RED; \ |
RB_COLOR(tmp, field) = RB_RED; \ |
RB_ROTATE_RIGHT(head, tmp, oleft, field);\ |
RB_ROTATE_RIGHT(head, tmp, oleft, field);\ |
Line 542 name##_RB_REMOVE_COLOR(struct name *head, struct type
|
Line 549 name##_RB_REMOVE_COLOR(struct name *head, struct type
|
if (RB_LEFT(tmp, field) == NULL || \ |
if (RB_LEFT(tmp, field) == NULL || \ |
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ |
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ |
struct type *oright; \ |
struct type *oright; \ |
if ((oright = RB_RIGHT(tmp, field)))\ | if ((oright = RB_RIGHT(tmp, field))) \ |
RB_COLOR(oright, field) = RB_BLACK;\ |
RB_COLOR(oright, field) = RB_BLACK;\ |
RB_COLOR(tmp, field) = RB_RED; \ |
RB_COLOR(tmp, field) = RB_RED; \ |
RB_ROTATE_LEFT(head, tmp, oright, field);\ |
RB_ROTATE_LEFT(head, tmp, oright, field);\ |