UNPKG

10.8 kBTypeScriptView Raw
1import type { NumericArray, TypedArray } from "./typedarray.js";
2export interface INDBase<BUF extends any[] | TypedArray = any[]> {
3 size: NumericArray;
4 stride: NumericArray;
5 offset: number;
6 data: BUF;
7 readonly dim: number;
8 order(): number[];
9}
10/**
11 * Semi-typechecked interface for cases accepting 1D-4D grids, i.e.
12 * {@link IGrid1D} - {@link IGrid4D}.
13 */
14export interface IGridND<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
15 /**
16 * Returns true if given position is valid (i.e. within grid bounds).
17 *
18 * @param pos -
19 */
20 includes(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): boolean;
21 /**
22 * Returns index for given position. Returns negative value if outside the
23 * grid's defined region.
24 *
25 * @param pos -
26 */
27 indexAt(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): number;
28 /**
29 * Non-boundschecked version of {@link IGridND.indexAt}. Assumes given
30 * position is valid.
31 *
32 * @param pos -
33 */
34 indexAtUnsafe(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): number;
35 /**
36 * Returns value at given position. If outside the grid's defined region,
37 * returns a suitable zero value.
38 *
39 * @param pos -
40 */
41 getAt(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
42 /**
43 * Non-boundschecked version of {@link IGridND.getAt}. Assumes given
44 * position is valid.
45 *
46 * @param pos -
47 */
48 getAtUnsafe(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
49 /**
50 * Writes value at given position. Has no effect if outside of the defined
51 * region. Returns true, if succeeded.
52 *
53 * @param args -
54 */
55 setAt(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
56 /**
57 * Non-boundschecked version of {@link IGridND.setAt}. Assumes given
58 * position is valid. Returns true, if succeeded.
59 *
60 * @param args -
61 */
62 setAtUnsafe(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
63}
64/**
65 * Gridlike container for 1D accessible data.
66 *
67 * @remarks
68 * See {@link IGrid1DMixin} for mixin implementation.
69 */
70export interface IGrid1D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
71 readonly dim: 1;
72 /**
73 * Returns true if given position is valid (i.e. within grid bounds).
74 *
75 * @param d0 -
76 */
77 includes(d0: number): boolean;
78 /**
79 * Returns index for given position. Returns negative value if outside the
80 * grid's defined region.
81 *
82 * @param d0 -
83 */
84 indexAt(d0: number): number;
85 /**
86 * Non-boundschecked version of {@link IGrid1D.indexAt}. Assumes given
87 * position is valid.
88 *
89 * @param d0 -
90 */
91 indexAtUnsafe(d0: number): number;
92 /**
93 * Returns value at given position. If outside the grid's defined region,
94 * returns a suitable zero value.
95 *
96 * @param d0 -
97 */
98 getAt(d0: number): T;
99 /**
100 * Non-boundschecked version of {@link IGrid1D.getAt}. Assumes given
101 * position is valid.
102 *
103 * @param d0 -
104 */
105 getAtUnsafe(d0: number): T;
106 /**
107 * Writes value at given position. Has no effect if outside of the defined
108 * region. Returns true, if succeeded.
109 *
110 * @param d0 -
111 * @param value -
112 */
113 setAt(d0: number, value: T): boolean;
114 /**
115 * Non-boundschecked version of {@link IGrid1D.setAt}. Assumes given
116 * position is valid. Returns true, if succeeded.
117 *
118 * @param d0 -
119 * @param value -
120 */
121 setAtUnsafe(d0: number, value: T): boolean;
122}
123/**
124 * Gridlike container for 2D accessible data.
125 *
126 * @remarks
127 * See {@link IGrid2DMixin} for mixin implementation.
128 */
129export interface IGrid2D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
130 readonly dim: 2;
131 /**
132 * Returns true if given position is valid (i.e. within grid bounds).
133 *
134 * @param d0 -
135 * @param d1 -
136 */
137 includes(d0: number, d1: number): boolean;
138 /**
139 * Returns index for given position (stated in same order as
140 * {@link IGrid2D.size} and {@link IGrid2D.stride}). Returns negative value
141 * if outside the grid's defined region.
142 *
143 * @param d0 -
144 * @param d1 -
145 */
146 indexAt(d0: number, d1: number): number;
147 /**
148 * Non-boundschecked version of {@link IGrid2D.indexAt}. Assumes given
149 * position is valid.
150 *
151 * @param d0 -
152 * @param d1 -
153 */
154 indexAtUnsafe(d0: number, d1: number): number;
155 /**
156 * Returns value at given position (given in same order as
157 * {@link IGrid2D.size} and {@link IGrid2D.stride}). If outside the grid's
158 * defined region, returns a suitable zero value.
159 *
160 * @param d0 -
161 * @param d1 -
162 */
163 getAt(d0: number, d1: number): T;
164 /**
165 * Non-boundschecked version of {@link IGrid2D.getAt}. Assumes given
166 * position is valid.
167 *
168 * @param d0 -
169 * @param d1 -
170 */
171 getAtUnsafe(d0: number, d1: number): T;
172 /**
173 * Writes value at given position (given in same order as
174 * {@link IGrid2D.size} and {@link IGrid2D.stride}). Has no effect if
175 * outside of the defined region. Returns true, if succeeded.
176 *
177 * @param d0 -
178 * @param d1 -
179 * @param value -
180 */
181 setAt(d0: number, d1: number, value: T): boolean;
182 /**
183 * Non-boundschecked version of {@link IGrid2D.setAt}. Assumes given
184 * position is valid. Returns true, if succeeded.
185 *
186 * @param d0 -
187 * @param d1 -
188 * @param value -
189 */
190 setAtUnsafe(d0: number, d1: number, value: T): boolean;
191}
192/**
193 * Gridlike container for 3D accessible data.
194 *
195 * @remarks
196 * See {@link IGrid3DMixin} for mixin implementation.
197 */
198export interface IGrid3D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
199 readonly dim: 3;
200 /**
201 * Returns true if given position is valid (i.e. within grid bounds).
202 *
203 * @param d0 -
204 * @param d1 -
205 * @param d2 -
206 */
207 includes(d0: number, d1: number, d2: number): boolean;
208 /**
209 * Returns index for given position (stated in same order as
210 * {@link IGrid3D.size} and {@link IGrid3D.stride}). Returns negative value
211 * if outside the grid's defined region.
212 *
213 * @param d0 -
214 * @param d1 -
215 * @param d2 -
216 */
217 indexAt(d0: number, d1: number, d2: number): number;
218 /**
219 * Non-boundschecked version of {@link IGrid3D.indexAt}. Assumes given
220 * position is valid.
221 *
222 * @param d0 -
223 * @param d1 -
224 * @param d2 -
225 */
226 indexAtUnsafe(d0: number, d1: number, d2: number): number;
227 /**
228 * Returns value at given position (given in same order as
229 * {@link IGrid3D.size} and {@link IGrid3D.stride}). If outside the grid's
230 * defined region, returns a suitable zero value.
231 *
232 * @param d0 -
233 * @param d1 -
234 * @param d2 -
235 */
236 getAt(d0: number, d1: number, d2: number): T;
237 /**
238 * Non-boundschecked version of {@link IGrid3D.getAt}. Assumes given
239 * position is valid.
240 *
241 * @param d0 -
242 * @param d1 -
243 * @param d2 -
244 */
245 getAtUnsafe(d0: number, d1: number, d2: number): T;
246 /**
247 * Writes value at given position (given in same order as
248 * {@link IGrid3D.size} and {@link IGrid3D.stride}). Has no effect if
249 * outside of the defined region. Returns true, if succeeded.
250 *
251 * @param d0 -
252 * @param d1 -
253 * @param d2 -
254 * @param value -
255 */
256 setAt(d0: number, d1: number, d2: number, value: T): boolean;
257 /**
258 * Non-boundschecked version of {@link IGrid3D.setAt}. Assumes given
259 * position is valid. Returns true, if succeeded.
260 *
261 * @param d0 -
262 * @param d1 -
263 * @param d2 -
264 * @param value -
265 */
266 setAtUnsafe(d0: number, d1: number, d2: number, value: T): boolean;
267}
268/**
269 * Gridlike container for 4D accessible data.
270 *
271 * @remarks
272 * See {@link IGrid4DMixin} for mixin implementation.
273 */
274export interface IGrid4D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
275 readonly dim: 4;
276 /**
277 * Returns true if given position is valid (i.e. within grid bounds).
278 *
279 * @param d0 -
280 * @param d1 -
281 * @param d2 -
282 * @param d3 -
283 */
284 includes(d0: number, d1: number, d2: number, d3: number): boolean;
285 /**
286 * Returns index for given position (stated in same order as
287 * {@link IGrid4D.size} and {@link IGrid4D.stride}). Returns negative value
288 * if outside the grid's defined region.
289 *
290 * @param d0 -
291 * @param d1 -
292 * @param d2 -
293 * @param d3 -
294 */
295 indexAt(d0: number, d1: number, d2: number, d3: number): number;
296 /**
297 * Non-boundschecked version of {@link IGrid4D.indexAt}. Assumes given
298 * position is valid.
299 *
300 * @param d0 -
301 * @param d1 -
302 * @param d2 -
303 * @param d3 -
304 */
305 indexAtUnsafe(d0: number, d1: number, d2: number, d3: number): number;
306 /**
307 * Returns value at given position (given in same order as
308 * {@link IGrid4D.size} and {@link IGrid4D.stride}). If outside the grid's
309 * defined region, returns a suitable zero value.
310 *
311 * @param d0 -
312 * @param d1 -
313 * @param d2 -
314 * @param d3 -
315 */
316 getAt(d0: number, d1: number, d2: number, d3: number): T;
317 /**
318 * Non-boundschecked version of {@link IGrid4D.getAt}. Assumes given
319 * position is valid.
320 *
321 * @param d0 -
322 * @param d1 -
323 * @param d2 -
324 * @param d3 -
325 */
326 getAtUnsafe(d0: number, d1: number, d2: number, d3: number): T;
327 /**
328 * Writes value at given position (given in same order as
329 * {@link IGrid4D.size} and {@link IGrid4D.stride}). Has no effect if
330 * outside of the defined region. Returns true, if succeeded.
331 *
332 * @param d0 -
333 * @param d1 -
334 * @param d2 -
335 * @param d3 -
336 * @param value -
337 */
338 setAt(d0: number, d1: number, d2: number, d3: number, value: T): boolean;
339 /**
340 * Non-boundschecked version of {@link IGrid4D.setAt}. Assumes given
341 * position is valid. Returns true, if succeeded.
342 *
343 * @param d0 -
344 * @param d1 -
345 * @param d2 -
346 * @param d3 -
347 * @param value -
348 */
349 setAtUnsafe(d0: number, d1: number, d2: number, d3: number, value: T): boolean;
350}
351//# sourceMappingURL=grid.d.ts.map
\No newline at end of file