[DGD] Re: Clones and very large arrays
Par Winzell
zell at skotos.net
Tue Apr 6 17:09:35 CEST 2004
> Well like I said, I'm having difficulty making sense of it. The only
> loop in the entire code will break as soon as it finds the first object
> (the while() statement in forward()). And there isn't any recursion. So
> I'm not sure how it is returning the entire list of clones.
An iterator is used as this:
while (iterator->has_next()) {
log("The next object is: " + iterator->next()->query_name());
}
On each call to next(), the iterator should return the next object in
the enumeration. It doesn't return an array or anything like that. It's
an iterator the same way a for loop is an iterator -- it keeps an index
of some kind internally, so that the code that uses it doesn't have to
bother with such things.
>> Because it's inefficient to loop 250,000 times (or whatever OTABSZ is)
>> to enumerate three objects.
>
> That does seem inefficient, I'm wondering if it would be better to have
> it loop by however many clones a master object happens to have (by
> storing that information in an integer in the object daemon). But I'm
> not sure, the instance number of a clone might exceed the number of
> clones for that object, might it not?
Right -- in e.g. /base/obj/thing#283445, the number 283445 has nothing
to do with how many clones of /base/obj/thing there are in the game.
It's not "clone number 283445", it's "object number 283445, oh and it is
also a clone of /base/obj/thing".
If you wanted, you could keep a global "this is the highest clone number
we have seen yet" number, if you really wanted, or maybe one per
clonable. In practice it's not that big a deal I think.
Zell
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list