Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Containers-Array2D/CTAlternateArray2D.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ CTAlternateArray2D class >> width2Height3 [

{ #category : 'iterate' }
CTAlternateArray2D >> allPositionsDo: aBlock [
"Execute a Block on all the positions (points) of the receiver."
self firstPosition pointTo: self dimension do: aBlock
1 to: self width do: [ :x |
1 to: self height do: [ :y |
aBlock value: x@y ] ]
]

{ #category : 'iterate' }
CTAlternateArray2D >> allPositionsWithin: someDistance from: someOrigin [
CTAlternateArray2D >> allPositionsWithin: someDistance from: someOrigin [
| answer topLeft bottomRight |
answer := OrderedCollection new.
topLeft := someOrigin - someDistance max: self firstPosition.
bottomRight := someOrigin + someDistance min: self dimension.
topLeft pointTo: bottomRight do: [ :each | answer add: each ].

topLeft x to: bottomRight x do: [ :x |
topLeft y to: bottomRight y do: [ :y |
answer add: x@y ] ].

^ answer
]

Expand Down
Loading