예제 #1
0
cv::Mat EMat::AppendRight(cv::Mat &src) {
    assert(src.rows == rows);

    cv::Mat newMat(rows, src.cols + cols, type());
    AppendRight(src, newMat);
    *this = newMat;
    return newMat;
}
예제 #2
0
void BTree <T> :: RemoveData ( const char *newid, const T &newdata  )
{
    
    /*
      Deletes an element from the list
      By replacing the element with it's own left node, then appending
      it's own right node onto the extreme right of itself.
      
      */
    
    assert (newid);
    
    if ( strcmp ( newid, id ) == 0 && data == newdata ) {
	
		//var tempright : pointer to node := data->right
		BTree <T> *tempright = Right ();       
			
			//data := data->left
		if ( Left () ) {
			
			id = new char [strlen (Left ()->id) + 1];
			strcpy ( id, Left ()->id );
			data = Left ()->data;                  // This bit requires a good copy constructor
			rtree = Left ()->Right ();
			ltree = Left ()->Left ();	
			
			AppendRight ( tempright );
			
		}
		else {
			
			//append_right ( data, tempright )
			
			if ( Right () ) {
			   
				id = new char [strlen (Right ()->id) + 1];
				strcpy ( id, Right ()->id );
				data = Right ()->data;                  // This bit requires a good copy constructor
				ltree = Right ()->Left ();	
				rtree = Right ()->Right ();
			
			}
			else {
			
				id = NULL;                              // Hopefully this is the root node
			
			}	    
			
		}
	    	
    }                                                   //elsif Name < data->name then
	else if ( strcmp ( newid, id ) <= 0 ) {
		if ( Left () ) {
            if ( strcmp ( Left ()->id, newid ) == 0 && data == newdata && !Left ()->Left () && !Left ()->Right () )
                ltree = NULL;
            else
		        Left ()->RemoveData ( newid, newdata );
		}
    }
    else {                                              //elsif Name > data->name then
		if ( Right () ) {
            if ( strcmp ( Right ()->id, newid ) == 0 && data == newdata && !Right ()->Left () && !Right ()->Right () )
                rtree = NULL;
            else
		        Right ()->RemoveData ( newid, newdata );
		}
    }

}
void BTree<T>::RemoveData( const char *newid )
{
    /*
      Deletes an element from the list
      By replacing the element with it's own left node, then appending
      its own right node onto the extreme right of itself.
      */
    
    AppAssert(newid);
    
    int compareResult = stricmp( newid, id );

    if( compareResult == 0 ) 
	{
		//var tempright : pointer to node := data->right
		BTree<T> *tempright = Right();       
			
			//data := data->left
		if( Left() ) 
		{
			id = new char[strlen(Left()->id) + 1];
#ifdef WIN32
			#pragma warning( suppress : 4996 )
#endif
			strcpy( id, Left()->id );
			data = Left()->data;                  // This bit requires a good copy constructor
			rtree = Left()->Right();
			ltree = Left()->Left();	
			
			AppendRight( tempright );
		}
		else 
		{
			//append_right( data, tempright )
			
			if( Right() ) 
			{
				id = new char[strlen(Right()->id) + 1];
#ifdef WIN32
				#pragma warning( suppress : 4996 )
#endif
				strcpy( id, Right()->id );
				data = Right()->data;                  // This bit requires a good copy constructor
				ltree = Right()->Left();	
				rtree = Right()->Right();
			}
			else 
			{
				id = NULL;                              // Hopefully this is the root node
			}	    
		}
    }                                                   //elsif Name < data->name then
    else if( compareResult < 0 ) 
    {
        if( Left() )
        {
            if( stricmp( Left()->id, newid ) == 0 && !Left()->Left() && !Left()->Right() )
                ltree = NULL;
            else
		        Left()->RemoveData( newid );
        }
    }                    
    else                                                //elsif Name > data->name then
    {
	    if( Right() )
        {
            if( stricmp( Right()->id, newid ) == 0 && !Right()->Left() && !Right()->Right() )
                rtree = NULL;
            else
		        Right()->RemoveData( newid );
        }
    }
                             
}