Skip to content

Commit

Permalink
added filling if considered empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzo-Demeulenaere committed Jul 22, 2024
1 parent 925a0c6 commit ce1e84d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Containers-Array2D-Tests/CTNewArray2DTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ CTNewArray2DTest >> testExtentFromArray [
self assert: (foo at: 3 @ 2) equals: 6
]

{ #category : 'tests' }
CTNewArray2DTest >> testFillIfEmpty [

| array |
array := CTNewArray2D width: 2 height: 3.

self assert: array isEmpty.

array fillIfEmpty.

self deny: array isEmpty.
]

{ #category : 'tests' }
CTNewArray2DTest >> testFromArray [

Expand Down
17 changes: 17 additions & 0 deletions src/Containers-Array2D/CTNewArray2D.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ CTNewArray2D >> extent: extent fromArray: anArray [
contents := anArray
]

{ #category : 'as yet unclassified' }
CTNewArray2D >> fillIfEmpty [

self isEmpty ifFalse: [ ^ self ].

self tabulate: [ :x :y | MygAbstractBox new ].

^ self

]

{ #category : 'enumerating' }
CTNewArray2D >> fromBottomToTopFromLeftToRightDo: aBlock [
"Apply a block to each element following that order bottom to top but from left gto right "
Expand Down Expand Up @@ -341,6 +352,12 @@ CTNewArray2D >> indexOfX: x y: y [
^ (y - 1) * width + x
]

{ #category : 'testing' }
CTNewArray2D >> isEmpty [

^ self contents includes: nil
]

{ #category : 'inspector' }
CTNewArray2D >> isSelfEvaluating [

Expand Down

0 comments on commit ce1e84d

Please sign in to comment.