views:

60

answers:

3

I have a list of point and have to do erosion/dilation operations. I need a kind of 2d-array but can't find how to do in VisualWorks (I know there is a Array2d class in Squeak, but I must use VW).

+2  A: 

Use simply a generic way: array of arrays:

(Array new: xSize)
    at: 1 put: ((Array new: ySize) at: 1 put: aValue; at: 2 put: aValue; ...);
    at: 2 put: ((Array new: ySize) at: 1 put: aValue; at: 2 put: aValue; ...);
    ...
Janko Mivšek
That was my first thought, but I thought it was pretty ugly and wondered if there was not a better way. But thanks for the answer, it shows me that it could be considered as acceptable way.
Serty Oan
+2  A: 

If you want to the operations to be efficient, study the VisualWorks Image class, protocol "image processing" and "bit processing". Build your own erosion/dilation operations based on primitives there.

Alan Wostenberg
+3  A: 

Many Smalltalk implementation will have some kind of Matrix class, sometimes optimized, that will have methods such as #rowAt:columnAt: (or for brevity #at:at:).

In GNU Smalltalk this is in package DhbNumericalMethods. Right now it is not optimized though.

Paolo Bonzini