Description
Shift selected right when at or beyond insertedAt.
An index map tracks where one item lands after a structural list operation. Zero-based element positions differ from boundary cursors, and missing destinations need a sentinel.
Shift selected right when at or beyond insertedAt.
When to use this tool
Use List Insert Delete Index Roundtrip when you need one item's position under an explicit list transformation.
How to use the tool and how it works
- Enter length, insertedAt, selected, deletedAt. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read index, removed. Inspect removed before interpreting the associated values.
Shift selected right when at or beyond insertedAt. Compare that shifted index with deletedAt, returning -1 if removed; otherwise account for a deletion strictly before it.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| length | Length, count, or code length under the stated domain and unit convention. | Required. Safe integer; minimum 1. |
| insertedAt | Inserted At | Required. Safe integer; minimum 0. |
| selected | Selected | Required. Safe integer; minimum 0. |
| deletedAt | Deleted At | Required. Safe integer; minimum 0. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| index | Zero-based position or diagnostic index under the calculation above; inspect any sentinel policy. | Required. Safe integer. |
| removed | Removed | Required. Boolean. |
{
"input": {
"length": 5,
"insertedAt": 2,
"selected": 3,
"deletedAt": 2
},
"output": {
"index": 3,
"removed": false
}
} Limitations and assumptions
- Deletion coordinates apply after insertion; the inserted value and list contents are not modeled.
- 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
Apply the operation to a small representative list when checking a consuming language's indexing and slicing semantics.
References
Similar or alternative tools
- List Delete Selected Index Map
Return -1 and removed true for selected deletion; otherwise subtract the number of deletions before selected.
- List Index After Stable Move
Map from to to; shift intervening positions left for a forward move or right for a backward move, leaving others unchanged.