CompareAndSwap<T extends Comparable> extension

Extension method that compares two values and swaps them if necessary.

This extension method can be used on any type that extends the Comparable class. It compares the current value with the other value and swaps them if the current value is greater. The method returns a tuple containing the updated values.

on
  • T

Methods

compareAndSwap(T other) Iterable<T>

Available on T, provided by the CompareAndSwap extension

Compares the current value with the other value and swaps them if necessary.