synchronized Object iteratorFind ( DeleteStack stack , SearchComparator comp , Object searchKey , SearchNode point ) { point . reset ( ) ; GBSNode p = root ( ) ; GBSNode l = null ; GBSNode r = null ; int lx = 0 ; int rx = 0 ; Object ret = null ; stack . start ( dummyTopNode ( ) , "GBSTree.iteratorFind" ) ; while ( p != null ) { int xcc = comp . compare ( searchKey , p . middleKey ( ) ) ; if ( xcc == 0 ) { point . setFound ( p , p . middleIndex ( ) ) ; p = null ; } else if ( xcc < 0 ) { if ( p . leftChild ( ) != null ) { stack . push ( NodeStack . PROCESS_CURRENT , p , "GBSTree.iteratorFind(1)" ) ; l = p ; lx = stack . index ( ) ; p = p . leftChild ( ) ; } else { leftSearch ( comp , p , r , searchKey , point ) ; if ( point . wasFound ( ) ) { if ( point . foundNode ( ) == r ) stack . reset ( rx - 1 ) ; } p = null ; } } else // (xcc > 0) { if ( p . rightChild ( ) != null ) { stack . push ( NodeStack . DONE_VISITS , p , "GBSTree.iteratorFind(2)" ) ; r = p ; rx = stack . index ( ) ; p = p . rightChild ( ) ; } else { rightSearch ( comp , p , l , searchKey , point ) ; if ( point . wasFound ( ) ) { if ( point . foundNode ( ) == l ) stack . reset ( lx - 1 ) ; } p = null ; } } } if ( point . wasFound ( ) ) { ret = point . foundNode ( ) . key ( point . foundIndex ( ) ) ; point . setLocation ( ret ) ; } return ret ; }
Search the index from an Iterator .