public boolean contains ( long key ) { if ( size == 0 ) { return false ; } if ( size == 1 ) { int posDiff = compare ( key , rootKey ) ; if ( posDiff == - 1 ) { return true ; } return false ; } Node < V > n = root ; while ( true ) { if ( ! doesInfixMatch ( n , key ) ) { return false ; } //infix matches, so now we check sub-nodes and postfixes if ( getBit ( key , n . posDiff ) ) { if ( n . hi != null ) { n = n . hi ; continue ; } return compare ( key , n . hiPost ) == - 1 ; } else { if ( n . lo != null ) { n = n . lo ; continue ; } return compare ( key , n . loPost ) == - 1 ; } } }
Check whether a given key exists in the tree .