Information générale
Catégorie:
Codage, syntaxe et commandes
>>>Hello James
>>>An alternate solution to implementing this as an array is to implement it as a linked list
>>>Your mediator (or raher your publisher) would hold 3 refrences
>>>the begining of the list, the end of the list and the for the current "node" and each object will have a propety holding reference to the next in line
>>>
>>>Adding a new object is o(1) (you can verify that an object is not already in the chain by checking its refrence property - or another)
>>>removing an object from the chain is o(n) to find it and o(1) to actually remove it
>>>and scanning through the whole chain is also o(n)
>
>>
>>The penalty of initializing a new object is huge compared to adding a new array element. If you just from the end of the array as though it is a stack, the task is fast and easy to manage.
>
>I am not talking about initializing objects for the linked list but rather using the objects you want to call to hold the references
>
>Arnon
Yes, that would be efficient. The Init and Destroy events can handle all of your insertion/deletion work. This is one of those instances where multiple inheritance would be nice.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement