lasd/librerie/exercise3/binarytree/binarytree.hpp

441 lines
13 KiB
C++

#ifndef BINARYTREE_HPP
#define BINARYTREE_HPP
/* ************************************************************************** */
#include "../container/container.hpp"
#include "../iterator/iterator.hpp"
// #include "..."
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
class BinaryTree { // Must extend InOrder/BreadthMappableContainer<Data> and InOrder/BreadthFoldableContainer<Data>
private:
// ...
protected:
// using InOrder/BreadthMappableContainer<Data>::???;
// ...
public:
struct Node {
private:
// ...
protected:
// ...
public:
// friend class BinaryTree<Data>;
/* ********************************************************************** */
// Destructor
// ~Node() specifiers
/* ********************************************************************** */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ********************************************************************** */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types is possible, but should not be visible.
// type operator!=(argument) specifiers; // Comparison of abstract types is possible, but should not be visible.
/* ********************************************************************** */
// Specific member functions
// type Element() specifiers; // Mutable access to the element (concrete function should not throw exceptions)
// type Element() specifiers; // Immutable access to the element (concrete function should not throw exceptions)
// type IsLeaf() specifiers; // (concrete function should not throw exceptions)
// type HasLeftChild() specifiers; // (concrete function should not throw exceptions)
// type HasRightChild() specifiers; // (concrete function should not throw exceptions)
// type LeftChild() specifiers; // (concrete function must throw std::out_of_range when not existent)
// type RightChild() specifiers; // (concrete function must throw std::out_of_range when not existent)
};
/* ************************************************************************ */
// Destructor
// ~BinaryTree() specifiers
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract binary tree is possible.
// type operator!=(argument) specifiers; // Comparison of abstract binary tree is possible.
/* ************************************************************************ */
// Specific member functions
// type Root() specifiers; // (concrete function must throw std::length_error when empty)
/* ************************************************************************ */
// Specific member functions (inherited from MappableContainer)
// using typename MappableContainer<Data>::MapFunctor;
// type MapPreOrder(arguments) specifiers; // Override MappableContainer member
// type MapPostOrder(arguments) specifiers; // Override MappableContainer member
/* ************************************************************************ */
// Specific member functions (inherited from FoldableContainer)
// using typename FoldableContainer<Data>::FoldFunctor;
// type FoldPreOrder(arguments) specifiers; // Override FoldableContainer member
// type FoldPostOrder(arguments) specifiers; // Override FoldableContainer member
/* ************************************************************************ */
// Specific member functions (inherited from InOrderMappableContainer)
// type MapInOrder(arguments) specifiers; // Override InOrderMappableContainer member
/* ************************************************************************ */
// Specific member functions (inherited from InOrderFoldableContainer)
// type FoldInOrder(arguments) specifiers; // Override InOrderFoldableContainer member
/* ************************************************************************ */
// Specific member functions (inherited from BreadthMappableContainer)
// type MapBreadth(arguments) specifiers; // Override BreadthMappableContainer member
/* ************************************************************************ */
// Specific member functions (inherited from BreadthFoldableContainer)
// type FoldBreadth(arguments) specifiers; // Override BreadthFoldableContainer member
protected:
// Auxiliary member functions (for MappableContainer)
// type MapPreOrder(arguments) specifiers; // Accessory function executing from one node of the tree
// type MapPostOrder(arguments) specifiers; // Accessory function executing from one node of the tree
/* ************************************************************************ */
// Auxiliary member functions (for FoldableContainer)
// type FoldPreOrder(arguments) specifiers; // Accessory function executing from one node of the tree
// type FoldPostOrder(arguments) specifiers; // Accessory function executing from one node of the tree
/* ************************************************************************ */
// Auxiliary member functions (for InOrderMappableContainer)
// type MapInOrder(arguments) specifiers; // Accessory function executing from one node of the tree
/* ************************************************************************ */
// Auxiliary member functions (for InOrderFoldableContainer)
// type FoldInOrder(arguments) specifiers; // Accessory function executing from one node of the tree
/* ************************************************************************ */
// Auxiliary member functions (for BreadthMappableContainer)
// type MapBreadth(arguments) specifiers; // Accessory function executing from one node of the tree
/* ************************************************************************ */
// Auxiliary member functions (for BreadthFoldableContainer)
// type FoldBreadth(arguments) specifiers; // Accessory function executing from one node of the tree
};
/* ************************************************************************** */
template <typename Data>
class BTPreOrderIterator { // Must extend ForwardIterator<Data>
private:
// ...
protected:
// ...
public:
// Specific constructors
// BTPreOrderIterator(argument) specifiers; // An iterator over a given binary tree
/* ************************************************************************ */
// Copy constructor
// BTPreOrderIterator(argument) specifiers;
// Move constructor
// BTPreOrderIterator(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BTPreOrderIterator() specifiers;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument) specifiers;
// Move assignment
// type operator=(argument) specifiers;
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers;
// type operator!=(argument) specifiers;
/* ************************************************************************ */
// Specific member functions (inherited from Iterator)
// type operator*() specifiers; // (throw std::out_of_range when terminated)
// type Terminated() specifiers; // (should not throw exceptions)
/* ************************************************************************ */
// Specific member functions (inherited from ForwardIterator)
// type operator++() specifiers; // (throw std::out_of_range when terminated)
};
/* ************************************************************************** */
template <typename Data>
class BTPostOrderIterator { // Must extend ForwardIterator<Data>
private:
// ...
protected:
// ...
public:
// Specific constructors
// BTPostOrderIterator(argument) specifiers; // An iterator over a given binary tree
/* ************************************************************************ */
// Copy constructor
// BTPostOrderIterator(argument) specifiers;
// Move constructor
// BTPostOrderIterator(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BTPostOrderIterator() specifiers;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument) specifiers;
// Move assignment
// type operator=(argument) specifiers;
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers;
// type operator!=(argument) specifiers;
/* ************************************************************************ */
// Specific member functions (inherited from Iterator)
// type operator*() specifiers; // (throw std::out_of_range when terminated)
// type Terminated() specifiers; // (should not throw exceptions)
/* ************************************************************************ */
// Specific member functions (inherited from ForwardIterator)
// type operator++() specifiers; // (throw std::out_of_range when terminated)
};
/* ************************************************************************** */
template <typename Data>
class BTInOrderIterator { // Must extend ForwardIterator<Data>
private:
// ...
protected:
// ...
public:
// Specific constructors
// BTInOrderIterator(argument) specifiers; // An iterator over a given binary tree
/* ************************************************************************ */
// Copy constructor
// BTInOrderIterator(argument) specifiers;
// Move constructor
// BTInOrderIterator(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BTInOrderIterator() specifiers;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument) specifiers;
// Move assignment
// type operator=(argument) specifiers;
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers;
// type operator!=(argument) specifiers;
/* ************************************************************************ */
// Specific member functions (inherited from Iterator)
// type operator*() specifiers; // (throw std::out_of_range when terminated)
// type Terminated() specifiers; // (should not throw exceptions)
/* ************************************************************************ */
// Specific member functions (inherited from ForwardIterator)
// type operator++() specifiers; // (throw std::out_of_range when terminated)
};
/* ************************************************************************** */
template <typename Data>
class BTBreadthIterator { // Must extend ForwardIterator<Data>
private:
// ...
protected:
// ...
public:
// Specific constructors
// BTBreadthIterator(argument) specifiers; // An iterator over a given binary tree
/* ************************************************************************ */
// Copy constructor
// BTBreadthIterator(argument) specifiers;
// Move constructor
// BTBreadthIterator(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BTBreadthIterator() specifiers;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument) specifiers;
// Move assignment
// type operator=(argument) specifiers;
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers;
// type operator!=(argument) specifiers;
/* ************************************************************************ */
// Specific member functions (inherited from Iterator)
// type operator*() specifiers; // (throw std::out_of_range when terminated)
// type Terminated() specifiers; // (should not throw exceptions)
/* ************************************************************************ */
// Specific member functions (inherited from ForwardIterator)
// type operator++() specifiers; // (throw std::out_of_range when terminated)
};
/* ************************************************************************** */
}
#include "binarytree.cpp"
#endif