通过数组进行特殊迭代 [英] special iteration through an array

查看:63
本文介绍了通过数组进行特殊迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个20x16的对象数组。

我需要一种迭代数组的方法,只考虑几行和几行
列。


为了更清楚,有时我只需要前2行和后3列

循环考虑

另一次,我只需要考虑到前3列和后4行

...

无论如何,我在同一次迭代中不会有单独的行或列...

所以,从来没有像前3行和后2行......或前2列

和最后3列


只有行和列,最后是r。


任何想法如何实现?


-

干杯,

Crirus


---------------------- --------

如果工作是件好事,老板会把这一切都从你那里拿走


------- -----------------------

解决方案

不是如果这是你想要的,我还没有测试过,只需用记事本写的



Const xSize As Integer = 20

Const ySize As Integer = 16

Dim Skips(xSize,ySize)as Boolean

Dim MyObjects(xSize,ySize)as Object

Dim xCount As Integer = 0

Dim yCount As Integer = 0


''设置全部跳到错误

For yCount = 0到yMax-1步骤1

xCount = 0到yMax-1 Step1

跳过(xCount,yCount)= False

下一页

下一页


''设置行和列以跳过例如。

Skips(9,3)= Frue


yCount = 0到ySize-1第1步


xCount = 0到xSize-1第1步


如果跳过(xCount,yCount)那么

''跳过动作

否则

''做动作
结束如果


下一页

下一页

问候 - OHM






Cri rus写道:

我有一个20x16的对象数组。
我需要一种迭代数组的方法,只考虑几行
和几列。

为了更清楚,有时我只需要前两行和后三列
要考虑循环
另一次,我只需要前3列和后4行
考虑到......

无论如何,我在同一个迭代中不会有单独的行或列...所以,从来没有像前3行和后2行......
或前2列和后3列

只有行和列,最后是r。

任何想法如何实现?



问候 - OHM#OneHandedMan {at} BTInternet {dot} com


*" Crirus" <铬**** @ datagroup.ro> scripsit:

我有一个20x16的对象数组。
我需要一种迭代数组的方法,只考虑几行和几列。
另一次,我只需要前3列和后4行就可以了
考虑到......

无论如何,我在同一次迭代中不会有单独的行或列......
所以,从来没有像前3行和后2行......或者先行2列
和最后3列

只有行和列,最后是r。

任何想法如何实现?




将索引存储在2个数组中并循环遍历数组,获取2个索引数组中的

值并访问数组中的值。 />

-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>


嗨Crirus


就像其他用这封邮件写的那样真伪我想到了这个

这个

\\\

mySelectedArray as myarrayfunction(R,3,2)

函数myarrayfunction(firstIs,rows,columns)

if firstis =" ; R"然后

RowIndexStart = 0

RowIndexEnd =行

ColIndexStart = coltable.length - (列+ 1)

ColIndexEnd = coltable.length - 1

else

RowIndexStart = rowtable.length - (rows + 1)

RowIndexEnd = rowtable.length - 1

ColIndexStart = 0

ConIndexEnd = columns

结束如果

///

然后正常嵌套下一个循环


Cor

我有一个20x16的对象数组。
我需要一种方法来迭代数组,只考虑几行和
几列。

为了更清楚,有时我只需要前两行和最后三列才能在循环中考虑
还有一次,我只需要前3列和后4行来考虑...

无论如何,我在同一次迭代中不会有单独的行或列...
所以,从来没有像前3行和后2行......或者前2个
列和最后3列

只有行和列,最后是r。

任何想法如何实现?

- <干杯,
Crirus

------------------------------
------------------------- -----



I have a 20x16 array of objects.
I need a way to iterate through the array and only consider few rows and few
columns.

To be clearer, sometimes I need only first 2 rows and last 3 columns to be
considered in loop
Another time, I whould need only first 3 columns and last 4 rows to be
considered...

Anyhow, I will not have separate rows or columns in the same iteration...
So, never something like first 3 rows and last 2 rows... or first 2 columns
and last 3 columns

only rows and columns, at the beginning r at the end.

Any ideea how to implement that?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

解决方案

Not totally sure if this is what you want, I have not tested it, just
written in Notepad.

Const xSize As Integer = 20
Const ySize As Integer = 16
Dim Skips( xSize,ySize ) as Boolean
Dim MyObjects(xSize,ySize) as Object
Dim xCount As Integer = 0
Dim yCount As Integer = 0

''Setup All Skips to False
For yCount=0 to yMax-1 Step 1
For xCount=0 to yMax-1 Step1
Skips(xCount,yCount)=False
Next
Next

''Set up rows and cols to skip for example.
Skips(9,3) = Frue

For yCount=0 to ySize-1 Step 1

For xCount=0 to xSize-1 step 1

if Skips(xCount,yCount) Then
''Skip Action
Else
''Do Action
End If

Next
Next
Regards - OHM






Crirus wrote:

I have a 20x16 array of objects.
I need a way to iterate through the array and only consider few rows
and few columns.

To be clearer, sometimes I need only first 2 rows and last 3 columns
to be considered in loop
Another time, I whould need only first 3 columns and last 4 rows to be
considered...

Anyhow, I will not have separate rows or columns in the same
iteration... So, never something like first 3 rows and last 2 rows...
or first 2 columns and last 3 columns

only rows and columns, at the beginning r at the end.

Any ideea how to implement that?



Regards - OHM# OneHandedMan{at}BTInternet{dot}com


* "Crirus" <Cr****@datagroup.ro> scripsit:

I have a 20x16 array of objects.
I need a way to iterate through the array and only consider few rows and few
columns.

To be clearer, sometimes I need only first 2 rows and last 3 columns to be
considered in loop
Another time, I whould need only first 3 columns and last 4 rows to be
considered...

Anyhow, I will not have separate rows or columns in the same iteration...
So, never something like first 3 rows and last 2 rows... or first 2 columns
and last 3 columns

only rows and columns, at the beginning r at the end.

Any ideea how to implement that?



Store the indices in 2 arrays and loop through the arrays, get the
values in the 2 index arrays and access the value in the array.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Hi Crirus

Just like the others written in this mail and true pseudo my thought about
this
\\\
mySelectedArray as myarrayfunction("R",3,2)
function myarrayfunction (firstIs, rows,columns)
if firstis = "R" then
RowIndexStart = 0
RowIndexEnd = rows
ColIndexStart = coltable.length - (columns + 1)
ColIndexEnd = coltable.length - 1
else
RowIndexStart = rowtable.length - (rows + 1)
RowIndexEnd = rowtable.length - 1
ColIndexStart = 0
ConIndexEnd = columns
end if
///
And then a normal nested for next loop

Cor

I have a 20x16 array of objects.
I need a way to iterate through the array and only consider few rows and few columns.

To be clearer, sometimes I need only first 2 rows and last 3 columns to be
considered in loop
Another time, I whould need only first 3 columns and last 4 rows to be
considered...

Anyhow, I will not have separate rows or columns in the same iteration...
So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns

only rows and columns, at the beginning r at the end.

Any ideea how to implement that?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------



这篇关于通过数组进行特殊迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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