Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: list cleaning
Home

[Freeciv-Dev] Re: list cleaning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: list cleaning
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 27 Jan 2004 20:40:38 +0000 (GMT)

On Tue, 27 Jan 2004, Jason Short wrote:
> However I also don't like delaying the deletion to far. Doing it in an
> end-of-turn loop is ugly, since this removes the clean interface and
> forces the calling code to know about the delayed-deletion mechanism.

The interface is cleaner with *_free(), IMHO, and the calling code does
not have to know anything about the mechanism beneath.

>My
> preference would be for:
>
> - At the end of the loop, if any nodes were deleted iterate through and
> find+remove them.
>
> - As you're iterating through the loop, when you pass a node that's
> deleted remove it.The current problem, IIRC, is with deleting the
> current node since you still need the pointer it provides to get to the
> next node.But at the end of the block when you move on to the next node
> you shouldn't need the current node anymore.
>
> Both of these require a very small ammortized overhead - no more than one
> extra boolean check per loop iteration.So efficiency shouldn't be a
> concern when compared to the delete-at-end-of-turn mechanism.

You forgot: Both require accounting to avoid doing deletions while inside
a nested iterator, and makes necessary a ban on the use of goto and return
from inside an iterator.

  - Per



[Prev in Thread] Current Thread [Next in Thread]