• splice rows of a row-major 2D array and optionally insert new rows at the specified start index.

    Type Parameters

    • T

    Parameters

    • arr2d: Array2DRowMajor<T>

      the row-major 2D array to be spliced.

    • start: number

      the row-index at which to start changing the array.

    • Optional delete_count: number

      the number of rows to remove. if undefined, all rows from start to the end of the array will be removed.

    • Rest ...insert_items: Array2DRowMajor<T>

      optionally insert row-major based 2D array items the index of start.

    Returns Array2DRowMajor<T>

    a new row-major 2D array containing the deleted rows.

    Example

    delete 1 row from arr2d (starting at row-index 1), and insert 2 new rows in its place.

    const arr2d: Array2DRowMajor<number> = [
    [1 , 2 , 3 , 4 , 5 ],
    [6 , 7 , 8 , 9 , 10],
    [11, 12, 13, 14, 15],
    ]
    const deleted_rows = spliceArray2DMajor(arr2d, 1, 1,
    [21, 22, 23, 24, 25],
    [31, 32, 33, 34, 35]
    )
    arr2d === [
    [1 , 2 , 3 , 4 , 5 ],
    [21, 22, 23, 24, 25],
    [31, 32, 33, 34, 35],
    [11, 12, 13, 14, 15],
    ]
    deleted_rows === [
    [6 , 7 , 8 , 9 , 10],
    ]

Generated using TypeDoc