This method implements compare-and-swap

@param expected
@param newValue
@return true if value was swapped, false otherwise
356070
public boolean cas(T expected, T newValue) {
        try {
            lock.writeLock().lock();

            if (Objects.equals(value, expected)) {
                this.value = newValue;
                return true;
            } else
                return false;
        } finally {
            lock.writeLock().unlock();
        }
    }
816178
boolean valuesAreTheSameAsDefault()
    {
        if (getDefaultValues() == null || getDefaultValues().size() == 0)
            return false;
        if (getValues() == null || getValues().size() == 0)
            return false;
        if (getDefaultValues().size() != getValues().size())
            return false;
        for (int v = 0; v < getDefaultValues().size(); v++)
            if (!getDefaultValues().get(v).equals(getValues().get(v)))
                return false;
        return true;
    }
673584
public ObservableValueAssert<T> hasSameValue(ObservableValue<T> expectedValue) {
        new ObservableValueAssertions<>(actual).hasSameValue(expectedValue);
        return this;
    }
892527
def has_swapped(self):
        
        new_values = self._read_swap_count()
        for key, new_value in new_values.items():
            old_value = self.swap_count.get(key, 0)
            if new_value > old_value:
                return True
        return False
1117306
public void setNewVertexValue(VV newValue) {
		if (setNewVertexValueCalled) {
			throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
		}
		setNewVertexValueCalled = true;
		if (isOptDegrees()) {
			outValWithDegrees.f1.f0 = newValue;
			outWithDegrees.collect(outValWithDegrees);
		} else {
			outVal.setValue(newValue);
			out.collect(outVal);
		}
	}
1118189
public T set(final T newValue) {
        if(continuous!=null)
         continuous.offer(newValue);

        setDiscreteIfDiff(newValue);
        return newValue;
    }
103244
function swap(nodeA, nodeB){
    if (nodeA === nodeB || comparePosition(nodeA, nodeB) & (POSITION_CONTAINED_BY | POSITION_CONTAINS | POSITION_DISCONNECTED))
      return false;

    replace(nodeA, testElement);
    replace(nodeB, nodeA);
    replace(testElement, nodeB);

    return true;
  }
1305667
public static function isApply($currentValue, $expectedValue, $operator = self::EQUAL)
    {
        list($currentValue, $expectedValue) = self::convertValues($currentValue, $expectedValue, $operator);

        switch ($operator) {
            case self::LIKE:
                if (stripos($currentValue, $expectedValue) !== false) {
                    return true;
                }
                break;

            case self::LIKE_LEFT:
                $length = strlen($expectedValue);
                $start = 0 - $length;
                $searchedValue = substr($currentValue, $start, $length);
                if (stripos($searchedValue, $expectedValue) !== false) {
                    return true;
                }
                break;

            case self::LIKE_RIGHT:
                $length = strlen($expectedValue);
                $searchedValue = substr($currentValue, 0, $length);
                if (stripos($searchedValue, $expectedValue) !== false) {
                    return true;
                }
                break;

            case self::NOT_LIKE:
                if (stripos($currentValue, $expectedValue) === false) {
                    return true;
                }
                break;

            case self::NOT_LIKE_LEFT:
                $length = strlen($expectedValue);
                $start = 0 - $length;
                $searchedValue = substr($currentValue, $start, $length);
                if (stripos($searchedValue, $expectedValue) === false) {
                    return true;
                }
                break;

            case self::NOT_LIKE_RIGHT:
                $length = strlen($expectedValue);
                $searchedValue = substr($currentValue, 0, $length);
                if (stripos($searchedValue, $expectedValue) === false) {
                    return true;
                }
                break;

            case self::EQUAL:
            case self::IN:
                return $currentValue == $expectedValue;

            case self::NOT_EQUAL:
            case self::NOT_IN:
                return $currentValue != $expectedValue;

            case self::GREATER_EQUAL:
                return $currentValue >= $expectedValue;

            case self::GREATER:
                return $currentValue > $expectedValue;

            case self::LESS_EQUAL:
                return $currentValue <= $expectedValue;

            case self::LESS:
                return $currentValue < $expectedValue;

            case self::BETWEEN:
                if (is_array($expectedValue) && count($expectedValue) >= 2) {
                    if ($currentValue >= $expectedValue[0] && $currentValue <= $expectedValue[1]) {
                        return true;
                    }
                } else {
                    throw new InvalidArgumentException(
                        sprintf(
                            'Between needs exactly an array of two expected values. Give: "%s"',
                            print_r($expectedValue, true)
                        )
                    );
                }
                break;

            default:
                throw new InvalidArgumentException('currently not implemented filter type: "' . $operator . '"');
        }

        return false;
    }
