author | simon <simon> | 2003-01-01 12:40:02 (UTC) |
---|---|---|
committer | simon <simon> | 2003-01-01 12:40:02 (UTC) |
commit | 25d85fe77aac5763ccc50bd532c2e661f4a64d1b (patch) (unidiff) | |
tree | 28a4a01f3bf232599db4f6c0d14162d6ac61bbd3 | |
parent | 31cbc7a5e6cc0a52b58d4de34cc8581a18bc4527 (diff) | |
download | opie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.zip opie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.tar.gz opie-25d85fe77aac5763ccc50bd532c2e661f4a64d1b.tar.bz2 |
T ORecordList<T>::operator[]( uint i ) {
- if ( i < 0 || (i+1) > m_ids.count() )
+ if ( i >= m_ids.count() )
-> fix warning and simplify :)
-rw-r--r-- | libopie/pim/orecordlist.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index b77a4ab..edcd729 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -220,81 +220,81 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | |||
220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
221 | m_direction( false ) | 221 | m_direction( false ) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | template <class T> | 224 | template <class T> |
225 | uint ORecordListIterator<T>::current()const { | 225 | uint ORecordListIterator<T>::current()const { |
226 | return m_current; | 226 | return m_current; |
227 | } | 227 | } |
228 | template <class T> | 228 | template <class T> |
229 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 229 | void ORecordListIterator<T>::setCurrent( uint cur ) { |
230 | if( cur < m_uids.count() ) { | 230 | if( cur < m_uids.count() ) { |
231 | m_end = false; | 231 | m_end = false; |
232 | m_current= cur; | 232 | m_current= cur; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | template <class T> | 235 | template <class T> |
236 | uint ORecordListIterator<T>::count()const { | 236 | uint ORecordListIterator<T>::count()const { |
237 | return m_uids.count(); | 237 | return m_uids.count(); |
238 | } | 238 | } |
239 | template <class T> | 239 | template <class T> |
240 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 240 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
241 | const Base* acc ) | 241 | const Base* acc ) |
242 | : m_ids( ids ), m_acc( acc ) | 242 | : m_ids( ids ), m_acc( acc ) |
243 | { | 243 | { |
244 | } | 244 | } |
245 | template <class T> | 245 | template <class T> |
246 | ORecordList<T>::~ORecordList() { | 246 | ORecordList<T>::~ORecordList() { |
247 | /* nothing to do here */ | 247 | /* nothing to do here */ |
248 | } | 248 | } |
249 | template <class T> | 249 | template <class T> |
250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { | 250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { |
251 | Iterator it( m_ids, m_acc ); | 251 | Iterator it( m_ids, m_acc ); |
252 | return it; | 252 | return it; |
253 | } | 253 | } |
254 | template <class T> | 254 | template <class T> |
255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { | 255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { |
256 | Iterator it( m_ids, m_acc ); | 256 | Iterator it( m_ids, m_acc ); |
257 | it.m_end = true; | 257 | it.m_end = true; |
258 | it.m_current = m_ids.count(); | 258 | it.m_current = m_ids.count(); |
259 | 259 | ||
260 | return it; | 260 | return it; |
261 | } | 261 | } |
262 | template <class T> | 262 | template <class T> |
263 | uint ORecordList<T>::count()const { | 263 | uint ORecordList<T>::count()const { |
264 | return m_ids.count(); | 264 | return m_ids.count(); |
265 | } | 265 | } |
266 | template <class T> | 266 | template <class T> |
267 | T ORecordList<T>::operator[]( uint i ) { | 267 | T ORecordList<T>::operator[]( uint i ) { |
268 | if ( i < 0 || (i+1) > m_ids.count() ) | 268 | if ( i >= m_ids.count() ) |
269 | return T(); | 269 | return T(); |
270 | /* forward */ | 270 | /* forward */ |
271 | return m_acc->find( m_ids[i], m_ids, i ); | 271 | return m_acc->find( m_ids[i], m_ids, i ); |
272 | } | 272 | } |
273 | template <class T> | 273 | template <class T> |
274 | int ORecordList<T>::uidAt( uint i ) { | 274 | int ORecordList<T>::uidAt( uint i ) { |
275 | return m_ids[i]; | 275 | return m_ids[i]; |
276 | } | 276 | } |
277 | 277 | ||
278 | template <class T> | 278 | template <class T> |
279 | bool ORecordList<T>::remove( int uid ) { | 279 | bool ORecordList<T>::remove( int uid ) { |
280 | QArray<int> copy( m_ids.count() ); | 280 | QArray<int> copy( m_ids.count() ); |
281 | int counter = 0; | 281 | int counter = 0; |
282 | bool ret_val = false; | 282 | bool ret_val = false; |
283 | 283 | ||
284 | for (uint i = 0; i < m_ids.count(); i++){ | 284 | for (uint i = 0; i < m_ids.count(); i++){ |
285 | if ( m_ids[i] != uid ){ | 285 | if ( m_ids[i] != uid ){ |
286 | copy[counter++] = m_ids[i]; | 286 | copy[counter++] = m_ids[i]; |
287 | 287 | ||
288 | }else | 288 | }else |
289 | ret_val = true; | 289 | ret_val = true; |
290 | } | 290 | } |
291 | 291 | ||
292 | copy.resize( counter ); | 292 | copy.resize( counter ); |
293 | m_ids = copy; | 293 | m_ids = copy; |
294 | 294 | ||
295 | 295 | ||
296 | return ret_val; | 296 | return ret_val; |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | #endif | 300 | #endif |
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index b77a4ab..edcd729 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -220,81 +220,81 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | |||
220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
221 | m_direction( false ) | 221 | m_direction( false ) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | template <class T> | 224 | template <class T> |
225 | uint ORecordListIterator<T>::current()const { | 225 | uint ORecordListIterator<T>::current()const { |
226 | return m_current; | 226 | return m_current; |
227 | } | 227 | } |
228 | template <class T> | 228 | template <class T> |
229 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 229 | void ORecordListIterator<T>::setCurrent( uint cur ) { |
230 | if( cur < m_uids.count() ) { | 230 | if( cur < m_uids.count() ) { |
231 | m_end = false; | 231 | m_end = false; |
232 | m_current= cur; | 232 | m_current= cur; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | template <class T> | 235 | template <class T> |
236 | uint ORecordListIterator<T>::count()const { | 236 | uint ORecordListIterator<T>::count()const { |
237 | return m_uids.count(); | 237 | return m_uids.count(); |
238 | } | 238 | } |
239 | template <class T> | 239 | template <class T> |
240 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 240 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
241 | const Base* acc ) | 241 | const Base* acc ) |
242 | : m_ids( ids ), m_acc( acc ) | 242 | : m_ids( ids ), m_acc( acc ) |
243 | { | 243 | { |
244 | } | 244 | } |
245 | template <class T> | 245 | template <class T> |
246 | ORecordList<T>::~ORecordList() { | 246 | ORecordList<T>::~ORecordList() { |
247 | /* nothing to do here */ | 247 | /* nothing to do here */ |
248 | } | 248 | } |
249 | template <class T> | 249 | template <class T> |
250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { | 250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { |
251 | Iterator it( m_ids, m_acc ); | 251 | Iterator it( m_ids, m_acc ); |
252 | return it; | 252 | return it; |
253 | } | 253 | } |
254 | template <class T> | 254 | template <class T> |
255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { | 255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { |
256 | Iterator it( m_ids, m_acc ); | 256 | Iterator it( m_ids, m_acc ); |
257 | it.m_end = true; | 257 | it.m_end = true; |
258 | it.m_current = m_ids.count(); | 258 | it.m_current = m_ids.count(); |
259 | 259 | ||
260 | return it; | 260 | return it; |
261 | } | 261 | } |
262 | template <class T> | 262 | template <class T> |
263 | uint ORecordList<T>::count()const { | 263 | uint ORecordList<T>::count()const { |
264 | return m_ids.count(); | 264 | return m_ids.count(); |
265 | } | 265 | } |
266 | template <class T> | 266 | template <class T> |
267 | T ORecordList<T>::operator[]( uint i ) { | 267 | T ORecordList<T>::operator[]( uint i ) { |
268 | if ( i < 0 || (i+1) > m_ids.count() ) | 268 | if ( i >= m_ids.count() ) |
269 | return T(); | 269 | return T(); |
270 | /* forward */ | 270 | /* forward */ |
271 | return m_acc->find( m_ids[i], m_ids, i ); | 271 | return m_acc->find( m_ids[i], m_ids, i ); |
272 | } | 272 | } |
273 | template <class T> | 273 | template <class T> |
274 | int ORecordList<T>::uidAt( uint i ) { | 274 | int ORecordList<T>::uidAt( uint i ) { |
275 | return m_ids[i]; | 275 | return m_ids[i]; |
276 | } | 276 | } |
277 | 277 | ||
278 | template <class T> | 278 | template <class T> |
279 | bool ORecordList<T>::remove( int uid ) { | 279 | bool ORecordList<T>::remove( int uid ) { |
280 | QArray<int> copy( m_ids.count() ); | 280 | QArray<int> copy( m_ids.count() ); |
281 | int counter = 0; | 281 | int counter = 0; |
282 | bool ret_val = false; | 282 | bool ret_val = false; |
283 | 283 | ||
284 | for (uint i = 0; i < m_ids.count(); i++){ | 284 | for (uint i = 0; i < m_ids.count(); i++){ |
285 | if ( m_ids[i] != uid ){ | 285 | if ( m_ids[i] != uid ){ |
286 | copy[counter++] = m_ids[i]; | 286 | copy[counter++] = m_ids[i]; |
287 | 287 | ||
288 | }else | 288 | }else |
289 | ret_val = true; | 289 | ret_val = true; |
290 | } | 290 | } |
291 | 291 | ||
292 | copy.resize( counter ); | 292 | copy.resize( counter ); |
293 | m_ids = copy; | 293 | m_ids = copy; |
294 | 294 | ||
295 | 295 | ||
296 | return ret_val; | 296 | return ret_val; |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | #endif | 300 | #endif |