Skip to content

Commit b97ed14

Browse files
committed
Docs: Add method comments to grid wrapping and neighbor logic
1 parent cdad99e commit b97ed14

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Containers-Array2D/CTArray2D.class.st

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ CTArray2D >> atColumn: x put: aCollection [
195195

196196
{ #category : 'accessing' }
197197
CTArray2D >> atColumnWrap: col atRowWrap: row [
198+
"Answer the element at the given coordinates. If the coordinates are outside the grid bounds, they wrap around using 1-based indexing logic to ensure seamless boundary traversal."
198199

199200
| wrappedCol wrappedRow |
200201
wrappedCol := ((col - 1) \\ self width) + 1.
@@ -205,7 +206,8 @@ CTArray2D >> atColumnWrap: col atRowWrap: row [
205206

206207
{ #category : 'accessing' }
207208
CTArray2D >> atColumnWrap: col atRowWrap: row put: aValue [
208-
209+
"Store the given value at the specified coordinates. If the coordinates are outside the grid bounds, they wrap around using 1-based indexing logic (e.g., in a grid of width 3, column 4 wraps to 1, and column 0 wraps to 3)."
210+
209211
| wrappedCol wrappedRow |
210212
wrappedCol := ((col - 1) \\ self width) + 1.
211213
wrappedRow := ((row - 1) \\ self height) + 1.
@@ -375,7 +377,8 @@ CTArray2D >> isSelfEvaluating [
375377

376378
{ #category : 'enumerating' }
377379
CTArray2D >> neighborsAtColumn: col atRow: row [
378-
380+
"Answer a collection of up to 8 valid elements surrounding the given origin. This method does not wrap; neighbors that would fall outside the grid are ignored. Throws an error if the starting origin coordinates are out of bounds."
381+
379382
| neighbors |
380383

381384
(col between: 1 and: self width) ifFalse: [ self error: 'Column out of bounds' ].
@@ -395,7 +398,8 @@ CTArray2D >> neighborsAtColumn: col atRow: row [
395398

396399
{ #category : 'enumerating' }
397400
CTArray2D >> neighborsAtColumnWrap: col atRowWrap: row [
398-
401+
"Answer a collection of exactly 8 elements surrounding the given origin, wrapping across grid boundaries where necessary. Throws an error if the starting origin coordinates are out of bounds."
402+
399403
| neighbors |
400404

401405
(col between: 1 and: self width) ifFalse: [ self error: 'Column out of bounds' ].

0 commit comments

Comments
 (0)