[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Order preserved?



Magnus Lie Hetland wrote:
> Is order preserved in a Group? I.e. if I make a group based on a
> sequence, and then iterate over the group, will I get the sprites in
> the same order? And are new sprites added to the end?

no, the ordering is undefined. although adding a "GroupOrdered" type of 
class could be a good idea. a couple 'sticky cases' come up, like if a 
sprite is added to a group it already exists in, does it move to the 
end? but for general use of it, ordering would be good.

the current Group class stores the sprites inside a dictionary. so the 
ordering is undefined. actually, it is stored in an ordered tree, which 
makes adding/removing/membership-testing very fast.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org