优化问题 [英] Optimization issue

查看:64
本文介绍了优化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有512x512网格的布尔值

在我的应用程序的特定点,我需要找出一个特定的

我的网格中的点的值为true。


现在我需要一种方法来存储网格中每个坐标的布尔值。


我找到了一些方法:


1.我可以有一个512x512 BitArray类,比如P(x,y)〜

myBitArray(y * 512 + x)=真

简单的检查会告诉我特定点的价值

缺点:内存占用无理由


2.另一种方法是仅在数组中存储真值。每个值

y * 512 + x添加到数组中告诉我在p(x,y)中我有值True

缺点:搜索是否有像y这样的值*我的阵列中的512 + x可以是

长,设置一个新值意味着Redim保留阵列并且是时间

消失,对吧?

3.我可以使用带有y * -512 + x值的ArrayList和Add,Contains,Remove for

添加,测试,设置值。

缺点:没有iddea如果比其他方式更快或者多少

内存需求


无论如何,我需要分配最好的折衷内存 - 搜索价值 - 设置

a值


任何建议?


我知道我可以测试每一个,只希望有人有已经完成了它:)


-

干杯,

Crirus


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

如果工作是好事,老板会接受所有来自你的


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

Hello
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a particular
point in my grid have value true of false.

Now I need a way to store the boolean value for each coordinates in my grid.

I found some methods:

1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason

2. Another way is to store only the true values in an array. Each value
y*512+x added to the array tells me that in p(x,y) I have value True
Drawback: Search if there is a value like y*512 +x in my array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?

3. I could use ArrayList with y*-512+x values and Add, Contains, Remove for
adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how much
memory require

Anyway, I need the best compromise memory allocated - search for value - set
a value

Any advices?

I know I could test each one, just hope someone have allready done it :)

--
Cheers,
Crirus

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

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

推荐答案

为什么不


Dim BoolsGrid(511,511)As Boolean


' '访问255,255


如果BoolGrid(255,255)那么


''我发现它是真的


结束如果

问候 - OHM

Crirus写道:
Why not

Dim BoolsGrid(511,511) As Boolean

''Access 255,255

If BoolGrid(255,255) Then

''I Found It to be True

End If
Regards - OHM

Crirus wrote:
你好
我有512x512网格的布尔值
在我的应用程序中的某个特定点,我需要找出我的网格中的某个特定点是否值为false。

现在我需要一种方法来存储我的网格中每个坐标的布尔值。

我找到了一些方法:

1.我可以使用像P(x,y)这样的512x512 BitArray类)〜
myBitArray(y * 512 + x)= True
一个简单的检查会告诉我特定点的价值
缺点:内存占用无理由
2.另一种方法是仅在数组中存储真值。每个
值y * 512 + x添加到数组中告诉我在p(x,y)中我有值
True Drawback:搜索我的<是否有像y * 512 + x这样的值br />数组可以很长,设置一个新值意味着Redim保留数组并且是时间消失,对吧?

3.我可以使用带有y *的ArrayList - 512 + x值和添加,包含,
删除添加,测试,设置值。
缺点:没有iddea如果比其他方式更快或如何
大量内存需要值 - 设置一个值

任何建议?

我知道我可以测试每一个,只希望有人已经完成它
:)
Hello
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a
particular point in my grid have value true of false.

Now I need a way to store the boolean value for each coordinates in
my grid.

I found some methods:

1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason

2. Another way is to store only the true values in an array. Each
value y*512+x added to the array tells me that in p(x,y) I have value
True Drawback: Search if there is a value like y*512 +x in my
array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?

3. I could use ArrayList with y*-512+x values and Add, Contains,
Remove for adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how
much memory require

Anyway, I need the best compromise memory allocated - search for
value - set a value

Any advices?

I know I could test each one, just hope someone have allready done it
:)




-

最诚挚的问候 - OHM

O_H_M {at} BTInternet {dot} com



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


BoolGrid(511,511)需要与myBitArray.Length相同的备忘录(511 * 511) ??


-

干杯,

Crirus


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

如果工作是好的,老板会从你那里拿走这一切


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


