Re: "Russian doll" class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Larry Serflaten (serflaten_at_usinternet.com)
Date: 03/10/04


Date: Wed, 10 Mar 2004 00:22:12 -0600


"Nick Cranham" <TungCheeWah@Invalid.com> wrote
> Larry,
> Thanks for your reply. I thought circular references may prove a concern in
> this situation. Seem to have fixed that by adding a method to the class,
> allowing the Class_Terminate to function as expected:
>
> Public Sub DeleteReferences()

In .Net they have a routine to release references, you might want to borrow
that name (Dispose) just to get used to the nomenclature... ;-)

> Using strings would simplify matters so I'll look into your method below.
> from how I read it though, I would need to hardcode some kind of structure
> to the collections, otherwise I cannot tell that the "B" child items belong
> to the "Boxes" collection. As the aim was to provide for an arbitray
> structure, that was one reason to go the object route.

The boxes were the lowest items in the heirarchy, so they would always
be some object's child. The collections were to keep things separate.
All box items go in the Box collection, all container items into the
Container collection and so on. A box's parent could be a container
or a pallet (or whatever, the arbitrary aspect) which means a box might
have a parent key of C-### where there is a C-### in the Containers
collection or a box might have a pallet for a parent with a key of P-###.
Items that can have kids would need a collection of keys as one of their
properties.

So if a box (B_001) has a parent in the pallet collection (P-021) that
pallet item would have a collection of kids of which the box's key
was a member. The letter prefixes simply let you know which collection
the item resides in and the numbers would have to be unique (to that
group at least) or some other form of GUID.

But it is just as well you break the cross referencing and use the
object methods, because collections have performance issues when
the number of members get to be in the thousands. (I happened to
think of that later in the day. The number of box items in all the cartons,
on all the pallets, in all the containers might easily get to be quite large.)

Good luck!
LFS



Relevant Pages

  • Re: "Russian doll" class
    ... I thought circular references may prove a concern ... > Container collection and so on. ... > or a pallet which means a box might ... > was a member. ...
    (microsoft.public.vb.general.discussion)
  • Re: Inheritance, vectors and copy
    ... Not okay. ... that with references. ... You'd never even be able to get them into a container ... >object in the vector and store the reference to the copy in v3. ...
    (comp.lang.cpp)
  • Re: Finding the instance reference of an object
    ... calls another function that references the same container as a global, ... Of course every copy has a list of references to other copies and time ... if the attribute has a newer time stamp there, so the value has to be ... with call-by-sharing semantics you may end up with actually copying the ...
    (comp.lang.python)
  • Re: Best Ref-counting algorithms?
    ... and allocation of the container is required. ... links to other heap elements. ... IMO the only required overhead are layout descriptors for all data ... I see no need for counting references in such context. ...
    (comp.compilers)
  • Re: Deleting objects obtained from a STL library
    ... > Are the objects in the container the same objects as the ones that I used ... Are they references to those objects, ... That's up to you when you implement the copy constructor. ... Is there anything that is especially inelegant with pointers ...
    (comp.lang.cpp)