-
Notifications
You must be signed in to change notification settings - Fork 0
Grid
Dickson Law edited this page Apr 12, 2023
·
5 revisions
A data structure that stores entries in a compact unit of set width and height, and allows access by x-y coordinates. Equivalent to DS Grids.
An iterator class designed to efficiently loop through the given disk region of the grid in linear time, skippping any points past the boundaries of the grid. It stores its current grid position in x and y, and its current value in value.
-
hasNext(): Return whether there are more values to iterate. -
next(): Iterate to the next value. -
set(val): Set the current value in the grid to the given value.
An iterator class designed to efficiently loop through the given rectangular region of the grid in linear time, skipping any points past the boundaries of the grid. It stores its current grid position in x and y, and its current value in value.
-
hasNext(): Return whether there are more values to iterate. -
next(): Iterate to the next value. -
set(val): Set the current value in the grid to the given value.
-
add(x, y, val): Seeds_grid_add(id, x, y, val). -
addDisk(xm, ym, r, val): Seeds_grid_add_disk(id, xm, ym, r, val). -
addGridRegion(sourceGrid, x1, y1, x2, y2, xpos, ypos): Seeds_grid_add_grid_region(index, source, x1, y1, x2, y2, xpos, ypos);. -
addRegion(x1, y1, x2, y2, val): Seeds_grid_add_region(id, x1, y1, x2, y2, val). -
clear(): Seeds_grid_clear(id). -
copy(sourceGrid): Seeds_grid_copy(id, source). -
get(x, y): Seeds_grid_get(id, x, y). -
getDiskMax(xm, ym, r): Seeds_grid_get_disk_max(id, xm, ym, r). -
getDiskMean(xm, ym, r): Seeds_grid_get_disk_mean(id, xm, ym, r). -
getDiskMin(xm, ym, r): Seeds_grid_get_disk_min(id, xm, ym, r). -
getDiskSum(xm, ym, r): Seeds_grid_get_disk_sum(id, xm, ym, r). -
getMax(x1, y1, x2, y2): Seeds_grid_get_max(id, x1, y1, x2, y2). -
getMean(x1, y1, x2, y2): Seeds_grid_get_mean(id, x1, y1, x2, y2). -
getMin(x1, y1, x2, y2): Seeds_grid_get_min(id, x1, y1, x2, y2). -
getSum(x1, y1, x2, y2): Seeds_grid_get_sum(id, x1, y1, x2, y2). -
height(): Seeds_grid_height(id). -
multiply(x, y, val): Seeds_grid_multiply(id, x, y, val). -
multiplyDisk(xm, ym, r, val): Seeds_grid_multiply_disk(id, xm, ym, r, val). -
multiplyGridRegion(sourceGrid, x1, y1, x2, y2): Seeds_grid_multiply_grid_region(index, source, x1, y1, x2, y2, xpos, ypos);. -
multiplyRegion(x1, y1, x2, y2, val): Seeds_grid_multiply_region(id, x1, y1, x2, y2, val). -
read(datastr): Seeds_grid_read(id, string). -
resize(w, h): Seeds_grid_resize(id, w, h). -
set(x, y, val): Seeds_grid_set(id, x, y, val). -
setDisk(xm, ym, r, val): Seeds_grid_set_disk(id, xm, ym, r, val). -
setGridRegion(sourceGrid, x1, y1, x2, y2, xpos, ypos): See:ds_grid_set_grid_region(index, source, x1, y1, x2, y2, xpos, ypos). -
setRegion(x1, y1, x2, y2, val): Seeds_grid_set_region(id, x1, y1, x2, y2, val). -
shuffle(): Seeds_grid_shuffle(id). -
sort(column, [ascending], [keyer], [comparer]): Seeds_grid_sort(id, col, ascending). Special: You can optionally specify akeyermethod taking a value and returning the value in it to compare (e.g.function(entry) { return entry.points; }for sorting entries by points), and acomparermethod taking two valuesaandband returning true ifa > b(e.g.function(v1, v2) { return sqr(v1[0])+sqr(v1[1]) > sqr(v2[0])+sqr(v2[1]); }for sorting 2D vectors by length). -
valueDiskExists(xm, ym, r, val): Seeds_grid_value_disk_exists(id, xm, ym, r, val). -
valueDiskX(xm, ym, r, val): Seeds_grid_value_disk_x(id, xm, ym, r, val). -
valueDiskY(xm, ym, r, val): Seeds_grid_value_disk_y(id, xm, ym, r, val). -
valueExists(x1, y1, x2, y2, val): Seeds_grid_value_exists(id, x1, y1, x2, y2, val). -
valueX(x1, y1, x2, y2, val): Seeds_grid_value_x(id, x1, y1, x2, y2, val). -
valueY(x1, y1, x2, y2, val): Seeds_grid_value_y(id, x1, y1, x2, y2, val). -
width(): Seeds_grid_width(id). -
write(): Seeds_grid_write(id).
-
clone(): Return a shallow clone of the grid. -
cloneDeep(): Same asclone(), but also making deep copies of everything in the grid. -
copyDeep(sourceGrid): Same ascopy(sourceGrid), but with deep copies of everything in the source. -
diskIterator(xm, ym, r): Return a newGridDiskIteratorset to track a disk region in this grid. -
forEach(func): Call the method or scriptfuncfor each value in the grid. On each iteration, it will be passed the current value followed by the current X and Y positions. -
forEachInDisk(func, xm, ym, r): Call the method or scriptfuncfor each value in the disk on the grid. On each iteration, it will be passed the current value followed by the current X and Y positions. -
forEachInRegion(func, x1, y1, x2, y2): Call the method or scriptfuncfor each value in the region on the grid. On each iteration, it will be passed the current value followed by the current X and Y positions. -
iterator(): Return a newGridRegionIteratorset to track the entire grid. -
mapEach(func): Set each valuevin the grid tofunc(v). -
mapEachInDisk(func, xm, ym, r): Set each valuevin the disk on the grid tofunc(v). -
mapEachInRegion(func, x1, y1, x2, y2): Set each valuevin the region on the grid tofunc(v). -
regionIterator(x1, y1, x2, y2): Return a newGridRegionIteratorset to track a rectangular region in this grid. -
shuffleRows(): Shuffle the rows of the grid, keeping those on the same row together. -
to2dArray(): Return the grid's contents in 2D array form. Note that this is a shallow conversion --- other grids nested inside will remain as grids in the returned array.