An open API service indexing awesome lists of open source software.

https://github.com/tyhil/general-tree

A general tree C++ library
https://github.com/tyhil/general-tree

cpp general-tree pointers tree

Last synced: 2 months ago
JSON representation

A general tree C++ library

Awesome Lists containing this project

README

          

# general-tree
[![Run on Repl.it](https://repl.it/badge/github/TyHil/general-tree)](https://repl.it/github/TyHil/general-tree)
## Description
A general tree C++ library
Using my [linked-list](https://github.com/TyHil/linked-list) library
## Documentation
### Clear
`template void generalTree::clear(linkedList> ** from)`
Clears and deletes all nodes and data inside the given list.
Paramaters: `linkedList> ** from`: pointer to a linked list pointer
### Add
`template void generalTree::add(int dir[], int depth, T * newData)`
Adds a new node with specified data to the end of the linked list found by the specified direction.
Parameters: `int dir[]`: list of locations in linked lists leading to the location, `int depth`: length of `dir`, `T * newData`: pointer to new data to be stored
### Get
`template treeNode * generalTree::get(int dir[], int depth)`
Returns a pointer to the node at the specified direction.
Parameters: `int dir[]`: list of locations in linked lists leading to the location, `int depth`: length of `dir`
Returns: `treeNode *`: a pointer to the tree node at the specified direction
### Set
`template void generalTree::set(int dir[], int depth, T * newData)`
Replaces the data of node at the specified direction with new data.
Parameters: `int dir[]`: list of locations in linked lists leading to the location, `int depth`: length of `dir`, `T * newData`: pointer to new data to be stored
### Insert
`template void generalTree::insert(int dir[], int depth, T * newData)`
Inserts a new node and new data in the linked list specified by the direction and before the last index.
Parameters: `int dir[]`: list of locations in linked lists leading to the location, `int depth`: length of `dir`, `T * newData`: pointer to new data to be stored
### Remove
`template void generalTree::remove(int dir[], int depth)`
Removes the node and data at the specified direction.
Parameters: `int dir[]`: list of locations in linked lists leading to the location, `int depth`: length of `dir`
### Is Empty
`template bool generalTree::isEmpty()`
Returns true if the tree has no elements in it.
Returns: `bool`: whether the tree is empty
### Swap
`template void generalTree::swap(int dir1[], int depth1, int dir2[], int depth2)`
Switches the data pointers of the nodes at the specified directions.
Parameters: `int dir1[]`: list of locations in linked lists leading to the first location, `int depth1`: length of `dir1`, `int dir2[]`: list of locations in linked lists leading to the second location, `int depth2`: length of `dir2`
## License
GPL-3.0 License