author | zecke <zecke> | 2002-10-10 17:08:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-10 17:08:58 (UTC) |
commit | 1dcc1b1fc9fd35d959255452c8b5be1269ca4f44 (patch) (unidiff) | |
tree | 469d239dec74f5751f3aced43c4bae1f0f3a42e3 /libopie2/opiepim/orecordlist.h | |
parent | aa38f642a07810515dcc18ea38bf520e26d7f88e (diff) | |
download | opie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.zip opie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.tar.gz opie-1dcc1b1fc9fd35d959255452c8b5be1269ca4f44.tar.bz2 |
The Cache is finally in place
I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster....
I still have to fully implement read ahead
This change is bic but sc
Diffstat (limited to 'libopie2/opiepim/orecordlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index b6fa7fa..08f5c85 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -65,12 +65,13 @@ public: | |||
65 | private: | 65 | private: |
66 | QArray<int> m_uids; | 66 | QArray<int> m_uids; |
67 | uint m_current; | 67 | uint m_current; |
68 | const Base* m_temp; | 68 | const Base* m_temp; |
69 | bool m_end : 1; | 69 | bool m_end : 1; |
70 | T m_record; | 70 | T m_record; |
71 | bool m_direction :1; | ||
71 | 72 | ||
72 | /* d pointer for future versions */ | 73 | /* d pointer for future versions */ |
73 | class IteratorPrivate; | 74 | class IteratorPrivate; |
74 | IteratorPrivate *d; | 75 | IteratorPrivate *d; |
75 | }; | 76 | }; |
76 | /** | 77 | /** |
@@ -122,12 +123,14 @@ private: | |||
122 | template <class T> | 123 | template <class T> |
123 | ORecordListIterator<T>::ORecordListIterator() { | 124 | ORecordListIterator<T>::ORecordListIterator() { |
124 | m_current = 0; | 125 | m_current = 0; |
125 | m_temp = 0l; | 126 | m_temp = 0l; |
126 | m_end = true; | 127 | m_end = true; |
127 | m_record = T(); | 128 | m_record = T(); |
129 | /* forward */ | ||
130 | m_direction = TRUE; | ||
128 | } | 131 | } |
129 | template <class T> | 132 | template <class T> |
130 | ORecordListIterator<T>::~ORecordListIterator() { | 133 | ORecordListIterator<T>::~ORecordListIterator() { |
131 | /* nothing to delete */ | 134 | /* nothing to delete */ |
132 | } | 135 | } |
133 | 136 | ||
@@ -136,12 +139,13 @@ ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | |||
136 | // qWarning("ORecordListIterator copy c'tor"); | 139 | // qWarning("ORecordListIterator copy c'tor"); |
137 | m_uids = it.m_uids; | 140 | m_uids = it.m_uids; |
138 | m_current = it.m_current; | 141 | m_current = it.m_current; |
139 | m_temp = it.m_temp; | 142 | m_temp = it.m_temp; |
140 | m_end = it.m_end; | 143 | m_end = it.m_end; |
141 | m_record = it.m_record; | 144 | m_record = it.m_record; |
145 | m_direction = it.m_direction; | ||
142 | } | 146 | } |
143 | 147 | ||
144 | template <class T> | 148 | template <class T> |
145 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 149 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { |
146 | m_uids = it.m_uids; | 150 | m_uids = it.m_uids; |
147 | m_current = it.m_current; | 151 | m_current = it.m_current; |
@@ -153,35 +157,35 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter | |||
153 | } | 157 | } |
154 | 158 | ||
155 | template <class T> | 159 | template <class T> |
156 | T ORecordListIterator<T>::operator*() { | 160 | T ORecordListIterator<T>::operator*() { |
157 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 161 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
158 | if (!m_end ) | 162 | if (!m_end ) |
159 | /* FIXME | 163 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, |
160 | * until the cache is in place | 164 | m_direction ? Base::Forward : |
161 | * we do the uid match uid check | 165 | Base::Reverse ); |
162 | */ | ||
163 | m_record = m_temp->find( m_uids[m_current] ); | ||
164 | else | 166 | else |
165 | m_record = T(); | 167 | m_record = T(); |
166 | 168 | ||
167 | return m_record; | 169 | return m_record; |
168 | } | 170 | } |
169 | 171 | ||
170 | template <class T> | 172 | template <class T> |
171 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 173 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
174 | m_direction = true; | ||
172 | if (m_current < m_uids.count() ) { | 175 | if (m_current < m_uids.count() ) { |
173 | m_end = false; | 176 | m_end = false; |
174 | ++m_current; | 177 | ++m_current; |
175 | }else | 178 | }else |
176 | m_end = true; | 179 | m_end = true; |
177 | 180 | ||
178 | return *this; | 181 | return *this; |
179 | } | 182 | } |
180 | template <class T> | 183 | template <class T> |
181 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 184 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { |
185 | m_direction = false; | ||
182 | if ( m_current > 0 ) { | 186 | if ( m_current > 0 ) { |
183 | --m_current; | 187 | --m_current; |
184 | m_end = false; | 188 | m_end = false; |
185 | } else | 189 | } else |
186 | m_end = true; | 190 | m_end = true; |
187 | 191 | ||
@@ -204,13 +208,14 @@ template <class T> | |||
204 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 208 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
205 | return !(*this == it ); | 209 | return !(*this == it ); |
206 | } | 210 | } |
207 | template <class T> | 211 | template <class T> |
208 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 212 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
209 | const Base* t ) | 213 | const Base* t ) |
210 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) | 214 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
215 | m_direction( false ) | ||
211 | { | 216 | { |
212 | } | 217 | } |
213 | template <class T> | 218 | template <class T> |
214 | uint ORecordListIterator<T>::current()const { | 219 | uint ORecordListIterator<T>::current()const { |
215 | return m_current; | 220 | return m_current; |
216 | } | 221 | } |
@@ -251,9 +256,10 @@ ORecordList<T>::Iterator ORecordList<T>::end() { | |||
251 | template <class T> | 256 | template <class T> |
252 | uint ORecordList<T>::count()const { | 257 | uint ORecordList<T>::count()const { |
253 | return m_ids.count(); | 258 | return m_ids.count(); |
254 | } | 259 | } |
255 | template <class T> | 260 | template <class T> |
256 | T ORecordList<T>::operator[]( uint i ) { | 261 | T ORecordList<T>::operator[]( uint i ) { |
257 | return m_acc->find( m_ids[i] ); | 262 | /* forward */ |
263 | return m_acc->find( m_ids[i], m_ids, i ); | ||
258 | } | 264 | } |
259 | #endif | 265 | #endif |