public final void copyEntries ( TransactionalBidiTreeMap < K , V > new_map ) { K key ; V val ; int transaction_status ; String transaction_id ; new_map . setAutoCommit ( isAutoCommit ( ) ) ; if ( ! isAutoCommit ( ) ) { // Do committed and deleted first for ( Iterator < Entry < K , V > > i = allEntrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { TransactionalBidiTreeMap . Node < K , V > entry = ( TransactionalBidiTreeMap . Node < K , V > ) i . next ( ) ; key = entry . getKey ( ) ; val = entry . getValue ( ) ; transaction_status = entry . getStatus ( ) ; transaction_id = entry . getTransactionId ( ) ; if ( transaction_status != TransactionalBidiTreeMap . Node . ADDED ) { try { // Put the value against the key new_map . put ( key , val ) ; // As the transaction status is deleted or no change then we need to commit the entry now. new_map . commit ( ) ; } catch ( Exception e ) { } // Duplicate keys can be ignored, this means we already have the value try { // If transaction status is deleted we need to now attach to the transaction id and remove. if ( transaction_status == TransactionalBidiTreeMap . Node . DELETED ) { new_map . attach ( transaction_id ) ; new_map . remove ( key ) ; } } catch ( Exception e ) { } // The entry may have already been deleted // Finally detach new_map . detach ( ) ; } } // Then do added for ( Iterator < Entry < K , V > > i = allEntrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { TransactionalBidiTreeMap . Node < K , V > entry = ( TransactionalBidiTreeMap . Node < K , V > ) i . next ( ) ; key = entry . getKey ( ) ; val = entry . getValue ( ) ; transaction_status = entry . getStatus ( ) ; transaction_id = entry . getTransactionId ( ) ; if ( transaction_status == TransactionalBidiTreeMap . Node . ADDED ) { // As the transaction status is added then attach to the transaction id before putting. new_map . attach ( transaction_id ) ; try { // Put the value against the key new_map . put ( key , val ) ; } catch ( Exception e ) { } // Duplicate keys can be ignored, this means we already have the value // Finally detach new_map . detach ( ) ; } } } else { for ( Iterator < Entry < K , V > > i = allEntrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { TransactionalBidiTreeMap . Node < K , V > entry = ( TransactionalBidiTreeMap . Node < K , V > ) i . next ( ) ; key = entry . getKey ( ) ; val = entry . getValue ( ) ; try { new_map . put ( key , val ) ; } catch ( Exception e ) { } // Duplicate keys can be ignored, this means we already have the value } } }
Copy all entries including transaction statuses from this map into the supplied map . Do not use this method unless you know exactly what you are doing . The auto commit flag of the supplied map may be changed as a result of calling this method check that this is valid first .