Function
createFp
(
k: number,
M: number,
routes: Uint32Array,
diffTypesPtrOffset: number,
ptr: number,
slide?: FarthestPoint,
down?: FarthestPoint,
)
Source from the content-addressed store, hash-verified
| 186 | * ``` |
| 187 | */ |
| 188 | export function createFp( |
| 189 | k: number, |
| 190 | M: number, |
| 191 | routes: Uint32Array, |
| 192 | diffTypesPtrOffset: number, |
| 193 | ptr: number, |
| 194 | slide?: FarthestPoint, |
| 195 | down?: FarthestPoint, |
| 196 | ): FarthestPoint { |
| 197 | if (slide && slide.y === -1 && down && down.y === -1) { |
| 198 | return { y: 0, id: 0 }; |
| 199 | } |
| 200 | const isAdding = (down?.y === -1) || |
| 201 | k === M || |
| 202 | (slide?.y ?? 0) > (down?.y ?? 0) + 1; |
| 203 | if (slide && isAdding) { |
| 204 | const prev = slide.id; |
| 205 | ptr++; |
| 206 | routes[ptr] = prev; |
| 207 | routes[ptr + diffTypesPtrOffset] = ADDED; |
| 208 | return { y: slide.y, id: ptr }; |
| 209 | } |
| 210 | if (down && !isAdding) { |
| 211 | const prev = down.id; |
| 212 | ptr++; |
| 213 | routes[ptr] = prev; |
| 214 | routes[ptr + diffTypesPtrOffset] = REMOVED; |
| 215 | return { y: down.y + 1, id: ptr }; |
| 216 | } |
| 217 | throw new Error("Unexpected missing FarthestPoint"); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Renders the differences between the actual and expected values. |
Tested by
no test coverage detected