Skip to content

Main content

Ordered Set Neighbor Insertion Rank Tool

Calculate ordered set neighbor insertion rank from explicit caller-supplied inputs.

Loading tool…

Description

Locate a new value in a strictly increasing numeric sorted list and return zero-based insertion rank, predecessor, successor, and presence flags.

A finite set records membership, while a multiset also records multiplicity. An ordered set adds an ordering rule, and an interval adds endpoint-closure choices. A witness for one element, a count budget, and equality of complete sets establish different facts.

Locate a new value in a strictly increasing numeric sorted list and return zero-based insertion rank, predecessor, successor, and presence flags.

When to use this tool

Use Ordered Set Neighbor Insertion Rank when you need the stated finite-set, interval, multiplicity, membership, or ordering operation under the given equality convention.

How to use the tool and how it works

  1. Enter sorted, value. 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 rank, predecessor, successor, hasPredecessor, hasSuccessor. Inspect hasPredecessor, hasSuccessor before interpreting the associated values.

Locate a new value in a strictly increasing numeric sorted list and return zero-based insertion rank, predecessor, successor, and presence flags. Reject an existing value.1

Input fieldMeaning and unitsAccepted input
sortedSortedRequired. Array of finite number; maximum items 256.
valueValueRequired. Finite number.
Output fieldInterpretationReturned shape
rankRankRequired. Safe integer.
predecessorNumeric neighbor or zero placeholder; check hasPredecessor.Required. Finite number.
successorNumeric neighbor or zero placeholder; check hasSuccessor.Required. Finite number.
hasPredecessorHas PredecessorRequired. Boolean.
hasSuccessorHas SuccessorRequired. Boolean.
json
{
  "input": {
    "sorted": [
      2,
      5,
      8
    ],
    "value": 6
  },
  "output": {
    "rank": 2,
    "predecessor": 5,
    "successor": 8,
    "hasPredecessor": true,
    "hasSuccessor": true
  }
}

Limitations and assumptions

  • Missing neighbors use zero placeholders, so inspect hasPredecessor and hasSuccessor. The tool does not insert the value or infer sorting tolerances or a different ordering relation.
  • The field tables state structural bounds; the mechanics also specify cross-field constraints. Malformed inputs and unsupported domains cause errors. A successful false flag, empty branch value, or zero placeholder has the meaning stated above and is distinct from an input error.
  • 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. Signed zero is exported as zero.

Alternative or Complementary methods

Use a full set operation when one element or count cannot establish the required relation. Preserve the distinction between strings, typed scalar atoms, nested sets, ordered lists, and multisets.

References

  1. Calculation and input contract: set/ordered-set-neighbor-insertion-rank — tool.io

Similar or alternative tools