473,657 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1392
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.programmin g

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
1576
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> <node> </node> <node>
38
3601
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 was very nice when Netscape ruled the World Wide Web, and http://valet.htmlhelp.com/page/why.html which is very suggestive but does not really give any factual example. Is there something to be _shown_ to people who ask "why validate?"? A page...
0
2175
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 am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not display the MenuItem Node at all Note: My tree Menu will start from MenuItem node and it will...
28
2726
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 such a thing and could recommend one? I'm particularly interested in coverage of binary search trees, especially Red-Black, Splay and AVL, as well as hashing tables and
4
9013
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, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if I had C / \ B D
2
1631
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 the inserts are totally out of order. where IPAddress is four ints Node is an IPAddress, portNumber, left pointer and right pointer Nodeptr is a pointer to a Node
1
1041
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
1947
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 API of PyHtmlGUI wants to be close to Trolltechs famous Qt API but incooperates the idea of a text based renderengine instead of the pixel based one. The obviouse target is html/css but through xml rendering process nearly every textual output...
2
1164
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 state of the objects and updates the tree. so the component should allow to change the nodes dynamically and easily. Also it should be easy to determine which node is selected at a time and
9
1208
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 see if some of the words are in the files. I can stop reading a file once I find 10 of the words in it. It's easy for me to do this with a few dozen words, but a thousand words is too large for an RE and too inefficient to loop, etc. Any...
0
8399
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.