* Insert another 2d array at specific coordinates. * If the inserted 2d array is greater than the 2d array this method is called on, * the inserted value will be trimmed to fit the current 2d array. * * @example Usage * ```ts * import { D2Array } from "@std/data-structures/unstable
(x: number, y: number, value: readonly T[][] | D2Array<T>)
| 275 | * @param value The 2d array to insert at the provided coordinates. |
| 276 | */ |
| 277 | insert(x: number, y: number, value: readonly T[][] | D2Array<T>) { |
| 278 | if (value instanceof D2Array) { |
| 279 | value = value.raw; |
| 280 | } |
| 281 | |
| 282 | for (let i = y; i < Math.min(this.raw.length, y + value.length); i++) { |
| 283 | const thisRow = this.raw[i]!; |
| 284 | const valueRow = value[i - y]!; |
| 285 | |
| 286 | for (let j = x; j < Math.min(thisRow.length, x + valueRow.length); j++) { |
| 287 | thisRow[j] = valueRow[j - x]!; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * The width of the 2d array. |
no test coverage detected