单手男[OHM#] < O_H_M {在} BTInternet {点} COM>在消息中写道

news:ux ************** @ tk2msftngp13.phx.gbl ...
BoolGrid(511,511) require the same memoy as myBitArray.Length(511*511)??

--
Cheers,
Crirus

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

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

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl...
为什么不

Dim BoolsGrid(511,511)As Boolean

''访问255,255
如果BoolGrid(255,255)那么

''我找到了它是真的

结束如果

问候 - OHM

Crirus写道:
Why not

Dim BoolsGrid(511,511) As Boolean

''Access 255,255

If BoolGrid(255,255) Then

''I Found It to be True

End If
Regards - OHM

Crirus wrote:
你好
我有512x512的布尔网格
在我的应用程序的特定点,我需要找出我的网格中的特定点是否真的是假的。

现在我需要一种在我的网格中存储每个坐标的布尔值的方法。

我找到了一些方法:

1.我可以使用512x512 BitArray类P(x,y)〜
myBitArray(y * 512 + x)=真
一个简单的检查会告诉我特定点的值是什么
缺点:内存占用无理由

2.另一种方法是仅在数组中存储真值。每个
值y * 512 + x添加到数组中告诉我在p(x,y)中我有值
True Drawback:搜索我的<是否有像y * 512 + x这样的值br />数组可以很长,设置一个新值意味着Redim保留数组并且是时间消失,对吧?

3.我可以使用带有y *的ArrayList - 512 + x值和添加,包含,
删除添加,测试,设置值。
缺点:没有iddea如果比其他方式更快或如何
大量内存需要值 - 设置一个值

任何建议?

我知道我可以测试每一个,只希望有人已经完成它
:)
Hello
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a
particular point in my grid have value true of false.

Now I need a way to store the boolean value for each coordinates in
my grid.

I found some methods:

1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason

2. Another way is to store only the true values in an array. Each
value y*512+x added to the array tells me that in p(x,y) I have value
True Drawback: Search if there is a value like y*512 +x in my
array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?

3. I could use ArrayList with y*-512+x values and Add, Contains,
Remove for adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how
much memory require

Anyway, I need the best compromise memory allocated - search for
value - set a value

Any advices?

I know I could test each one, just hope someone have allready done it
:)



-
最诚挚的问候 - OHM

O_H_M {at } BTInternet {dot} com



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com



我认为它们是相同或非常相似的。我真的不确定如何确定单个对象在堆上占用多少内存,这就好了。
>
问候OHM

Crirus写道:
I would think they are the same or very similar. I''m not actually sure how
to find out how much memory an individual object takes up on the heap, thats
a good question.

Regards OHM
Crirus wrote:
BoolGrid(511,511)需要和
myBitArray.Length(511 * 511)?? br />
单手男[OHM#] < O_H_M {在} BTInternet {点} COM>在
消息新闻中写道:ux ************** @ tk2msftngp13.phx.gbl ...
BoolGrid(511,511) require the same memoy as
myBitArray.Length(511*511)??
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:ux**************@tk2msftngp13.phx.gbl...
为什么不
Dim BoolsGrid(511,511)As Boolean

''访问255,255
如果BoolGrid(255,255)那么

''我发现它是真的

结束如果

问候 - OHM

Crirus写道:
Why not

Dim BoolsGrid(511,511) As Boolean

''Access 255,255

If BoolGrid(255,255) Then

''I Found It to be True

End If
Regards - OHM

Crirus wrote:
你好
我有512x512网格booleans
在我的应用程序的特定点,我需要找出我的网格中的特定点是否真的是假的。

现在我需要一种方法来存储我的网格中每个坐标的布尔值。

我找到了一些方法:

1.我可以有一个512x512 BitArray类,类似于P(x, y)〜
myBitArray(y * 512 + x)= True
一个简单的检查会告诉我特定点的价值
缺点:内存占用无理由
值y * 512 + x告诉我在p(x,y)中我有
值真实缺点:搜索是否有像y * 512 + x这样的值在我的
数组中可以长,设置一个新值意味着Redim保留数组并且是时间消失了吧?

3.我可以使用ArrayList使用y * -512 + x值并添加,包含,
删除以添加,测试,设置值。
缺点:没有iddea如果比其他方式更快或如何
多内存要求

无论如何,我需要分配最好的妥协内存 - 搜索
值 - 设置一个值

任何建议?

我知道我可以测试每一个,只希望有人已经完成了它。)
Hello
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a
particular point in my grid have value true of false.

Now I need a way to store the boolean value for each coordinates in
my grid.

I found some methods:

1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason

2. Another way is to store only the true values in an array. Each
value y*512+x added to the array tells me that in p(x,y) I have
value True Drawback: Search if there is a value like y*512 +x
in my
array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?

3. I could use ArrayList with y*-512+x values and Add, Contains,
Remove for adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how
much memory require

Anyway, I need the best compromise memory allocated - search for
value - set a value

Any advices?

I know I could test each one, just hope someone have allready done
it :)



-
最诚挚的问候 - OHM
O_H_M {at} BTInternet {dot} com



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com




-

最诚挚的问候 - OHM


O_H_M {at} BTInternet {dot} com



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


这篇关于优化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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