PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB`#ifndef SQL_HSET_INCLUDED #define SQL_HSET_INCLUDED /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "my_global.h" #include "hash.h" /** A type-safe wrapper around mysys HASH. */ template class Hash_set { public: enum { START_SIZE= 8 }; /** Constructs an empty unique hash. */ Hash_set(PSI_memory_key psi_key, const uchar *(*K)(const void *, size_t *, my_bool), CHARSET_INFO *cs= &my_charset_bin) { my_hash_init(psi_key, &m_hash, cs, START_SIZE, 0, 0, K, 0, HASH_UNIQUE); } Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements, size_t key_offset, size_t key_length, my_hash_get_key get_key, void (*free_element)(void*), uint flags) { my_hash_init(psi_key, &m_hash, charset, default_array_elements, key_offset, key_length, get_key, free_element, flags); } /** Destroy the hash by freeing the buckets table. Does not call destructors for the elements. */ ~Hash_set() { my_hash_free(&m_hash); } /** Insert a single value into a hash. Does not tell whether the value was inserted -- if an identical value existed, it is not replaced. @retval TRUE Out of memory. @retval FALSE OK. The value either was inserted or existed in the hash. */ bool insert(T *value) { return my_hash_insert(&m_hash, reinterpret_cast(value)); } bool remove(T *value) { return my_hash_delete(&m_hash, reinterpret_cast(value)); } T *find(const void *key, size_t klen) const { return (T*)my_hash_search(&m_hash, reinterpret_cast(key), klen); } /** Is this hash set empty? */ bool is_empty() const { return m_hash.records == 0; } /** Returns the number of unique elements. */ size_t size() const { return static_cast(m_hash.records); } /** Erases all elements from the container */ void clear() { my_hash_reset(&m_hash); } const T* at(size_t i) const { return reinterpret_cast(my_hash_element(const_cast(&m_hash), i)); } /** An iterator over hash elements. Is not insert-stable. */ class Iterator { public: Iterator(Hash_set &hash_set) : m_hash(&hash_set.m_hash), m_idx(0) {} /** Return the current element and reposition the iterator to the next element. */ inline T *operator++(int) { if (m_idx < m_hash->records) return reinterpret_cast(my_hash_element(m_hash, m_idx++)); return NULL; } void rewind() { m_idx= 0; } private: HASH *m_hash; uint m_idx; }; private: HASH m_hash; }; #endif // SQL_HSET_INCLUDED