When Borland began shipping Borland C++ version 3.1, the company added a new container class library called the Borland International Data Structures (BIDS), which takes advantage of class templates. The BIDS library provides you with class templates you can use to derive container classes (arrays, lists, stacks, and so on) for your own data types.
Although Borland C++ 3.1 is a very solid product, the BIDS library version that ships with version 3.1 contains a minor problem with the BI_ISVectorImp class template. This problem can be very hard to track down. Version 4.0 of the compiler corrects this problem as part of a BIDS library redesign. If you're using version 4.0, you don't need to worry about this problem.
However, if you're using version 3.1 and you want to use
either the BI_ISArrayAsVector or the BI_ISObjectVector
BIDS class template, which Borland derived from BI_ISVectorImp,
or the BI_ISVectorImp class template itself, you'll
want to change the source code to avoid problems with this class
template. In this article, we'll tell you how to locate
and correct a problem with the find() member function
of the BI_ISVectorImp class template.
When you use the BI_ISVectorImp class template (either
directly or through inheritance), you'll call the find()
function to determine the index of an item in the array that matches
a search item. For example, if you create a sorted array of pointers
to integers with
BI_ISVectorImp<int> intArray(1, 1);
you can search for a pointer to an integer whose value is 3 by
adding
int* searchValue = new int(3); int index = intArray.find(searchValue);
If the intArray array contains a pointer to an integer whose value is 3, the find() function will return that pointer's index in the array. If there aren't any pointers to an integer with a value of 3, the find() function should return the unsigned integer value 65,535 as an error code.
However, under some circumstances, the find() function
will try to reference locations outside the boundaries of the
array. See Under the hood - Examining the find () function
below, for more information on what happens inside the find()
function.
To fix the BI_ISVectorImp class template's find()
function, first launch version 3.0 or 3.1 of the Borland C++ Integrated
Development Environment (IDE). When the IDE desktop appears, choose
Open... from the File menu. In the File Name entry field
of the Open A File dialog box, enter
\BORLANDC\CLASSLIB\INCLUDE\VECTIMP.H
and click OK.
Next, choose Go To Line Number from the Search menu, enter 815
in the Enter New Line Number entry field, and click OK. You should
now see the function shown in Figure B of Under the hood - Examining the find () function. In line 815, change
while(lower < upper)
to
while((lower < upper) && (upper != UINT_MAX))
When you finish making this change, choose Save from the File
menu and then choose Close from the Window menu. Now, you can
safely use the BI_ISVectorImp class in your projects.
Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.