PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: HashMapKeyIterator.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_HASHMAPKEYITERATOR_H__ 00024 #define __PLCORE_CONTAINER_HASHMAPKEYITERATOR_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 Hasher, class Comparer, class Grower> class HashMap; 00044 00045 00046 //[-------------------------------------------------------] 00047 //[ Classes ] 00048 //[-------------------------------------------------------] 00049 /** 00050 * @brief 00051 * Hash map key iterator class 00052 */ 00053 template <class KeyType, class ValueType, class Hasher, class Comparer, class Grower> 00054 class HashMapKeyIterator : public IteratorImpl<KeyType> { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Friends ] 00059 //[-------------------------------------------------------] 00060 friend class HashMap<KeyType, ValueType, Hasher, Comparer, Grower>; 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Private functions ] 00065 //[-------------------------------------------------------] 00066 private: 00067 /** 00068 * @brief 00069 * Constructor 00070 * 00071 * @param[in] mapOwner 00072 * Hash map to operate on 00073 * @param[in] nIndex 00074 * Start index, if >= GetNumOfElements() the index is set to the last valid index 00075 */ 00076 HashMapKeyIterator(const HashMap<KeyType, ValueType, Hasher, Comparer, Grower> &mapOwner, uint32 nIndex); 00077 00078 /** 00079 * @brief 00080 * Constructor 00081 * 00082 * @param[in] mapOwner 00083 * Hash map to operate on 00084 * 00085 * @note 00086 * - The iterator will start at the last element 00087 */ 00088 HashMapKeyIterator(const HashMap<KeyType, ValueType, Hasher, Comparer, Grower> &mapOwner); 00089 00090 /** 00091 * @brief 00092 * Copy constructor 00093 * 00094 * @param[in] cSource 00095 * Source to copy from 00096 */ 00097 HashMapKeyIterator(const HashMapKeyIterator<KeyType, ValueType, Hasher, Comparer, Grower> &cSource); 00098 00099 /** 00100 * @brief 00101 * Destructor 00102 */ 00103 virtual ~HashMapKeyIterator(); 00104 00105 00106 //[-------------------------------------------------------] 00107 //[ Private data ] 00108 //[-------------------------------------------------------] 00109 private: 00110 const HashMap<KeyType, ValueType, Hasher, Comparer, Grower> *m_pmapOwner; /**< Hash map to operate on (always valid!) */ 00111 uint32 m_nNextSlots; /**< Next slots list */ 00112 typename HashMap<KeyType, ValueType, Hasher, Comparer, Grower>::Slot *m_pNextSlot; /**< Next slot, can be a null pointer */ 00113 uint32 m_nPreviousSlots; /**< Next slots list */ 00114 typename HashMap<KeyType, ValueType, Hasher, Comparer, Grower>::Slot *m_pPreviousSlot; /**< Previous slot, can be a null pointer */ 00115 00116 00117 //[-------------------------------------------------------] 00118 //[ Private virtual IteratorImpl functions ] 00119 //[-------------------------------------------------------] 00120 private: 00121 virtual IteratorImpl<KeyType> *Clone() const override; 00122 virtual bool HasNext() const override; 00123 virtual KeyType &Next() override; 00124 virtual bool HasPrevious() const override; 00125 virtual KeyType &Previous() override; 00126 00127 00128 }; 00129 00130 00131 //[-------------------------------------------------------] 00132 //[ Namespace ] 00133 //[-------------------------------------------------------] 00134 } // PLCore 00135 00136 00137 //[-------------------------------------------------------] 00138 //[ Implementation ] 00139 //[-------------------------------------------------------] 00140 #include "PLCore/Container/HashMapKeyIterator.inl" 00141 00142 00143 #endif // __PLCORE_CONTAINER_HASHMAPKEYITERATOR_H__
|