Re: [Vala] foreach performance
- From: "Phil Housley" <undeconstructed gmail com>
- To: "Кутейников Дмитрий" <kuteynikov gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] foreach performance
- Date: Wed, 17 Dec 2008 12:53:46 +0000
2008/12/16 Кутейников Дмитрий <kuteynikov gmail com>:
Hello!
Why there are no operator to remove current object in foreach block?
I have to write
foreach(Components.Obj obj in m_objects)
{
if(obj.item.x == x && obj.item.y == y)
{
Events.disappear(obj);
m_objects.remove(obj); // :(
return obj;
}
An object can be iterable with a foreach block with having method for
removing items, so this can't be automatic. Also, many potentially
iterable objects have no concept of removing items anyway.
Whether there will be a performance issue depends on the type of
collection. Something array backed won't cost anything extra,
something linked list backed will.
--
Phil Housley
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]