public boolean compareAndSet(V   expectedReference,
                                 V   newReference,
                                 int expectedStamp,
                                 int newStamp) {
        Pair<V> current = pair;
        return
            expectedReference == current.reference &&
            expectedStamp == current.stamp &&
            ((newReference == current.reference &&
              newStamp == current.stamp) ||
             casPair(current, Pair.of(newReference, newStamp)));
    }
public boolean compareAndSet ( V expectedReference , V newReference , int expectedStamp , int newStamp ) { Pair < V > current = pair ; return expectedReference == current . reference && expectedStamp == current . stamp && ( ( newReference == current . reference && newStamp == current . stamp ) || casPair ( current , Pair . of ( newReference , newStamp ) ) ) ; }
Atomically sets the value of both the reference and stamp
to the given update values if the
current reference is {@code ==} to the expected reference
and the current stamp is equal to the expected stamp.

@param expectedReference the expected value of the reference
@param newReference the new value for the reference
@param expectedStamp the expected value of the stamp
@param newStamp the new value for the stamp
@return {@code true} if successful