如何在 Smalltalk 中管理二维数组? [英] How to manage 2d array in Smalltalk?

查看:44
本文介绍了如何在 Smalltalk 中管理二维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个点列表,必须进行腐蚀/膨胀操作.我需要一种二维数组,但在 VisualWorks 中找不到方法(我知道 Squeak 中有一个 Array2d 类,但我必须使用 VW).

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

推荐答案

使用简单的通用方式:数组数组:

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

这篇关于如何在 Smalltalk 中管理二维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