aboutsummaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/array.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/array.h b/src/array.h
index 39efb9e..ede43cc 100644
--- a/src/array.h
+++ b/src/array.h
@@ -297,6 +297,17 @@ namespace Bu
297 return *this; 297 return *this;
298 } 298 }
299 299
300 iterator operator+( int iAmnt )
301 {
302 if( iPos < 0 )
303 throw ArrayException(
304 "Cannot increment iterator past end of array.");
305 iPos += iAmnt;
306 if( iPos >= src.getSize() )
307 iPos = -1;
308 return *this;
309 }
310
300 iterator operator--( int ) 311 iterator operator--( int )
301 { 312 {
302 if( iPos < 0 ) 313 if( iPos < 0 )
@@ -316,6 +327,15 @@ namespace Bu
316 iPos = -1; 327 iPos = -1;
317 return *this; 328 return *this;
318 } 329 }
330
331 iterator operator-( int iAmnt )
332 {
333 if( iPos < src.getSize() )
334 iPos -= iAmnt;
335 if( iPos <= 0 )
336 iPos = -1;
337 return *this;
338 }
319 339
320 bool operator==( const iterator &oth ) const 340 bool operator==( const iterator &oth ) const
321 { 341 {
@@ -477,6 +497,36 @@ namespace Bu
477 return const_iterator( *this, -1 ); 497 return const_iterator( *this, -1 );
478 } 498 }
479 499
500 MyType &insert( iterator i, const value &rVal )
501 {
502 if( i.iPos == -1 )
503 {
504 append( rVal );
505 return *this;
506 }
507
508 _hardCopy();
509 if( core->iSize == core->iCapacity )
510 {
511 core->setCapacity( core->iCapacity + inc );
512 }
513 core->iSize++;
514
515 core->va.construct(
516 &core->pData[core->iSize-1],
517 core->pData[core->iSize-2]
518 );
519 for( int iPos = core->iSize-2; iPos > i.iPos; iPos-- )
520 {
521 core->va.destroy( &core->pData[iPos] );
522 core->va.construct( &core->pData[iPos], core->pData[iPos-1] );
523 }
524 core->va.destroy( &core->pData[i.iPos] );
525 core->va.construct( &core->pData[i.iPos], rVal );
526
527 return *this;
528 }
529
480 /** 530 /**
481 * If order is important, use this. It will delete the suggested item 531 * If order is important, use this. It will delete the suggested item
482 * and move the rest of the data up a spot. This is a time O(n) 532 * and move the rest of the data up a spot. This is a time O(n)