Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Heterogeneous tree header only library

License

Notifications You must be signed in to change notification settings

AleksandrRybin/heterogeneous-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heterogeneous tree

Heterogeneous tree header only library. Such tree can store node with diffrent data types.

Build

Dependicies

  • CMake > 3.16
  • Boost > 1.65
  • C++17 compatible compiler

How to configure and build

  1. Clone repository

git clone <url>

  1. Enter project directory

cd heterogeneous-tree

  1. Run CMake

cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=RELEASE

  1. Build

cmake --build build

build folder now contains tree_demo executable - demo application for library

Run

Demo application

Demo application accepts path to file with serialized heterogeneous tree and path to output file, then reads tree from input, prints it to console and saves to output

Program options:

  • i,input - path to input file
  • o,output - path to output file

samples folder contains example files for demo application:

  • sample_input.txt - example of program input
  • sample_output.txt - example of program output

How to use library

  1. Define types that tree will store e.g. int, double and std::string
  2. Create tree
#include <string>
#include "tree_lib/tree.hpp"

using TreeType = tree_lib::Tree<int, double, std::string>;

TreeType tree;
  1. Create nodes and connect them
using TreeNodeType = TreeType::NodeType;

TreeNodeType root = 1;
TreeNodeType leftChild = 2.0;
TreeNodeType rightChild = "str";

root.AddChild(std::move(leftChild));
root.AddChild(std::move(rightChild));

tree.SetRoot(std::move(root));
  1. Print tree
#include <iostream>

tree.Print(std::cout);
  1. Save and load tree
#include <fstream>

std::ofstream out("..");
tree.Dump(out);

tree.Clear();
std::ifstream in("..");
tree.Load(in);

About

Heterogeneous tree header only library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published