PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: BinaryHeapIterator.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_CONTAINER_BINARYHEAPITERATOR_H__ 00024 #define __PLCORE_CONTAINER_BINARYHEAPITERATOR_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/Container/IteratorImpl.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 template <class KeyType, class ValueType, class Comparer> class BinaryHeap; 00044 00045 00046 //[-------------------------------------------------------] 00047 //[ Classes ] 00048 //[-------------------------------------------------------] 00049 /** 00050 * @brief 00051 * Binary heap iterator class 00052 */ 00053 template <class KeyType, class ValueType, class Comparer> 00054 class BinaryHeapIterator : public IteratorImpl<ValueType> { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Friends ] 00059 //[-------------------------------------------------------] 00060 friend class BinaryHeap<KeyType, ValueType, Comparer>; 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Private functions ] 00065 //[-------------------------------------------------------] 00066 private: 00067 /** 00068 * @brief 00069 * Constructor 00070 * 00071 * @param[in] cHeapOwner 00072 * Binary heap to operate on 00073 * @param[in] nIndex 00074 * Start index, if >= GetNumOfElements() the index is set to the last valid index 00075 */ 00076 BinaryHeapIterator(const BinaryHeap<KeyType, ValueType, Comparer> &cHeapOwner, uint32 nIndex); 00077 00078 /** 00079 * @brief 00080 * Constructor 00081 * 00082 * @param[in] cHeapOwner 00083 * Binary heap to operate on 00084 * 00085 * @note 00086 * - The iterator will start at the last element 00087 */ 00088 BinaryHeapIterator(const BinaryHeap<KeyType, ValueType, Comparer> &cHeapOwner); 00089 00090 /** 00091 * @brief 00092 * Copy constructor 00093 * 00094 * @param[in] cSource 00095 * Source to copy from 00096 */ 00097 BinaryHeapIterator(const BinaryHeapIterator<KeyType, ValueType, Comparer> &cSource); 00098 00099 /** 00100 * @brief 00101 * Destructor 00102 */ 00103 virtual ~BinaryHeapIterator(); 00104 00105 00106 //[-------------------------------------------------------] 00107 //[ Private data ] 00108 //[-------------------------------------------------------] 00109 private: 00110 const BinaryHeap<KeyType, ValueType, Comparer> *m_pHeapOwner; /**< Binary heap to operate on (always valid!) */ 00111 uint32 m_nNextID; /**< ID of the next element */ 00112 00113 00114 //[-------------------------------------------------------] 00115 //[ Private virtual IteratorImpl functions ] 00116 //[-------------------------------------------------------] 00117 private: 00118 virtual IteratorImpl<ValueType> *Clone() const override; 00119 virtual bool HasNext() const override; 00120 virtual ValueType &Next() override; 00121 virtual bool HasPrevious() const override; 00122 virtual ValueType &Previous() override; 00123 00124 00125 }; 00126 00127 00128 //[-------------------------------------------------------] 00129 //[ Namespace ] 00130 //[-------------------------------------------------------] 00131 } // PLCore 00132 00133 00134 //[-------------------------------------------------------] 00135 //[ Implementation ] 00136 //[-------------------------------------------------------] 00137 #include "PLCore/Container/BinaryHeapIterator.inl" 00138 00139 00140 #endif // __PLCORE_CONTAINER_BINARYHEAPITERATOR_H__
|