예제 #1
0
typename tree< T , A >::iterator
tree< T , A >::
insert( iterator it , const value_type & copy /*= value_type()*/ )
{
    NodePtr_t node_ptr;
    if ( get_node_ptr( it ) != root_) {
        NodePtr_t _S = get_node_ptr( it );
        node_ptr = alloc_node( _S->left , _S , 0 );
        allocator_.construct( & node_ptr->value , copy );
        if ( _S == _S->left->child )
            node_ptr->left->child = node_ptr;
        else if ( _S == _S->left->right )
            node_ptr->left->right = node_ptr;
        _S->left = node_ptr;
    } else if ( root_->child != root_ ) {
        NodePtr_t _S = root_->child;
        while ( _S->right != 0 )
            _S = _S->right;
        node_ptr = alloc_node( _S , _S->right , 0 );
        allocator_.construct( & node_ptr->value , copy );
        _S->right = node_ptr;
        if ( node_ptr->right != 0 )
            node_ptr->right->left = node_ptr;
    } else {
        node_ptr = alloc_node( root_ );
        allocator_.construct( & node_ptr->value , copy );
        root_->child = node_ptr;
    } // if
    ++size_;
    return iterator( node_ptr );
} // insert
예제 #2
0
typename tree< T , A >::const_iterator
tree< T , A >::next_sibling( const_iterator it ) const
{
    return get_node_ptr( it )->right == 0
           ? const_iterator( root_ )
           : const_iterator( get_node_ptr( it )->right );
}
예제 #3
0
void
tree< T , A >::insert( iterator it , const Self & t )
{
    NodePtr_t _T = alloc_node();
    deep_copy( _T , get_node_ptr( t.begin() ) );
    NodePtr_t _S = get_node_ptr( it );
    if ( _S->child != 0 && _S->child != root_ )
        deep_erase( _S->child );
    _S->child = _T->child;
    if ( _T->child )
        _T->child->left = _S;
    free_node( _T );
}
예제 #4
0
typename tree< T , A >::const_iterator
tree< T , A >::get_child( const_iterator it ) const
{
    if ( ! has_child( it ) )
        return const_iterator( root_ );
    return const_iterator( get_node_ptr( it )->child );
}
예제 #5
0
typename tree< T , A >::iterator
tree< T , A >::
insert_after( iterator it , const value_type & copy /*= value_type()*/ )
{
    NodePtr_t node_ptr( root_ );
    if ( get_node_ptr( it ) != root_ ) {
        NodePtr_t _S = get_node_ptr( it );
        node_ptr = alloc_node( _S , _S->right , 0 );
        allocator_.construct( & node_ptr->value , copy );
        if ( _S->right != 0 )
            _S->right->left = node_ptr;
        _S->right = node_ptr;
        ++size_;
    } // if
    return iterator( node_ptr );
}
예제 #6
0
typename tree< T , A >::iterator
tree< T , A >::erase( iterator it )
{
    if ( it == end() )
        return it;
    NodePtr_t node_ptr = get_node_ptr( it );
    --it;
    sub_erase( node_ptr );
    return ++it;
}
예제 #7
0
파일: NodalLoad.cpp 프로젝트: lcpt/xc
//! @brief Applies the load on the node.
//! 
//! To it's associated Node it invokes addUnbalancedLoad() with it's
//! load and a factor of \p loadFactor if \p isLoadConstant was specified
//! as \p false in the constructor or \f$1.0\f$ if it was specified
//! as \p true. 
void XC::NodalLoad::applyLoad(double loadFactor)
  {
    if(!loadedNodePtr)
      loadedNodePtr= get_node_ptr();

    // add the load times the load factor to nodal unbalanced load
    if(konstant == false)
      loadedNodePtr->addUnbalancedLoad(load,loadFactor);
    else
      loadedNodePtr->addUnbalancedLoad(load,1.0);
  } 
예제 #8
0
bool search_tree_get(Search_tree *tree, int key, int *val)
{
    Tree_node *node = *get_node_ptr(tree, key);

    if (node == NULL)
        return false;

    if (val != NULL)
        *val = node->val;

    return true;
}
예제 #9
0
// this is called when the refcount of the node drops to 0
// (and the node itself is being put into the garbage collector's
// queue by the refcnt manager)
static void
terminate_node_callback(refcnt_node_t *node, void *priv)
{
    arc_object_t *obj = (arc_object_t *)get_node_ptr(node);
    arc_t *cache = (arc_t *)priv;

    if (obj->ptr && cache->ops->evict)
        cache->ops->evict(obj->ptr, cache->ops->priv);

    obj->ptr = NULL;
    obj->state = NULL;
}
예제 #10
0
bool search_tree_remove(Search_tree *tree, int key, int *val)
{
    Tree_node **node = get_node_ptr(tree, key);

    if (*node == NULL)
        return false;

    if (val != NULL)
        *val = (*node)->val;
    tree_remove(node);

    return true;
}
예제 #11
0
bool search_tree_set(Search_tree *tree, int key, int val, int *old_val)
{
    Tree_node **node = get_node_ptr(tree, key);

    if (*node == NULL) {
        *node = create_node(key, val, NULL, NULL);

        return false;
    }

    if (old_val != NULL)
        *old_val = (*node)->val;
    (*node)->val = val;

    return true;
}
예제 #12
0
typename tree< T , A >::iterator
tree< T , A >::
insert_child( iterator it , const value_type & copy /*= value_type()*/ )
{
    NodePtr_t _S = get_node_ptr( it );
    NodePtr_t node_ptr;
    if ( _S->child == 0 || _S == root_ ) {
        node_ptr = alloc_node( _S );
        allocator_.construct( & node_ptr->value , copy );
        _S->child = node_ptr;
    } else {
        _S = _S->child;
        while ( _S->right != 0 )
            _S = _S->right;
        node_ptr = alloc_node( _S );
        allocator_.construct( & node_ptr->value , copy );
        _S->right = node_ptr;
    } // if
    ++size_;
    return iterator( node_ptr );
} // insert_child
예제 #13
0
typename tree< T , A >::const_iterator
tree< T , A >::prev_sibling( const_iterator it ) const
{
    return const_iterator( prev_sibling_impl( get_node_ptr( it ) ) );
}
예제 #14
0
typename tree< T , A >::const_iterator
tree< T , A >::get_parent( const_iterator it ) const
{
    return const_iterator( get_parent_impl( get_node_ptr( it ) ) );
}
예제 #15
0
bool
tree< T , A >::has_parent( const_iterator it ) const
{
    return has_parent_impl( get_node_ptr( it ) );
}
예제 #16
0
bool
tree< T , A >::has_child( const_iterator it ) const
{
    return get_node_ptr( it )->child != 0;
}