On 8-Apr-07, at 2:36 PM, Theodore H. Smith wrote:

>>> My RingTree class (part of the ElfData plugin, only compiles to 4K)
>>> actually uses weak references, internally. Without all the RAM
>>> overhead normally associated with weak references.
>>>
>>> It just doesn't really advertise the fact that it uses weak
>>> references. All it advertises is that it makes a tree.
>>>
>>> AND it uses it for the most important purpose of weak references. To
>>> build trees that automatically dispose themselves! It's nice to be
>>> able to move up and down a tree, without it making cyclical refs.
>>
>> You can make a self-cleaning tree in RB code without weakrefs, though
>> you need to call the plugin API's Lock/Unlock functions - the
>> framework provides these if you know where to look ;) I use this
>> technique to travel a 3D scenegraph upwards from a leaf node and have
>> been very satisfied with the results.
>
> You could have just used my RingTree class ;)

If RB had multiple inheritance that might have been an option, but  
for various reasons my 3D nodes inherit from a base "transformable"  
class that can't be a node itself, for various other reasons!

> It would save you a lot of time in using a well made simple class
> that does it all for you.

My node class is dead simple (well, the parts that implement the tree  
anyway) and it took very little time to get going once the eureka  
moment hit. I like to think it's well made too, but don't hold me to  
that...

>> There are times weakrefs come in handy beyond tree structures
>> however. E.g. I'd refactor my file caching system to use weakrefs if
>> I had 2007r2, but I'm stuck with 2007r1 for the next few months at
>> least.
>
> I use double-linked lists for file caching. Then I moved it over to
> using my RingTree class. It's slightly wasteful here, because for
> each object, 8 bytes are wasted on unneeded parent and child
> properties. But it's OK really. 8 bytes per object isn't much when
> you have around 200 objects max.

I wouldn't worry much about 8 bytes, or speediness when dealing with  
a file cache. File size/parsing and disk access will far outweigh any  
small gains in the management code.

Frank.
<http://developer.chaoticbox.com/>
<http://macgameblog.com/>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to