diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
commit | f4b191f0ea396b58465bfba40749977780a3af58 (patch) | |
tree | 891490e91ab3b67524be67b2b71c85d84fd2f92a /src/old/ordhash.h | |
parent | 292ae9453e7fdb2f1023ed9dfc99cbcd751f8b90 (diff) | |
download | libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.gz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.bz2 libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.xz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.zip |
Just removing some things that are cluttering up the source tree.
Diffstat (limited to 'src/old/ordhash.h')
-rw-r--r-- | src/old/ordhash.h | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/src/old/ordhash.h b/src/old/ordhash.h deleted file mode 100644 index e946f95..0000000 --- a/src/old/ordhash.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | #ifndef ORD_HASH_H | ||
2 | #define ORD_HASH_H | ||
3 | |||
4 | #include "hash.h" | ||
5 | #include "tqsort.h" | ||
6 | |||
7 | template<typename key, typename value, typename cmpfnc, typename sizecalc = __calcNextTSize_fast, typename keyalloc = std::allocator<key>, typename valuealloc = std::allocator<value>, typename challoc = std::allocator<uint32_t> > | ||
8 | class OrdHash : public Hash<key, value, sizecalc, keyalloc, valuealloc, challoc> | ||
9 | { | ||
10 | public: | ||
11 | OrdHash() : | ||
12 | bSorted( false ), | ||
13 | aData( NULL ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | virtual ~OrdHash() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | protected: | ||
22 | virtual void invalidate() | ||
23 | { | ||
24 | bSorted = false; | ||
25 | delete[] aData; | ||
26 | aData = NULL; | ||
27 | } | ||
28 | |||
29 | virtual void onInsert() | ||
30 | { | ||
31 | invalidate(); | ||
32 | } | ||
33 | |||
34 | virtual void onUpdate() | ||
35 | { | ||
36 | invalidate(); | ||
37 | } | ||
38 | |||
39 | virtual void onDelete() | ||
40 | { | ||
41 | invalidate(); | ||
42 | } | ||
43 | |||
44 | virtual void onReHash() | ||
45 | { | ||
46 | invalidate(); | ||
47 | } | ||
48 | |||
49 | virtual std::pair<key,value> getAtPos( uint32_t nPos ) | ||
50 | { | ||
51 | return Hash<key, value, sizecalc, keyalloc, valuealloc, challoc>::getAtPos( aData[nPos].nIndex ); | ||
52 | } | ||
53 | |||
54 | virtual void buildIndex() | ||
55 | { | ||
56 | aData = new struct ind[this->nFilled]; | ||
57 | uint32_t k = 0; | ||
58 | for( uint32_t j = 0; j < this->nCapacity; j++ ) | ||
59 | { | ||
60 | if( this->isFilled( j ) ) | ||
61 | { | ||
62 | if( !this->isDeleted( j ) ) | ||
63 | { | ||
64 | aData[k].pVal = &(this->aValues[j]); | ||
65 | aData[k].nIndex = j; | ||
66 | k++; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | tqsort<typename OrdHash<key, value, cmpfnc, sizecalc, keyalloc, valuealloc, challoc>::ind, cmpfnc, value **>( aData, this->nFilled ); | ||
72 | |||
73 | bSorted = true; | ||
74 | } | ||
75 | |||
76 | virtual uint32_t getFirstPos( bool &bFinished ) | ||
77 | { | ||
78 | if( bSorted == false ) | ||
79 | buildIndex(); | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | virtual uint32_t getNextPos( uint32_t nPos, bool &bFinished ) | ||
85 | { | ||
86 | if( nPos+1 >= this->nFilled ) | ||
87 | { | ||
88 | bFinished = true; | ||
89 | return 0; | ||
90 | } | ||
91 | return ++nPos; | ||
92 | } | ||
93 | public: | ||
94 | typedef struct ind | ||
95 | { | ||
96 | value *pVal; | ||
97 | uint32_t nIndex; | ||
98 | } ind; | ||
99 | private: | ||
100 | bool bSorted; | ||
101 | ind *aData; | ||
102 | }; | ||
103 | |||
104 | #endif | ||