F4
Implementation of the F4 algorithm.
 All Classes Namespaces Files Functions Variables Friends
avl-pointer-critical-pair.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Antoine Joux and Vanessa Vitse
3 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 #ifndef F4_AVL_POINTER_CRITICAL_PAIR_H
25 #define F4_AVL_POINTER_CRITICAL_PAIR_H
26 
28 #include <iostream>
29 #include <cassert>
30 #include <iomanip>
32 #include "critical-pair.h"
33 #include "dynamic-array.h"
34 
38 namespace F4
39 {
44  template<typename Element>
46  {
47  public:
48 
49  /* Constructor */
50 
55 
56  /* Attributes */
57 
59  signed char _bf;
63  };
64 
69  template<typename Element>
70  void printNode(NodeAvlPointerCriticalPair<Element> * p, int indent=0);
71 
72 
77  template<typename Element>
79  {
80  public:
81 
82  /* Constructor */
83 
88 
89 
90  /* Miscellaneous */
91 
96  void printAvlCriticalPair(std::ostream & stream) const;
97 
101  void reset();
102 
107  size_t size() const;
108 
114  bool isEmpty() const;
115 
119  void testAVL();
120 
121  /* Insertion */
122 
129  int insert(CriticalPair<Element> * cp);
130 
131 
132  /* Search */
133 
139 
145 
152 
159 
165 
171 
178 
185 
186  private:
190  size_t _size;
193  };
194 
199  template <typename Element>
200  std::ostream & operator<<(std::ostream & stream, AvlPointerCriticalPair<Element> const & avlCriticalPair);
201 }
202 
203 #include "../src/avl-pointer-critical-pair.inl"
204 
205 #endif // F4_AVL_POINTER_CRITICAL_PAIR_H
NodeAvlPointerCriticalPair< Element > * findNextBiggest(NodeAvlPointerCriticalPair< Element > *node)
Find the next biggest NodeAvlPointerCriticalPair after node.
bool isEmpty() const
Test if the AVL is empty.
NodeAvlPointerCriticalPair< Element > * findBiggest()
Find the biggest NodeAvlPointerCriticalPair of the AVL.
void reset()
Reset the AVL for a new usage, memory is not clear.
Declaration of class DynamicArray.
AvlPointerCriticalPair()
Constructor.
Definition: critical-pair.h:39
NodeAvlPointerCriticalPair< Element > * findNextSmallest(NodeAvlPointerCriticalPair< Element > *node)
Find the next smallest NodeAvlPointerCriticalPair after node.
NodeAvlPointerCriticalPair< Element > * _root
Definition: avl-pointer-critical-pair.h:189
size_t size() const
Get the number of element in the AVL.
Definition: dynamic-array.h:42
size_t _size
Definition: avl-pointer-critical-pair.h:190
Definition: avl-pointer-critical-pair.h:45
NodeAvlPointerCriticalPair< Element > * findSmallest()
Find the smallest NodeAvlPointerCriticalPair of the AVL.
Definition: avl-pointer-critical-pair.h:78
void printAvlCriticalPair(std::ostream &stream) const
Print the AVL.
void testAVL()
Test the consistency of the AVL.
Declaration of class CriticalPair.
NodeAvlPointerCriticalPair< Element > * _it
Definition: avl-pointer-critical-pair.h:188
void printNode(NodeAvlCriticalPair< Element > *p, int indent=0)
Print the AVL of root p.
DynamicArray< NodeAvlPointerCriticalPair< Element > > _array
Definition: avl-pointer-critical-pair.h:187
NodeAvlPointerCriticalPair()
Constructor.
int insert(CriticalPair< Element > *cp)
Insert the critical pair pointer cp in the AVL.