1171897
public void setValue(String newValue, @Nullable String newName) {
        if (isChecked()) {
            searcher.updateFacetRefinement(this.attribute, value, false)
                    .updateFacetRefinement(newName != null ? newName : attribute, newValue, true)
                    .search();
        }
        this.value = newValue;
        applyEventualNewAttribute(newName);
    }
691365
void expectSwitchMatchesCase(Node n, JSType switchType, JSType caseType) {
    // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
    // but allowing extra autoboxing.
    // TODO(user): remove extra conditions when type annotations
    // in the code base have adapted to the change in the compiler.
    if (!switchType.canTestForShallowEqualityWith(caseType)
        && (caseType.autoboxesTo() == null || !caseType.autoboxesTo().isSubtypeOf(switchType))) {
      mismatch(n.getFirstChild(), "case expression doesn't match switch", caseType, switchType);
    } else if (!switchType.canTestForShallowEqualityWith(caseType)
        && (caseType.autoboxesTo() == null
            || !caseType.autoboxesTo().isSubtypeWithoutStructuralTyping(switchType))) {
      TypeMismatch.recordImplicitInterfaceUses(this.implicitInterfaceUses, n, caseType, switchType);
      TypeMismatch.recordImplicitUseOfNativeObject(this.mismatches, n, caseType, switchType);
    }
  }
680801
function( name, actual, expected ) {
		return this.ok( name, actual !== expected, this.notEqual, "\nValues should not match\nActual:" + actual + "\nExpected:" + expected );
	}
264623
private void swapHeapValues(int i, int j)
    {
        if(fastValueRemove == Mode.HASH)
        {
            valueIndexMap.put(heap[i], j);
            valueIndexMap.put(heap[j], i);
        }
        else if(fastValueRemove == Mode.BOUNDED)
        {
            //Already in the array, so just need to set
            valueIndexStore[heap[i]] = j;
            valueIndexStore[heap[j]] = i;
        }
        int tmp = heap[i];
        heap[i] = heap[j];
        heap[j] = tmp;
    }
1135402
public void setValue(byte[] newValue) throws Exception
    {
        Preconditions.checkState(state.get() == State.STARTED, "not started");

        Stat result = client.setData().forPath(path, newValue);
        updateValue(result.getVersion(), Arrays.copyOf(newValue, newValue.length));
    }
283947
function (newValue) {
		var oldValue = this._value;
		if (oldValue !== newValue) {
			this._value = newValue;
			this.trigger(EVENT_CHANGE, this, newValue, oldValue);
		}
	}
615366
public void setValueOff(String newValue, @Nullable String newName) {
            if (!isChecked()) { // refining on valueOff: facetRefinement needs an update
                searcher.updateFacetRefinement(attribute, valueOff, false)
                        .updateFacetRefinement(newName != null ? newName : attribute, newValue, true)
                        .search();
            }
        this.valueOff = newValue;
        applyEventualNewAttribute(newName);
    }
16038
public function isTransaction($newValue = null)
    {
        if (null !== $newValue) {
            $this->isTransaction = (bool) $newValue;
        }
        return $this->isTransaction;
    }
27866
public boolean setValueIfGreater(final int newValue) {
        final boolean greater = _value.setIfSignificantToUser(newValue);
        if (greater) {
            WidgetUtils.invokeSwingAction(() -> DCProgressBar.super.setValue(newValue));
        }
        return greater;
    }