home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
bc45
/
clobss.pak
/
BSORTARY.CPO
< prev
next >
Wrap
Text File
|
1997-07-23
|
2KB
|
66 lines
/*------------------------------------------------------------------------*/
/* */
/* BSORTARY.CPP */
/* */
/* Copyright Borland International 1991, 1993 */
/* All Rights Reserved */
/* */
/*------------------------------------------------------------------------*/
#if !defined( TEMPLATES )
#define TEMPLATES
#endif
#if 0
#if !defined( __SORTABLE_H )
#include "classlib\obsolete\sortable.h"
#endif // __SORTABLE_H
#if !defined( __ARRAYS_H )
#include "classlib\arrays.h"
#endif // __ARRAYS_H
void BI_ISObjectVector::add( Object _FAR *o )
{
if( count_ >= lim )
resize( count_+1 );
unsigned loc = count_++;
while( loc > 0 && *(Sortable _FAR *)o < *(Sortable _FAR *)(void _FAR *)(data[loc-1]) )
{
data[loc] = data[loc-1];
loc--;
}
data[loc] = o;
}
unsigned BI_ISObjectVector::find( void _FAR * obj ) const
{
unsigned lower = 0;
unsigned upper = count_-1;
if( count_ != 0 )
{
while( lower < upper && upper != UINT_MAX )
{
unsigned middle = (lower+upper)/2;
if( *(const Sortable _FAR *)(void _FAR *)(data[middle]) ==
*(const Sortable _FAR *)obj
)
return middle;
if( *(const Sortable _FAR *)(const void _FAR *)(data[middle]) <
*(const Sortable _FAR *)obj
)
lower = middle+1;
else
upper = middle-1;
}
}
if( lower == upper &&
*(const Sortable _FAR *)(const void _FAR *)(data[lower]) == *(const Sortable _FAR *)obj
)
return lower;
else
return UINT_MAX;
}
#endif