Jump to content
  • Advertisement
Sign in to follow this  
iaretony

What do you think?

This topic is 5044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One component of my general purpose game programming foundation classes is a resource bundling / loading class... Essentially, my idea involved building some code that could recursively scan a directory heirarchy, creating a tree in memory, each node in the tree representing either a data file (like a .WAV, or .JPG) or a directory. Directorys of course have children that are either regular files, or other directorys. I have all of this working. My question now is: Is their any standard way to serialize a tree to disk? Some format that will make it easy to recover it's structure? Im hoping theirs an easy, cool way to do this? :) Another option, of course, is to just throw out the tree nature of the structure, and perhaps simply have a data file with an index preceding it... Tony

Share this post


Link to post
Share on other sites
Advertisement
I would just print out the first node and the number of children it has, then each child and the number of children the have, etc..

So:


function traverse(node)
{
print node, print # of children (0 if a leaf node)
foreach(child) traverse(child)
}

then simply traverse(rootnode)


I'm not sure of any standard way to serialize n-ary trees though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!