avl_Destroy.cpp.h revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* kAVLDestroy - Walk the tree calling a callback to destroy all the nodes.
*/
/*
* Copyright (C) 1999-2007 knut st. osmundsen (bird-src-spam@anduin.net)
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef _kAVLDestroy_h_
#define _kAVLDestroy_h_
/**
* Destroys the specified tree, starting with the root node and working our way down.
*
* @returns 0 on success.
* @returns Return value from callback on failure. On failure, the tree will be in
* an unbalanced condition and only further calls to the Destroy should be
* made on it. Note that the node we fail on will be considered dead and
* no action is taken to link it back into the tree.
* @param ppTree Pointer to the AVL-tree root node pointer.
* @param pfnCallBack Pointer to callback function.
* @param pvUser User parameter passed on to the callback function.
*/
{
unsigned cEntries;
int rc;
return 0;
cEntries = 1;
while (cEntries > 0)
{
/*
* Process the subtrees first.
*/
else
{
#ifdef KAVL_EQUAL_ALLOWED
/*
* Process nodes with the same key.
*/
{
if (rc)
return rc;
}
#endif
/*
* Unlink the node.
*/
if (--cEntries > 0)
{
else
}
else
if (rc)
return rc;
}
} /* while */
return 0;
}
#endif