/*------------------------------------------------------------------------*/ /* */ /* SORTARRY.CPP */ /* */ /* Copyright Borland International 1991, 1993 */ /* All Rights Reserved */ /* */ /*------------------------------------------------------------------------*/ #if !defined( __STDLIB_H ) #include #endif // __STDLIB_H #if !defined( __IOSTREAM_H ) #include #endif // __IOSTREAM_H #if !defined( __SORTARRY_H ) #include "classlib\obsolete\sortarry.h" #endif // __SORTARRY_H void SortedArray::add( Object& toAdd ) { if( toAdd.isSortable() ) { if( lastElementIndex == upperbound ) { reallocate( arraySize() + 1 ); } int insertionPoint = lowerbound; while( insertionPoint <= lastElementIndex && (Sortable&)objectAt( insertionPoint ) < (Sortable&)toAdd ) insertionPoint++; insertEntry( insertionPoint ); setData( insertionPoint, &toAdd ); itemsInContainer++; lastElementIndex++; } else ClassLib_error( __ENOTSORT ); } void SortedArray::detach( int loc, DeleteType dt ) { if( loc != INT_MIN ) { if( delObj(dt) ) delete ptrAt( loc ); removeEntry( loc ); itemsInContainer--; if( loc <= lastElementIndex ) lastElementIndex--; } } void SortedArray::detach( Object& toDetach, DeleteType dt ) { int detachPoint = find( toDetach ); detach( detachPoint, dt ); }