private void add ( Object key , Token value , Entry currentEntry , Transaction transaction , long logSpaceDelta ) throws ObjectManagerException { final String methodName = "add" ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , methodName , new Object [ ] { key , value , currentEntry , transaction , new Long ( logSpaceDelta ) } ) ; Entry newEntry ; // Place the new Entry at a point greater than or equal to the currentEntry. keySearch : while ( true ) { if ( compare ( key , currentEntry . key ) < 0 ) { // Less than. if ( Tracing . isAnyTracingEnabled ( ) && trace . isDebugEnabled ( ) ) trace . debug ( this , cclass , methodName , new Object [ ] { "Less than branch." , currentEntry . key } ) ; if ( currentEntry . left == null ) { // We have reached a less than leaf. newEntry = new Entry ( this , key , value , currentEntry , transaction ) ; transaction . add ( newEntry , logSpaceDelta ) ; currentEntry . setLeft ( newEntry ) ; break keySearch ; // Now included in the tree. } // if (currentEntry.left == null). // Look further into the less than tree. currentEntry = ( Entry ) currentEntry . getLeft ( ) ; } else { // Greater than or equal. if ( Tracing . isAnyTracingEnabled ( ) && trace . isDebugEnabled ( ) ) trace . debug ( this , cclass , methodName , new Object [ ] { "Greater than branch." , currentEntry . key } ) ; if ( currentEntry . right == null ) { // Place to the right. // Add into the greater than side. newEntry = new Entry ( this , key , value , currentEntry , transaction ) ; transaction . add ( newEntry , logSpaceDelta ) ; currentEntry . setRight ( newEntry ) ; break keySearch ; // Now included in the tree. } // if (currentEntry.right == null). // Look further into the greater than tree. currentEntry = ( Entry ) currentEntry . getRight ( ) ; } // if (comparator... } // keySearch: while (.... size ++ ; balance ( newEntry ) ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , methodName ) ; }
Add a new value to the tree at a point where they key is after all less than or equal keys and below the currentEntry .