protected List < Versioned < V > > resolveAndConstructVersionsToPersist ( List < Versioned < V > > valuesInStorage , List < Versioned < V > > multiPutValues ) { List < Versioned < V >> obsoleteVals = new ArrayList < Versioned < V > > ( multiPutValues . size ( ) ) ; // Go over all the values and determine whether the version is // acceptable for ( Versioned < V > value : multiPutValues ) { Iterator < Versioned < V >> iter = valuesInStorage . iterator ( ) ; boolean obsolete = false ; // Compare the current version with a set of accepted versions while ( iter . hasNext ( ) ) { Versioned < V > curr = iter . next ( ) ; Occurred occurred = value . getVersion ( ) . compare ( curr . getVersion ( ) ) ; if ( occurred == Occurred . BEFORE ) { obsolete = true ; break ; } else if ( occurred == Occurred . AFTER ) { iter . remove ( ) ; } } if ( obsolete ) { // add to return value if obsolete obsoleteVals . add ( value ) ; } else { // else update the set of accepted versions valuesInStorage . add ( value ) ; } } return obsoleteVals ; }
Computes the final list of versions to be stored on top of what is currently being stored . Final list is valuesInStorage modified in place