mirror of
https://github.com/xfarrow/lasd.git
synced 2025-06-05 21:49:14 +02:00
Library 3
cleaner code
This commit is contained in:
@ -1,30 +1,17 @@
|
||||
|
||||
#ifndef BINARYTREELNK_HPP
|
||||
#define BINARYTREELNK_HPP
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../binarytree.hpp"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
namespace lasd {
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
template <typename Data>
|
||||
class BinaryTreeLnk : virtual public BinaryTree<Data>{ // Must extend BinaryTree<Data>
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
using BinaryTree<Data>::size;
|
||||
|
||||
struct NodeLnk : virtual protected BinaryTree<Data>::Node { // Must extend Node
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
using BinaryTree<Data>::Node::data;
|
||||
@ -46,64 +33,42 @@ protected:
|
||||
};
|
||||
|
||||
protected:
|
||||
using BinaryTree<Data>::size;
|
||||
|
||||
struct BinaryTreeLnk<Data>::NodeLnk* root = nullptr;
|
||||
struct BinaryTreeLnk<Data>::NodeLnk* CreateNode(const Data& data);
|
||||
|
||||
public:
|
||||
|
||||
// Default constructor
|
||||
BinaryTreeLnk() = default;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific constructors
|
||||
BinaryTreeLnk(const LinearContainer<Data>&); // A binary tree obtained from a LinearContainer
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Copy constructor
|
||||
BinaryTreeLnk(const BinaryTreeLnk<Data>&);
|
||||
|
||||
// Move constructor
|
||||
BinaryTreeLnk(BinaryTreeLnk<Data>&&) noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Destructor
|
||||
virtual ~BinaryTreeLnk();
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Copy assignment
|
||||
BinaryTreeLnk& operator=(const BinaryTreeLnk<Data>&);
|
||||
|
||||
// Move assignment
|
||||
BinaryTreeLnk& operator=(BinaryTreeLnk<Data>&&) noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Comparison operators
|
||||
bool operator==(const BinaryTreeLnk<Data>&) const noexcept;
|
||||
bool operator!=(const BinaryTreeLnk<Data>&) const noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific member functions (inherited from BinaryTree)
|
||||
|
||||
struct BinaryTree<Data>::Node& Root() const override; // Override BinaryTree member (throw std::length_error when empty)
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific member functions (inherited from Container)
|
||||
|
||||
void Clear() override; // Override Container member
|
||||
|
||||
// Specific functions
|
||||
|
||||
struct BinaryTreeLnk<Data>::NodeLnk* CreateTreeFromLinearContainerInBreadth(const LinearContainer<Data>&,ulong);
|
||||
struct BinaryTreeLnk<Data>::NodeLnk* CopyTree(struct BinaryTreeLnk<Data>::Node*);
|
||||
void DeleteTree(BinaryTreeLnk<Data>::NodeLnk* node);
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
}
|
||||
|
||||
#include "binarytreelnk.cpp"
|
||||
|
Reference in New Issue
Block a user