Re: Listing objects
- From: Peter Fox <peterfox@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 10:19:00 +0000
Following on from Lüpher Cypher's message. . .
Hi,
Suppose we have a hierarchical class structure that looks something like this:
Sorry, I lost the plot half way through.
Your objects can be
1 - nesting : object has a 'what are my children' and 'who is my parent' functionality.
2 - pointing : eg object has a 'these are my siblings' or 'previous/next' functionality
3 - dictionary entries : object in some container is discoverable by name
Variations and combinations of course apply. BUT every object exists in some context. I /think/ you might be trying to get A's to point-to/own B's where more than one A could be the parent of a B. Eg
"Sally is daughter of Jean"
"Geoffrey is son of Teddy"
"Sally is daughter of Teddy" // Only one Sally! J+T are married.
In this case[1] create an array of children and point to elements in that array from your parent objects.
eg $child['Sally'] = new ChildObj(.....);
then $Jean->AddChild('Sally') // just a key name or index
or $Jean->AddChild($child['Sally']) // inside the routine do $myKids[] = & $NewChild
where $NewChild is the function argument.
[1] If in this example children can be parents then you should be looking at a single universal 'person' class with the necessary links.
-- PETER FOX Not the same since the adhesive company came unstuck peterfox@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 Tees Close, Witham, Essex. Gravity beer in Essex <http://www.eminent.demon.co.uk> .
- Follow-Ups:
- Re: Listing objects
- From: Lüpher Cypher
- Re: Listing objects
- References:
- Listing objects
- From: Lüpher Cypher
- Listing objects
- Prev by Date: Re: How to tell if Mime type matches contents
- Next by Date: Re: Cannot get this one correct and working, though simple!
- Previous by thread: Listing objects
- Next by thread: Re: Listing objects
- Index(es):
Relevant Pages
|