From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/arraylist.cpp | 100 ------------------------------------------------------ 1 file changed, 100 deletions(-) delete mode 100644 src/arraylist.cpp (limited to 'src/arraylist.cpp') diff --git a/src/arraylist.cpp b/src/arraylist.cpp deleted file mode 100644 index ef21426..0000000 --- a/src/arraylist.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "arraylist.h" -#include -#include - -ArrayList::ArrayList( int initSize, int growByFactor ) -{ - apData = new void *[initSize]; - nSize = 0; - nCapacity = initSize; - nGrowByFactor = growByFactor; -} - -ArrayList::~ArrayList( ) -{ - delete[] apData; -} - -void *ArrayList::getAt( int index ) -{ - if( index < 0 || index > nSize ) - return NULL; - - return apData[index]; -} - -void ArrayList::append( void *data ) -{ - insertBefore( data, nSize ); -} - -void ArrayList::insertBefore( void *data, int pos ) -{ - if( pos < 0 || pos > nSize ) - return; - - checkResize(); - memmove( &apData[pos+1], &apData[pos], (nSize-pos)*sizeof(void*) ); - apData[pos] = data; - nSize++; -} - -int ArrayList::getSize( ) -{ - return nSize; -} - -bool ArrayList::isEmpty( ) -{ - return nSize==0; -} - -void ArrayList::deleteAt( int index ) -{ - if( index < 0 || index >= nSize ) - return; - - memmove( &apData[index], &apData[index+1], (nSize-index-1)*sizeof(void *) ); - nSize--; -} - -void ArrayList::empty() -{ - // Probably the easiest as far as things go. - nSize = 0; -} - -void ArrayList::resizeTo( int newSize ) -{ - void **apNew = new void *[newSize]; - memmove( apNew, apData, nSize*sizeof(void *) ); - nCapacity = newSize; - delete[] apData; - apData = apNew; -} - -void ArrayList::checkResize() -{ - if( nSize >= nCapacity ) - { - resizeTo( nCapacity + nGrowByFactor ); - } -} - -void ArrayList::setSize( int newSize ) -{ - if( newSize < 0 ) - return; - - nSize = newSize; - checkResize(); -} - -void ArrayList::setAt( int index, void *data ) -{ - if( index < 0 || index >= nSize ) - return; - - apData[index] = data; -} - -- cgit v1.2.3