Library 3

Added template
This commit is contained in:
Alessandro Ferro
2021-04-24 16:58:05 +02:00
parent d080cf6fcc
commit 31bf18d985
46 changed files with 4175 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
// #include "..."
namespace lasd {
/* ************************************************************************** */
// ...
/* ************************************************************************** */
}

View File

@@ -0,0 +1,440 @@
#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

View File

@@ -0,0 +1,10 @@
namespace lasd {
/* ************************************************************************** */
// ...
/* ************************************************************************** */
}

View File

@@ -0,0 +1,101 @@
#ifndef BINARYTREELNK_HPP
#define BINARYTREELNK_HPP
/* ************************************************************************** */
#include "../binarytree.hpp"
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
class BinaryTreeLnk { // Must extend BinaryTree<Data>
private:
// ...
protected:
// using BinaryTree<Data>::???;
// ...
struct NodeLnk { // Must extend Node
private:
// ...
protected:
// ...
public:
// ...
};
public:
// Default constructor
// BinaryTreeLnk() specifiers;
/* ************************************************************************ */
// Specific constructors
// BinaryTreeLnk(argument) specifiers; // A binary tree obtained from a LinearContainer
/* ************************************************************************ */
// Copy constructor
// BinaryTreeLnk(argument) specifiers;
// Move constructor
// BinaryTreeLnk(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BinaryTreeLnk() 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 BinaryTree)
// type Root() specifiers; // Override BinaryTree member (throw std::length_error when empty)
/* ************************************************************************ */
// Specific member functions (inherited from Container)
// type Clear() specifiers; // Override Container member
};
/* ************************************************************************** */
}
#include "binarytreelnk.cpp"
#endif

View File

@@ -0,0 +1,10 @@
namespace lasd {
/* ************************************************************************** */
// ...
/* ************************************************************************** */
}

View File

@@ -0,0 +1,102 @@
#ifndef BINARYTREEVEC_HPP
#define BINARYTREEVEC_HPP
/* ************************************************************************** */
#include "../binarytree.hpp"
#include "../../vector/vector.hpp"
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
class BinaryTreeVec { // Must extend BinaryTree<Data>
private:
// ...
protected:
// using BinaryTree<Data>::???;
// ...
struct NodeVec { // Must extend Node
private:
// ...
protected:
// ...
public:
// ...
};
public:
// Default constructor
// BinaryTreeVec() specifiers;
/* ************************************************************************ */
// Specific constructors
// BinaryTreeVec(argument) specifiers; // A binary tree obtained from a LinearContainer
/* ************************************************************************ */
// Copy constructor
// BinaryTreeVec(argument) specifiers;
// Move constructor
// BinaryTreeVec(argument) specifiers;
/* ************************************************************************ */
// Destructor
// ~BinaryTreeVec() 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 BinaryTree)
// type Root() specifiers; // Override BinaryTree member (throw std::length_error when empty)
/* ************************************************************************ */
// Specific member functions (inherited from Container)
// type Clear() specifiers; // Override Container member
};
/* ************************************************************************** */
}
#include "binarytreevec.cpp"
#endif