Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Inline::C hash access

by betterworld (Curate)
on Sep 04, 2008 at 12:03 UTC ( #708997=note: print w/replies, xml ) Need Help??


in reply to Inline::C hash access

Have you considered storing the root directly, i.e. as $self->{root}?

Of course, this will only work if the parents don't change over time.

Replies are listed 'Best First'.
Re^2: Inline::C hash access
by puudeli (Pilgrim) on Sep 04, 2008 at 12:08 UTC
    Actually storing the $root info into an item is a good idea, you just have to make sure that when the linked list (or whatever the structure is) is changed (eg. add/delete from the middle) the $root information is also updated.
    --
    seek $her, $from, $everywhere if exists $true{love};
Re^3: Inline::C hash access
by fireartist (Chaplain) on Sep 04, 2008 at 12:14 UTC

    I've looked into this, but unfortunately the parent can change - and this involves a tree of lots of different types of objects - so keeping track of what type of children need updated sounds like a bug waiting to happen ;)

      This sounds like a place where a doubly-linked list could do the job. Each node knows the previous and the next node, thus you can easily descend/ascend the list whenever you need.
      --
      seek $her, $from, $everywhere if exists $true{love};
        If you have several branches and many $roots in the tree then of course the $root needs to know that it is the $root. A simple flag would tell the search to stop and return the $root for a particular $node.
        --
        seek $her, $from, $everywhere if exists $true{love};

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://708997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2021-02-27 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?