diff --git a/src/Containers-Array2D-Tests/CTNewArray2DTest.class.st b/src/Containers-Array2D-Tests/CTNewArray2DTest.class.st index fed2802..e0cb082 100644 --- a/src/Containers-Array2D-Tests/CTNewArray2DTest.class.st +++ b/src/Containers-Array2D-Tests/CTNewArray2DTest.class.st @@ -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 [ diff --git a/src/Containers-Array2D/CTNewArray2D.class.st b/src/Containers-Array2D/CTNewArray2D.class.st index ab24bf8..8599443 100644 --- a/src/Containers-Array2D/CTNewArray2D.class.st +++ b/src/Containers-Array2D/CTNewArray2D.class.st @@ -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 " @@ -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 [