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
- Host: GitHub
- URL: https://github.com/tyhil/general-tree
- Owner: TyHil
- License: gpl-3.0
- Created: 2021-05-20T03:49:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-24T00:15:47.000Z (over 4 years ago)
- Last Synced: 2025-02-16T18:40:06.851Z (10 months ago)
- Topics: cpp, general-tree, pointers, tree
- Language: C++
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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