OpenNI 1.5.4
XnHash.h
Go to the documentation of this file.
1/****************************************************************************
2* *
3* OpenNI 1.x Alpha *
4* Copyright (C) 2011 PrimeSense Ltd. *
5* *
6* This file is part of OpenNI. *
7* *
8* OpenNI is free software: you can redistribute it and/or modify *
9* it under the terms of the GNU Lesser General Public License as published *
10* by the Free Software Foundation, either version 3 of the License, or *
11* (at your option) any later version. *
12* *
13* OpenNI is distributed in the hope that it will be useful, *
14* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16* GNU Lesser General Public License for more details. *
17* *
18* You should have received a copy of the GNU Lesser General Public License *
19* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
20* *
21****************************************************************************/
22#ifndef _XN_HASH_H
23#define _XN_HASH_H
24
25//---------------------------------------------------------------------------
26// Includes
27//---------------------------------------------------------------------------
28#include "XnList.h"
29
30//---------------------------------------------------------------------------
31// Defines
32//---------------------------------------------------------------------------
33#define XN_HASH_LAST_BIN 256
34#define XN_HASH_NUM_BINS (XN_HASH_LAST_BIN + 1)
35//---------------------------------------------------------------------------
36// Types
37//---------------------------------------------------------------------------
41typedef XnValue XnKey;
42
46typedef XnUInt8 XnHashValue;
47
51static XnHashValue XnDefaultHashFunction(const XnKey& key)
52{
53 return (XnSizeT(key) & 0xff);
54}
55
59static XnInt32 XnDefaultCompareFunction(const XnKey& key1, const XnKey& key2)
60{
61 return XnInt32(XnSizeT(key1)-XnSizeT(key2));
62}
63
67class XnHash
68{
69public:
74 {
75 public:
76 friend class XnHash;
77
85
90 {
91 ++m_Iterator;
92
93 while (m_Iterator == m_pHash->m_Bins[m_nCurrentBin]->end() &&
95 {
96 do
97 {
99 } while (m_pHash->m_Bins[m_nCurrentBin] == NULL);
101 }
102 return *this;
103 }
104
109 {
110 XnHash::ConstIterator other(*this);
111 ++*this;
112 return other;
113 }
114
119 {
120 --m_Iterator;
121
122 while (m_Iterator == m_pHash->m_Bins[m_nCurrentBin]->end() &&
124 {
125 do
126 {
127 if (m_nCurrentBin == 0)
128 {
131 return *this;
132 }
134 } while (m_pHash->m_Bins[m_nCurrentBin] == NULL);
136 }
137 return *this;
138 }
139
144 {
145 ConstIterator other(*this);
146 --*this;
147 return other;
148 }
149
155 XnBool operator==(const ConstIterator& other) const
156 {
157 return m_Iterator == other.m_Iterator;
158 }
159
165 XnBool operator!=(const ConstIterator& other) const
166 {
167 return m_Iterator != other.m_Iterator;
168 }
169
173 const XnKey& Key() const
174 {
175 return ((XnNode*)(*m_Iterator))->Data();
176 }
177
181 const XnValue& Value() const
182 {
183 return ((XnNode*)(*m_Iterator))->Next()->Data();
184 }
185
190 {
191 return m_Iterator.GetNode();
192 }
193
197 const XnNode* GetNode() const
198 {
199 return m_Iterator.GetNode();
200 }
201
202 protected:
210 ConstIterator(const XnHash* pHash, XnUInt16 nBin, XnList::Iterator listIterator) :
211 m_pHash(pHash), m_nCurrentBin(nBin), m_Iterator(listIterator)
212 {
213 // Find the first valid
214 while (m_Iterator == m_pHash->m_Bins[m_nCurrentBin]->end() &&
216 {
217 do
218 {
219 m_nCurrentBin++;
220 } while (m_pHash->m_Bins[m_nCurrentBin] == NULL);
222 }
223 }
224
230 ConstIterator(const XnHash* pHash) :
231 m_pHash(pHash), m_nCurrentBin(0), m_Iterator(m_pHash->m_Bins[XN_HASH_LAST_BIN]->end()) {}
232
239 };
240
244 class Iterator : public ConstIterator
245 {
246 public:
247 friend class XnHash;
248
254 inline Iterator(const Iterator& other) : ConstIterator(other) {}
255
260 {
261 ++(*(ConstIterator*)this);
262 return (*this);
263 }
267 inline Iterator operator++(int)
268 {
269 Iterator result = *this;
270 ++*this;
271 return (result);
272 }
273
278 {
279 --(*(ConstIterator*)this);
280 return (*this);
281 }
286 {
287 Iterator result = *this;
288 --*this;
289 return (result);
290 }
291
295 XnKey& Key() const { return (XnKey&)ConstIterator::Key(); }
296
300 XnValue& Value() const { return (XnValue&)ConstIterator::Value(); }
301
302 protected:
310 Iterator(const XnHash* pHash, XnUInt16 nBin, XnList::Iterator listIterator) :
311 ConstIterator(pHash, nBin, listIterator)
312 {}
313
319 Iterator(const XnHash* pHash) : ConstIterator(pHash) {}
320
321 Iterator(const ConstIterator& other) : ConstIterator(other) {}
322 };
323
324 friend class ConstIterator;
325
326public:
330 typedef XnHashValue (*XnHashFunction)(const XnKey& key);
334 typedef XnInt32 (*XnCompareFunction)(const XnKey& key1, const XnKey& key2);
335
340 {
341 m_nInitStatus = Init();
342 }
343
347 virtual ~XnHash()
348 {
349 if (m_Bins != NULL)
350 {
351 for (int i = 0; i < XN_HASH_NUM_BINS; ++i)
352 {
353 XN_DELETE(m_Bins[i]);
354 }
355 XN_DELETE_ARR(m_Bins);
356 }
357 }
358
365 {
366 return m_nInitStatus;
367 }
368
375 XnStatus Set(const XnKey& key, const XnValue& value)
376 {
377 XnHashValue HashValue = (*m_HashFunction)(key);
378
379 // Check if key already exists
380 if (m_Bins[HashValue] != NULL)
381 {
382 Iterator hiter(this);
383 if (Find(key, HashValue, hiter) == XN_STATUS_OK)
384 {
385 // Replace value
386 hiter.Value() = value;
387 return XN_STATUS_OK;
388 }
389 }
390 else
391 {
392 // First time trying to access this bin, create it.
393 m_Bins[HashValue] = XN_NEW(XnList);
394 if (m_Bins[HashValue] == NULL)
395 {
396 return XN_STATUS_ALLOC_FAILED;
397 }
398 if (HashValue < m_nMinBin)
399 m_nMinBin = HashValue;
400 }
401
402 // Get a new node for the key
403 XnNode* pKeyNode = XnNode::Allocate();
404 if (pKeyNode == NULL)
405 {
406 return XN_STATUS_ALLOC_FAILED;
407 }
408 pKeyNode->Data() = key;
409
410 // Get a new node for the value
411 XnNode* pValueNode = XnNode::Allocate();
412 if (pValueNode == NULL)
413 {
414 XnNode::Deallocate(pKeyNode);
415 return XN_STATUS_ALLOC_FAILED;
416 }
417 pValueNode->Data() = value;
418
419 // Concatenate the value node to the key node
420 pKeyNode->Next() = pValueNode;
421 pValueNode->Next() = NULL;
422
423 // Add the 2 nodes as the value to the key's list
424 XnStatus ListStatus = m_Bins[HashValue]->AddLast(XnValue(pKeyNode));
425 if (ListStatus != XN_STATUS_OK)
426 {
427 // Add failed. return the 2 nodes to the pool
428 XnNode::Deallocate(pKeyNode);
429 XnNode::Deallocate(pValueNode);
430 return ListStatus;
431 }
432
433 return XN_STATUS_OK;
434 }
435
444 XnStatus Get(const XnKey& key, XnValue& value) const
445 {
446 // Check if key exists
447 Iterator hiter(this);
448 XnStatus FindStatus = Find(key, hiter);
449 if (FindStatus != XN_STATUS_OK)
450 {
451 // Key doesn't exist!
452 return FindStatus;
453 }
454 value = hiter.Value();
455
456 return XN_STATUS_OK;
457 }
458
467 XnStatus Remove(const XnKey& key, XnValue& value)
468 {
469 // find the entry to which the key belongs
470 Iterator hiter(this);
471
472 XnStatus FindStatus = Find(key, hiter);
473 if (FindStatus != XN_STATUS_OK)
474 {
475 // no such entry!
476 return FindStatus;
477 }
478
479 // Remove by iterator
480 value = hiter.Value();
481 return Remove(hiter);
482 }
483
494 {
495 if (iter == end())
496 {
497 // Can't remove invalid node
498 return XN_STATUS_ILLEGAL_POSITION;
499 }
500
501 // Get value and key, to return to the caller
502 value = iter.Value();
503 key = iter.Key();
504
505 return Remove(iter);
506 }
507
516 {
517 if (iter == end())
518 {
519 // Can't remove invalid node
520 return XN_STATUS_ILLEGAL_POSITION;
521 }
522
523 XnNode* pNode = iter.GetNode();
524
525 XnNode* pKeyNode = (XnNode*)(pNode->Data());
526 XnNode* pValueNode = pKeyNode->Next();
527
528 // Return the nodes to the pool
529 XnNode::Deallocate(pKeyNode);
530 XnNode::Deallocate(pValueNode);
531
532 pNode->Previous()->Next() = pNode->Next();
533 pNode->Next()->Previous() = pNode->Previous();
534
535 XnNode::Deallocate(pNode);
536
537 return XN_STATUS_OK;
538 }
539
540
545 {
546 while (begin() != end())
547 Remove(begin());
548
549 return XN_STATUS_OK;
550 }
551
555 XnBool IsEmpty() const
556 {
557 return (begin() == end());
558 }
559
563 XnUInt32 Size() const
564 {
565 XnUInt32 nSize = 0;
566 for (Iterator iter = begin(); iter != end(); ++iter, ++nSize)
567 ;
568
569 return nSize;
570 }
571
580 XnStatus Find(const XnKey& key, ConstIterator& hiter) const
581 {
582 return ConstFind(key, hiter);
583 }
584
593 XnStatus Find(const XnKey& key, Iterator& hiter)
594 {
595 XnStatus nRetVal = XN_STATUS_OK;
596
597 ConstIterator& it = hiter;
598 nRetVal = ConstFind(key, it);
599 XN_IS_STATUS_OK(nRetVal);
600
601 return (XN_STATUS_OK);
602 }
603
608 {
609 return Iterator(this, m_nMinBin, m_Bins[m_nMinBin]->begin());
610 }
611
616 {
617 return ConstIterator(this, m_nMinBin, m_Bins[m_nMinBin]->begin());
618 }
619
624 {
625 return Iterator(this, XN_HASH_LAST_BIN, m_Bins[XN_HASH_LAST_BIN]->end());
626 }
627
632 {
633 return ConstIterator(this, XN_HASH_LAST_BIN, m_Bins[XN_HASH_LAST_BIN]->end());
634 }
635
643 XnStatus SetHashFunction(XnHashFunction hashFunction)
644 {
645 if (begin() != end())
646 {
647 return XN_STATUS_IS_NOT_EMPTY;
648 }
649 m_HashFunction = hashFunction;
650 return XN_STATUS_OK;
651 }
652
660 XnStatus SetCompareFunction(XnCompareFunction compareFunction)
661 {
662 if (begin() != end())
663 {
664 return XN_STATUS_IS_NOT_EMPTY;
665 }
666 m_CompareFunction = compareFunction;
667 return XN_STATUS_OK;
668 }
669
670protected:
671
673 {
675 XN_VALIDATE_ALLOC_PTR(m_Bins);
676
677 for (int i = 0; i < XN_HASH_NUM_BINS; i++)
678 {
679 m_Bins[i] = NULL;
680 }
681
682 m_Bins[XN_HASH_LAST_BIN] = XN_NEW(XnList); // We need this for an end() iterator
683 m_nMinBin = XN_HASH_LAST_BIN;
684
686 m_CompareFunction = &XnDefaultCompareFunction;
687 m_HashFunction = &XnDefaultHashFunction;
688 return XN_STATUS_OK;
689 }
690
700 XnStatus Find(const XnKey& key, XnHashValue hashValue, ConstIterator& hiter) const
701 {
702 if (m_Bins[hashValue] != NULL)
703 {
704 hiter = ConstIterator(this, hashValue, m_Bins[hashValue]->begin());
705 for (XnList::ConstIterator iter = m_Bins[hashValue]->begin();
706 iter != m_Bins[hashValue]->end(); ++iter, ++hiter)
707 {
708 if ((*m_CompareFunction)(key, hiter.Key()) == 0)
709 return XN_STATUS_OK;
710 }
711 }
712
713 return XN_STATUS_NO_MATCH;
714 }
715
716
719
720 XnUInt16 m_nMinBin;
721
722 /* Status of initialization - could be an error if memory could not be allocated. */
724
726 XnHashFunction m_HashFunction;
728 XnCompareFunction m_CompareFunction;
729
730private:
732
733 XnStatus ConstFind(const XnKey& key, ConstIterator& hiter) const
734 {
735 XnHashValue HashValue = (*m_HashFunction)(key);
736 return Find(key, HashValue, hiter);
737 }
738};
739
744#define XN_DECLARE_DEFAULT_KEY_MANAGER_DECL(decl, KeyType, ClassName, KeyTranslator) \
745 class decl ClassName \
746 { \
747 public: \
748 inline static XnHashValue Hash(KeyType const& key) \
749 { \
750 const XnKey _key = KeyTranslator::GetAsValue(key); \
751 return XnDefaultHashFunction(_key); \
752 } \
753 inline static XnInt32 Compare(KeyType const& key1, KeyType const& key2) \
754 { \
755 const XnKey _key1 = KeyTranslator::GetAsValue(key1); \
756 const XnKey _key2 = KeyTranslator::GetAsValue(key2); \
757 return XnDefaultCompareFunction(_key1, _key2); \
758 } \
759 };
760
765#define XN_DECLARE_DEFAULT_KEY_MANAGER(KeyType, ClassName, KeyTranslator) \
766 XN_DECLARE_DEFAULT_KEY_MANAGER_DECL(, KeyType, ClassName, KeyTranslator)
767
773#define XN_DECLARE_HASH_DECL(decl, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator, KeyManager) \
774 class decl ClassName : public XnHash \
775 { \
776 public: \
777 class decl ConstIterator : public XnHash::ConstIterator \
778 { \
779 public: \
780 friend class ClassName; \
781 inline ConstIterator(const ConstIterator& other) : XnHash::ConstIterator(other) {} \
782 inline ConstIterator& operator++() \
783 { \
784 ++(*(XnHash::ConstIterator*)this); \
785 return (*this); \
786 } \
787 inline ConstIterator operator++(int) \
788 { \
789 ConstIterator result = *this; \
790 ++*this; \
791 return result; \
792 } \
793 inline ConstIterator& operator--() \
794 { \
795 --(*(XnHash::ConstIterator*)this); \
796 return (*this); \
797 } \
798 inline ConstIterator operator--(int) \
799 { \
800 ConstIterator result = *this; \
801 --*this; \
802 return result; \
803 } \
804 inline KeyType const& Key() const \
805 { \
806 return KeyTranslator::GetFromValue(XnHash::ConstIterator::Key()); \
807 } \
808 inline ValueType const& Value() const \
809 { \
810 return ValueTranslator::GetFromValue(XnHash::ConstIterator::Value()); \
811 } \
812 protected: \
813 inline ConstIterator(const XnHash::ConstIterator& other) : \
814 XnHash::ConstIterator(other) {} \
815 }; \
816 class decl Iterator : public ConstIterator \
817 { \
818 public: \
819 friend class ClassName; \
820 inline Iterator(const Iterator& other) : ConstIterator(other) {} \
821 inline Iterator& operator++() \
822 { \
823 ++(*(ConstIterator*)this); \
824 return (*this); \
825 } \
826 inline Iterator operator++(int) \
827 { \
828 Iterator result = *this; \
829 ++*this; \
830 return result; \
831 } \
832 inline Iterator& operator--() \
833 { \
834 --(*(ConstIterator*)this); \
835 return (*this); \
836 } \
837 inline Iterator operator--(int) \
838 { \
839 Iterator result = *this; \
840 --*this; \
841 return result; \
842 } \
843 inline KeyType& Key() const \
844 { \
845 return (KeyType&)ConstIterator::Key(); \
846 } \
847 inline ValueType& Value() const \
848 { \
849 return (ValueType&)ConstIterator::Value(); \
850 } \
851 protected: \
852 inline Iterator(const XnHash::Iterator& other) : ConstIterator(other) {} \
853 }; \
854 public: \
855 ClassName() \
856 { \
857 SetHashFunction(Hash); \
858 SetCompareFunction(Compare); \
859 } \
860 virtual ~ClassName() \
861 { \
862 while (!IsEmpty()) \
863 Remove(begin()); \
864 } \
865 XnStatus Set(KeyType const& key, ValueType const& value) \
866 { \
867 Iterator oldIt = begin(); \
868 if (Find(key, oldIt) == XN_STATUS_OK) \
869 { \
870 oldIt.Value() = value; \
871 } \
872 else \
873 { \
874 XnKey _key = KeyTranslator::CreateValueCopy(key); \
875 XnValue _value = ValueTranslator::CreateValueCopy(value); \
876 XnStatus nRetVal = XnHash::Set(_key, _value); \
877 if (nRetVal != XN_STATUS_OK) \
878 { \
879 KeyTranslator::FreeValue(_key); \
880 ValueTranslator::FreeValue(_value); \
881 return (nRetVal); \
882 } \
883 } \
884 return XN_STATUS_OK; \
885 } \
886 XnStatus Get(KeyType const& key, ValueType& value) const \
887 { \
888 XnKey _key = KeyTranslator::GetAsValue(key); \
889 XnValue _value; \
890 XnStatus nRetVal = XnHash::Get(_key, _value); \
891 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
892 value = ValueTranslator::GetFromValue(_value); \
893 return XN_STATUS_OK; \
894 } \
895 XnStatus Get(KeyType const& key, ValueType*& pValue) const \
896 { \
897 XnKey _key = KeyTranslator::GetAsValue(key); \
898 XnValue _value; \
899 XnStatus nRetVal = XnHash::Get(_key, _value); \
900 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
901 pValue = &ValueTranslator::GetFromValue(_value); \
902 return XN_STATUS_OK; \
903 } \
904 XnStatus Remove(KeyType const& key) \
905 { \
906 ValueType dummy; \
907 return Remove(key, dummy); \
908 } \
909 XnStatus Remove(KeyType const& key, ValueType& value) \
910 { \
911 ConstIterator it = end(); \
912 XnStatus nRetVal = Find(key, it); \
913 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
914 value = it.Value(); \
915 return Remove(it); \
916 } \
917 inline XnStatus Remove(ConstIterator iter) \
918 { \
919 XnKey key = KeyTranslator::GetAsValue(iter.Key()); \
920 XnValue value = ValueTranslator::GetAsValue(iter.Value()); \
921 XnStatus nRetVal = XnHash::Remove(iter); \
922 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
923 KeyTranslator::FreeValue(key); \
924 ValueTranslator::FreeValue(value); \
925 return XN_STATUS_OK; \
926 } \
927 XnStatus Find(KeyType const& key, ConstIterator& hiter) const \
928 { \
929 XnKey _key = KeyTranslator::GetAsValue(key); \
930 XnHash::ConstIterator it = XnHash::end(); \
931 XnStatus nRetVal = XnHash::Find(_key, it); \
932 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
933 hiter = it; \
934 return XN_STATUS_OK; \
935 } \
936 XnStatus Find(KeyType const& key, Iterator& hiter) \
937 { \
938 XnKey _key = KeyTranslator::GetAsValue(key); \
939 XnHash::Iterator it = XnHash::end(); \
940 XnStatus nRetVal = XnHash::Find(_key, it); \
941 if (nRetVal != XN_STATUS_OK) return (nRetVal); \
942 hiter = it; \
943 return XN_STATUS_OK; \
944 } \
945 inline Iterator begin() { return XnHash::begin(); } \
946 inline ConstIterator begin() const { return XnHash::begin(); } \
947 inline Iterator end() { return XnHash::end(); } \
948 inline ConstIterator end() const { return XnHash::end(); } \
949 protected: \
950 virtual XnStatus Remove(XnHash::ConstIterator iter) \
951 { \
952 return Remove(ConstIterator(iter)); \
953 } \
954 inline static XnHashValue Hash(const XnKey& key) \
955 { \
956 KeyType const& _key = KeyTranslator::GetFromValue(key); \
957 return KeyManager::Hash(_key); \
958 } \
959 inline static XnInt32 Compare(const XnKey& key1, const XnKey& key2) \
960 { \
961 KeyType const _key1 = KeyTranslator::GetFromValue(key1); \
962 KeyType const _key2 = KeyTranslator::GetFromValue(key2); \
963 return KeyManager::Compare(_key1, _key2); \
964 } \
965 private: \
966 XN_DISABLE_COPY_AND_ASSIGN(ClassName); \
967 };
968
973#define XN_DECLARE_HASH(KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator, KeyManager) \
974 XN_DECLARE_HASH_DECL(, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator, KeyManager)
975
976#define _XN_DEFAULT_KEY_MANAGER_NAME(ClassName) _##ClassName##Manager
977
983#define XN_DECLARE_DEFAULT_MANAGER_HASH_DECL(decl, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator) \
984 XN_DECLARE_DEFAULT_KEY_MANAGER_DECL(decl, KeyType, _XN_DEFAULT_KEY_MANAGER_NAME(ClassName), KeyTranslator) \
985 XN_DECLARE_HASH_DECL(decl, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator, _XN_DEFAULT_KEY_MANAGER_NAME(ClassName))
986
991#define XN_DECLARE_DEFAULT_MANAGER_HASH(decl, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator) \
992 XN_DECLARE_DEFAULT_MANAGER_HASH_DECL(, KeyType, ValueType, ClassName, KeyTranslator, ValueTranslator)
993
994#define _XN_DEFAULT_KEY_TRANSLATOR(ClassName) _##ClassName##KeyTranslator
995#define _XN_DEFAULT_VALUE_TRANSLATOR(ClassName) _##ClassName##ValueTranslator
996
1002#define XN_DECLARE_DEFAULT_HASH_DECL(decl, KeyType, ValueType, ClassName) \
1003 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, KeyType, _XN_DEFAULT_KEY_TRANSLATOR(ClassName)) \
1004 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, ValueType, _XN_DEFAULT_VALUE_TRANSLATOR(ClassName)) \
1005 XN_DECLARE_DEFAULT_MANAGER_HASH_DECL(decl, KeyType, ValueType, ClassName, _XN_DEFAULT_KEY_TRANSLATOR(ClassName), _XN_DEFAULT_VALUE_TRANSLATOR(ClassName))
1006
1011#define XN_DECLARE_DEFAULT_HASH(KeyType, ValueType, ClassName) \
1012 XN_DECLARE_DEFAULT_HASH_DECL(, KeyType, ValueType, ClassName)
1013
1014#endif // _XN_HASH_H
void * XnValue
Definition XnDataTypes.h:36
XnValue XnKey
Definition XnHash.h:41
#define XN_HASH_LAST_BIN
Definition XnHash.h:33
#define XN_HASH_NUM_BINS
Definition XnHash.h:34
XnUInt8 XnHashValue
Definition XnHash.h:46
#define XN_IS_STATUS_OK(x)
Definition XnMacros.h:60
#define XN_DISABLE_COPY_AND_ASSIGN(TypeName)
Definition XnMacros.h:119
#define XN_VALIDATE_ALLOC_PTR(x)
Definition XnOS.h:128
#define XN_DELETE(p)
Definition XnOS.h:336
#define XN_NEW(type,...)
Definition XnOS.h:326
#define XN_DELETE_ARR(p)
Definition XnOS.h:337
#define XN_NEW_ARR(type, count)
Definition XnOS.h:335
XnUInt32 XnStatus
Definition XnStatus.h:34
#define XN_STATUS_OK
Definition XnStatus.h:37
Definition XnHash.h:74
XnUInt16 m_nCurrentBin
Definition XnHash.h:236
ConstIterator(const XnHash *pHash)
Definition XnHash.h:230
const XnNode * GetNode() const
Definition XnHash.h:197
ConstIterator operator--(int)
Definition XnHash.h:143
XnBool operator==(const ConstIterator &other) const
Definition XnHash.h:155
ConstIterator & operator++()
Definition XnHash.h:89
XnNode * GetNode()
Definition XnHash.h:189
const XnValue & Value() const
Definition XnHash.h:181
XnBool operator!=(const ConstIterator &other) const
Definition XnHash.h:165
const XnKey & Key() const
Definition XnHash.h:173
ConstIterator & operator--()
Definition XnHash.h:118
const XnHash * m_pHash
Definition XnHash.h:234
ConstIterator operator++(int)
Definition XnHash.h:108
XnList::Iterator m_Iterator
Definition XnHash.h:238
ConstIterator(const XnHash *pHash, XnUInt16 nBin, XnList::Iterator listIterator)
Definition XnHash.h:210
ConstIterator(const ConstIterator &other)
Definition XnHash.h:83
Definition XnHash.h:245
Iterator(const XnHash *pHash)
Definition XnHash.h:319
Iterator operator++(int)
Definition XnHash.h:267
Iterator(const XnHash *pHash, XnUInt16 nBin, XnList::Iterator listIterator)
Definition XnHash.h:310
Iterator(const Iterator &other)
Definition XnHash.h:254
Iterator & operator++()
Definition XnHash.h:259
XnKey & Key() const
Definition XnHash.h:295
Iterator & operator--()
Definition XnHash.h:277
XnValue & Value() const
Definition XnHash.h:300
Iterator operator--(int)
Definition XnHash.h:285
Iterator(const ConstIterator &other)
Definition XnHash.h:321
Definition XnHash.h:68
XnList ** m_Bins
Definition XnHash.h:718
XnStatus SetCompareFunction(XnCompareFunction compareFunction)
Definition XnHash.h:660
XnHashFunction m_HashFunction
Definition XnHash.h:726
ConstIterator begin() const
Definition XnHash.h:615
Iterator begin()
Definition XnHash.h:607
XnStatus Find(const XnKey &key, ConstIterator &hiter) const
Definition XnHash.h:580
XnUInt16 m_nMinBin
Definition XnHash.h:720
XnUInt32 Size() const
Definition XnHash.h:563
XnStatus Get(const XnKey &key, XnValue &value) const
Definition XnHash.h:444
XnBool IsEmpty() const
Definition XnHash.h:555
XnStatus Clear()
Definition XnHash.h:544
XnStatus GetInitStatus() const
Definition XnHash.h:364
ConstIterator end() const
Definition XnHash.h:631
XnStatus m_nInitStatus
Definition XnHash.h:723
XnStatus Init()
Definition XnHash.h:672
virtual XnStatus Remove(ConstIterator iter)
Definition XnHash.h:515
XnCompareFunction m_CompareFunction
Definition XnHash.h:728
virtual ~XnHash()
Definition XnHash.h:347
XnStatus SetHashFunction(XnHashFunction hashFunction)
Definition XnHash.h:643
XnStatus Set(const XnKey &key, const XnValue &value)
Definition XnHash.h:375
Iterator end()
Definition XnHash.h:623
XnHash()
Definition XnHash.h:339
XnStatus Remove(const XnKey &key, XnValue &value)
Definition XnHash.h:467
XnStatus Remove(ConstIterator iter, XnKey &key, XnValue &value)
Definition XnHash.h:493
XnStatus Find(const XnKey &key, Iterator &hiter)
Definition XnHash.h:593
XnStatus Find(const XnKey &key, XnHashValue hashValue, ConstIterator &hiter) const
Definition XnHash.h:700
Definition XnList.h:45
const XnNode * GetNode() const
Definition XnList.h:125
Definition XnList.h:154
Definition XnList.h:42
Iterator end()
Definition XnList.h:449
Iterator rbegin()
Definition XnList.h:465
Iterator begin()
Definition XnList.h:433
Definition XnNode.h:38
static void Deallocate(XnNode *pNode)
Definition XnNode.h:41
XnNode *& Previous()
Definition XnNode.h:60
static XnNode * Allocate()
Definition XnNode.h:40
XnValue & Data()
Definition XnNode.h:69
XnNode *& Next()
Definition XnNode.h:51