/* $Id$ * Implementation of RTL_SPLAY_LINKS functions of libcaptive * Copyright (C) 2002 Jan Kratochvil * * 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; exactly version 2 of June 1991 is required * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include "reactos/ntos/rtltypes.h" /* self */ #include /** * RtlDelete: * @Links: Node to delete. * %NULL value is forbidden. * * Deletes the given node from its tree. * * Returns: New root of the given tree. It may be %NULL if the tree becomes empty. */ PRTL_SPLAY_LINKS RtlDelete(PRTL_SPLAY_LINKS Links) { RTL_SPLAY_LINKS *root,**selfp; g_return_val_if_fail(Links!=NULL,NULL); for (root=Links;root->Parent!=root;) { g_assert(root->Parent!=NULL); root=root->Parent; } if (root==Links) selfp=&root; else if (Links->Parent->LeftChild==Links) selfp=&Links->Parent->LeftChild; else if (Links->Parent->RightChild==Links) selfp=&Links->Parent->RightChild; else g_assert_not_reached(); /* should not happen if the structures are valid */ if (!Links->LeftChild) *selfp=Links->RightChild; else if (!Links->RightChild) *selfp=Links->LeftChild; else g_assert_not_reached(); /* FIXME: NOT IMPLEMENTED YET */ /* FIXME: rebalance: NOT IMPLEMENTED YET */ return root; } /** * RtlSplay: * @Links: Root of the tree to rebalance. * %NULL value is forbidden. * * Rebalances the tree for optimal heights and effective operations. * FIXME: Currently a NOP in libcaptive. * * Returns: New root of the rebalanced tree. * It may or it may not be equal to the given @Links. */ PRTL_SPLAY_LINKS RtlSplay(PRTL_SPLAY_LINKS Links) { g_return_val_if_fail(Links!=NULL,NULL); /* FIXME: rebalance: NOT IMPLEMENTED YET */ return Links; }