CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Posts
    218

    Tree data structure

    Hi,

    I want to have something like a tree datastructure. I want to represent a tree containing integers.

    I want it to be able to easily add nodes and to easily geth the path from a leaf to the base node.
    e.g.
    Code:
               0
    1      8      6      3
          7 9      4
         2
         5
    //so it must be easy to append an new integer node on any leaf. e.g. append 10 on 5.
    //and it must be easy to give the path for a given node. e.g. for 5: 5-2-7-8-0; e.g. for 9: 9-8-0
    I can't seem to find anything on msdn. Doesn't this exist? If so, where must I look. If not, how do I start on this?

    You may also point me to sample implementations of this..

    greets
    Last edited by timv; September 14th, 2005 at 05:23 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Tree data structure

    Call in the loop CTreeCtrl::GetParentItem followed by CTreeCtrl::GetItemText and build "the full path".
    Yoou migjt also want to use ItemData rather than Item Text (don't forget to set the Item Data in this case and use CTreeCtrl::GetItemData instead of CTreeCtrl::GetItemText)

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Tree data structure

    Quote Originally Posted by VictorN
    Call in the loop CTreeCtrl::GetParentItem followed by CTreeCtrl::GetItemText and build "the full path".
    Yoou migjt also want to use ItemData rather than Item Text (don't forget to set the Item Data in this case and use CTreeCtrl::GetItemData instead of CTreeCtrl::GetItemText)
    I think the question was not about CTreeCtrl, but about a generic tree data structure. Perhaps the thread should be moved to the "Non-Visual C++" forum.

  4. #4
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Tree data structure

    What you mean by "tree data structure"? You don't seem like talking about MFC Tree Control or are you?

  5. #5
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Tree data structure

    [ Moved Thread ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured