set
Replace the element at index with element, updating its weight as computed by weighter.
Preconditions:
indexmust be valid.new weight must be within bounds.
new weight must be >= left neighbor weight (if present) and <= right neighbor weight (if present).
If these checks fail, an IllegalStateException is thrown and the list remains unchanged.
Return
the previous element at index
Parameters
index
index to replace
element
new element
Throws
if index invalid
if new weight is out of bounds or violates neighboring order
Complexity: O(1) for update.