473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Looking for tree-like structure

Hello there,

I am looking for the proper structure for the following problem. I
would like to read in memory a file that has the following structure:

k1, v1
k2, v2
k3, v3
k4 /
k1, v11
k3, v33
k5, v5
k1, v11
k8/
k1, v111
k2, v222
k7, v7

In the previous example k(i) is an uint32_t where k1 < k2 < ... < k7
< k8 and v(i) is just some data associated with the k(i). Note that
there is no data associated with k4 or k8 for instance (k4 and k8 are
special keys). There can be gap (k6 is missing), and the tree can be
any level deep.

I do not need any rebalancing operation, since the order of k(i) is
important. All I need is:
* Parsing (read and write the tree from/to disk)
* Insertion/Deletion of elements or sub-tree (e.g k4)
* Access (find a specific key k(i) a particular level)

Thanks for pointer to documentation and/or code,
Mathieu

May 18 '06 #1
2 1381
mathieu wrote:
Hello there,

I am looking for the proper structure for the following problem. I
would like to read in memory a file that has the following structure:

k1, v1
k2, v2
k3, v3
k4 /
k1, v11
k3, v33
k5, v5
k1, v11
k8/
k1, v111
k2, v222
k7, v7

In the previous example k(i) is an uint32_t where k1 < k2 < ... < k7
< k8 and v(i) is just some data associated with the k(i). Note that
there is no data associated with k4 or k8 for instance (k4 and k8 are
special keys). There can be gap (k6 is missing), and the tree can be
any level deep.

I do not need any rebalancing operation, since the order of k(i) is
important. All I need is:
* Parsing (read and write the tree from/to disk)
* Insertion/Deletion of elements or sub-tree (e.g k4)
* Access (find a specific key k(i) a particular level)

Thanks for pointer to documentation and/or code,
Mathieu


You could use a standard container (probably, std::set, std::map,
std::list, or std::vector) in conjunction with the Composite design
pattern, which calls for a class that represents both the primitive
(i.e., key and value) and their containers (e.g., your k4).

Cheers! --M

May 19 '06 #2
Thanks for your comment. But I am not convinced sorry :-P
I posted my question with lot more details to comp.programming

Thanks anyway !
-M

May 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Johnny Ooi | last post by:
I've written a template that does some work on a subtree, but I want to replace the subtree that I originally worked on. How would I do this? Confused, Okay, here's an example: <node> <node>...
38
by: Jukka K. Korpela | last post by:
As well all know, valid markup is important... but when trying to find a convincing modern argument in favor of this, I found pages like http://www.htmlhelp.com/tools/validator/reasons.html which...
0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
28
by: John McCabe | last post by:
Hi I'm looking for something equivalent to the Data Structures and Algorithms in Ada 95 books by Biedler and Feldman etc, but based towards efficient C++ implementations. Does anyone know of...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
2
by: New | last post by:
Why does this code insert a node into a binary search tree correctly? If I only inserting going by first digit it works properly but when I try inserting going by the whole ip and the port number...
1
by: Hai Nguyen | last post by:
Hi everyone, I'm looking for a component to help me to build navigation menu and tree view. I'm asking if I can find any good component going on the market to fix my need Thanks
19
by: phoenixathell | last post by:
Hi all, the PyHtmlGUI Project (http://www.sourceforge.net/projects/pyhtmlgui) is looking for developers that want to join. The aim of the project is to create a web application framework. The...
2
by: Sebastian Fey | last post by:
Hi, Im looking for a javascript treeview component. I want to display the state of differnt objects. (Lights, shutters, windows, ... in a house) The client polls the server for the current...
9
by: brad | last post by:
Just wondering if anyone has ever solved this efficiently... not looking for specific solutions tho... just ideas. I have one thousand words and one thousand files. I need to read the files to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.