Skip to content

added check if empty and filling #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 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
Loading