1 /* Copyright (c) 2014, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 24 #ifndef BOUNDED_HEAP_BOOST_INCLUDED 25 #define BOUNDED_HEAP_BOOST_INCLUDED 26 27 #include "my_global.h" 28 #include "my_base.h" 29 30 /** 31 @file 32 A test of how to implement Bounded_queue using boost heap. 33 We use the 'pimpl' idiom, to illustrate how to avoid dependencies from 34 our own header files to boost header files. 35 */ 36 37 template<typename Element_type, 38 typename Key_type, 39 typename Key_generator, 40 typename Key_compare 41 > 42 class Bounded_queue_impl; 43 44 template<typename Element_type, 45 typename Key_type, 46 typename Key_generator, 47 typename Key_compare = std::less<Key_type> 48 > 49 class Bounded_queue_boost 50 { 51 public: 52 explicit Bounded_queue_boost(); 53 54 ~Bounded_queue_boost(); 55 56 int init(ha_rows max_elements, 57 Key_generator *sort_param, 58 Key_type *sort_keys); 59 60 void push(Element_type element); 61 num_elements()62 size_t num_elements() const { return m_num_elements; } 63 64 private: 65 Key_compare m_cmp; 66 Key_type *m_sort_keys; 67 size_t m_compare_length; 68 Key_generator *m_sort_param; 69 size_t m_max_elements; 70 size_t m_num_elements; 71 Bounded_queue_impl<Element_type, Key_type, Key_generator, Key_compare> *pimpl; 72 }; 73 74 75 #endif // BOUNDED_HEAP_BOOST_INCLUDED 76