**fig4_61.txt** /* 1*/ template /* 2*/ int /* 3*/ Splay_Tree:: /* 4*/ Find( const Etype & X ) /* 5*/ { /* 6*/ Splay_Node /* 7*/ *Last_On_Path, /* 8*/ *Current = ( Splay_Node* ) Root; /* 9*/ if( Current == NULL ) /*10*/ return 0; /*11*/ while( Current != NULL ) /*12*/ { /*13*/ Last_On_Path = Current; /*14*/ if( X < Current->Element ) /*15*/ Current = ( Splay_Node* )( Current->Left ); /*16*/ else /*17*/ if( X > Current->Element ) /*18*/ Current = ( Splay_Node* )( Current->Right ); /*19*/ else /*20*/ { // Item is found. /*21*/ Splay( Current ); /*22*/ Root = Last_Find = Current; /*23*/ return 1; /*24*/ } /*25*/ } /*26*/ Splay( Last_On_Path ); // Not found. Still splay, however. /*27*/ Root = Last_On_Path; /*28*/ return 0; /*29*/ }