smalltalkmultidimensional-arrayvisualworks

How to manage 2d array in Smalltalk?


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).


Solution

  • 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; ...);
        ...