Advertisement
Guest User

Untitled

a guest
May 28th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1.  
  2. #ifndef _BINARY_TREE_SORT_H_
  3.  
  4. #include "../BenchmarkFramework/Benchmarkable.h"
  5. #include "../Types.h"
  6.  
  7.  
  8.  
  9. namespace sort
  10. {
  11.  
  12.     template <typename T>
  13.     class Node
  14.     {
  15.     public:
  16.  
  17.         T Value;
  18.         Node * Left, * Right, * Parent;
  19.  
  20.         Node( );
  21.         ~Node( );
  22.     };
  23.  
  24.  
  25.  
  26.  
  27.  
  28.     template <typename T>
  29.     class BinaryTree : public bf::BenchmarkableSort <T>
  30.     {
  31.     public:
  32.         BinaryTree( );
  33.         virtual ~BinaryTree( );
  34.  
  35.         void Initialize( const std::vector<T> & data ) override;
  36.         void Run( const std::vector<T> & data ) override;
  37.         std::string Name( ) const override;
  38.    
  39.  
  40.     protected:
  41.         void FillSortedData( std::vector<T> & targetContainer ) const override;
  42.  
  43.  
  44.     private:
  45.         void AddNodeToReserve( Node<T> * node );
  46.         void AddValueToNodeSlot( Node<T> * parent, Node<T> ** slot, const T & value );
  47.  
  48.         void ProcessNodeToSortedData(
  49.             const Node<T> & targetNode,
  50.             std::vector<T> & targetContainer
  51.             ) const;
  52.  
  53.         Node<T> * GetNewNode( );
  54.         Node<T> * GetReservedNode( );
  55.  
  56.         void Clear( );
  57.  
  58.  
  59.  
  60.         std::vector<Node<T> *> m_NodeReserve;
  61.         int m_InitReserveSize; // Datastructure size reserved upon the call to Initialize()
  62.  
  63.         Node<T> * m_Root;
  64.     };
  65. }
  66.  
  67. #include "BinaryTreeSort.inl"
  68.  
  69. #endif // !_BINARY_TREE_SORT_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement