Plugins/PointSprite/ParaViewPlugin/Qvis/DataNode.cpp
void
DataNode::RemoveNode(const vtkstd::string &key, bool deleteNode)
{
    if(NodeType != INTERNAL_NODE)
        return;
    if(Length < 1)
        return;

    if(Length == 1)
    {
        DataNode *node = (DataNode *)Data;
        if(node->Key == key)
        {
            if(deleteNode)
                delete node;
            Data = 0;
            Length = 0;
        }
    }
    else
    {
        DataNode **nodeArray = (DataNode **)Data;
        bool start = false;

        for(int i = 0; i < Length; ++i)
        {
            if(!start && nodeArray[i]->Key == key)
            {
                if(deleteNode)
                    delete nodeArray[i];
                start = true;
            }

            if(start && (i < (Length - 1)))
                nodeArray[i] = nodeArray[i + 1];
        }
        if(start)
        {
            --Length;

            // If we're down to 1, convert to a single pointer.
            if(Length == 1)
            {
                DataNode *temp = nodeArray[0];
                delete [] nodeArray;
                Data = (void *)temp;
            } 
        }
    }
}
// ****************************************************************************
// Method: DataNode::RemoveNode
//
// Purpose: 
//   Removes the node with the specified key if it exists under the 
//   current node.
//
// Arguments:
//   key : The key of the node to remove.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 28 12:14:24 PDT 2000
//
// Modifications:
//   Brad Whitlock, Mon Feb 2 15:38:05 PST 2004
//   I added an optional argument to delete the node.
//
// ****************************************************************************
:RemoveNode
Purpose:
Removes the node with the specified key if it exists under the
current node.

key : The key of the node to remove.

Brad Whitlock
Creation:   Thu Sep 28 12:14:24 PDT 2000

Brad Whitlock, Mon Feb 2 15:38:05 PST 2004
I added an optional argument to delete the node.
: RemoveNode Purpose : Removes the node with the specified key if it exists under the current node . key : The key of the node to remove . Brad Whitlock Creation : Thu Sep 28 12 : 14 : 24 PDT 2000 Brad Whitlock Mon Feb 2 15 : 38 : 05 PST 2004 I added an optional argument to delete the node .
void
DataNode::RemoveNode(const vtkstd::string &key, bool deleteNode)
{
    if(NodeType != INTERNAL_NODE)
        return;
    if(Length < 1)
        return;
    if(Length == 1)
    {
        DataNode *node = (DataNode *)Data;
        if(node->Key == key)
        {
            if(deleteNode)
                delete node;
            Data = 0;
            Length = 0;
        }
    }
    else
    {
        DataNode **nodeArray = (DataNode **)Data;
        bool start = false;
        for(int i = 0; i < Length; ++i)
        {
            if(!start && nodeArray[i]->Key == key)
            {
                if(deleteNode)
                    delete nodeArray[i];
                start = true;
            }
            if(start && (i < (Length - 1)))
                nodeArray[i] = nodeArray[i + 1];
        }
        if(start)
        {
            --Length;
            if(Length == 1)
            {
                DataNode *temp = nodeArray[0];
                delete [] nodeArray;
                Data = (void *)temp;
            } 
        }
    }
}
void DataNode :: RemoveNode ( const vtkstd :: string & key , bool deleteNode ) { if ( NodeType != INTERNAL_NODE ) return ; if ( Length < 1 ) return ; if ( Length == 1 ) { DataNode * node = ( DataNode * ) Data ; if ( node -> Key == key ) { if ( deleteNode ) delete node ; Data = 0 ; Length = 0 ; } } else { DataNode * * nodeArray = ( DataNode * * ) Data ; bool start = false ; for ( int i = 0 ; i < Length ; ++ i ) { if ( ! start && nodeArray [ i ] -> Key == key ) { if ( deleteNode ) delete nodeArray [ i ] ; start = true ; } if ( start && ( i < ( Length - 1 ) ) ) nodeArray [ i ] = nodeArray [ i + 1 ] ; } if ( start ) { -- Length ; if ( Length == 1 ) { DataNode * temp = nodeArray [ 0 ] ; delete [ ] nodeArray ; Data = ( void * ) temp ; } } } }
Method: DataNode::RemoveNode
Purpose:
Removes the node with the specified key if it exists under the
current node.
Method : DataNode :: RemoveNode Purpose : Removes the node with the specified key if it exists under the current node .
// If we're down to 1, convert to a single pointer.