Skip to content

Main content

List Splice Cursor Affinity Tool

Map a boundary cursor through a splice using an explicit affinity inside the replaced interval.

Loading tool…

Description

Validate a cursor boundary and splice bounds.

A splice replaces part of a list and changes later positions. Cursor affinity defines which side of inserted content a boundary follows when the splice covers it.

Validate a cursor boundary and splice bounds.

When to use this tool

Use List Splice Cursor Affinity when you need a splice length, gap-fill, or cursor-mapping calculation.

How to use the tool and how it works

  1. Enter cursor, start, deleteCount, insertCount, affinity, length. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read newCursor, newLength. Use the output convention below.

Validate a cursor boundary and splice bounds. Keep cursors before start, shift those strictly after the deletion end, and map those at or within the replaced interval to start or start + insertCount according to affinity.1

Input fieldMeaning and unitsAccepted input
cursorZero-based boundary position in [0, length], including the terminal boundary.Required. Safe integer; minimum 0.
startStartRequired. Safe integer; minimum 0.
deleteCountDelete CountRequired. Safe integer; minimum 0.
insertCountInsert CountRequired. Safe integer; minimum 0.
affinityPlacement before or after inserted content when cursor lies on or inside the replaced interval.Required. Text; one of "before", "after"; maximum UTF-16 length 8192.
lengthLengthRequired. Safe integer; minimum 0.
Output fieldInterpretationReturned shape
newCursorBoundary cursor after applying the stated splice affinity.Required. Safe integer.
newLengthNew LengthRequired. Safe integer.
json
{
  "input": {
    "cursor": 3,
    "start": 3,
    "deleteCount": 0,
    "insertCount": 2,
    "affinity": "after",
    "length": 5
  },
  "output": {
    "newCursor": 5,
    "newLength": 7
  }
}

Limitations and assumptions

  • Both deletion endpoints use affinity, including a pure insertion at the cursor; this maps a boundary without changing list data.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Check the actual collection API's deletion clamping and cursor semantics before applying an edit.

References

  1. Calculation and input contract: list/list-splice-cursor-affinity — tool.io

Similar or alternative tools