X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fbt.c;h=997083b1a08fb64271098f1342a126b9ebd0fe6b;hb=a554ee5cd3f34f39bd202f6a40a79256b537c40d;hp=9b78af230f78da3301c75c49e27b825944e6bfbe;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp diff --git a/src/libpspp/bt.c b/src/libpspp/bt.c index 9b78af230f..997083b1a0 100644 --- a/src/libpspp/bt.c +++ b/src/libpspp/bt.c @@ -1,20 +1,18 @@ -/* PSPP - computes sample statistics. - Copyright (C) 2007 Free Software Foundation, Inc. +/* PSPP - a program for statistical analysis. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ /* Balanced tree (BT) data structure. @@ -69,6 +67,8 @@ #include #include +#include + static void rebalance_subtree (struct bt *, struct bt_node *, size_t); static struct bt_node **down_link (struct bt *, struct bt_node *); @@ -81,9 +81,7 @@ static inline int calculate_h_alpha (size_t); /* Initializes BT as an empty BT that uses the given COMPARE function, passing in AUX as auxiliary data. */ void -bt_init (struct bt *bt, - bt_compare_func *compare, - const void *aux) +bt_init (struct bt *bt, bt_compare_func *compare, const void *aux) { bt->root = NULL; bt->compare = compare; @@ -252,7 +250,7 @@ bt_find (const struct bt *bt, const struct bt_node *target) { cmp = bt->compare (target, p, bt->aux); if (cmp == 0) - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } return NULL; @@ -285,7 +283,7 @@ bt_find_ge (const struct bt *bt, const struct bt_node *target) break; } } - return (struct bt_node *) q; + return CONST_CAST (struct bt_node *, q); } /* Searches BT for, and returns, the last node in in-order whose @@ -316,7 +314,7 @@ bt_find_le (const struct bt *bt, const struct bt_node *target) break; } } - return (struct bt_node *) q; + return CONST_CAST (struct bt_node *, q); } /* Returns the node in BT following P in in-order. @@ -340,7 +338,7 @@ bt_next (const struct bt *bt, const struct bt_node *p) p = p->down[1]; while (p->down[0] != NULL) p = p->down[0]; - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } } @@ -365,7 +363,7 @@ bt_prev (const struct bt *bt, const struct bt_node *p) p = p->down[0]; while (p->down[1] != NULL) p = p->down[1]; - return (struct bt_node *) p; + return CONST_CAST (struct bt_node *, p); } }