Best way to find a single record with simple find
Matthew Jew
mjew at icnc.com
Mon Aug 4 00:00:26 CDT 2003
I am wondering what the simplest way to find a single record given a
field containing unique, indexed values to search on.
It seems the simplest way in Valentina is to do something like:
FBL_BitSet *articleNumberBitSet = theTable.articleNumber.Find(
&anArticleNumber );
FBL_ArraySet *anArraySet = new FBL_ArraySet( *articleNumberBitSet );
ID_TYPE theRecordNumber = anArraySet(1);
which will give you the record number in three simple steps.
Of course, one could instead
FBL_BitSet *articleNumberBitSet = theTable.articleNumber.Find(
&anArticleNumber );
FBL_BitSetIterator *anIterator = new FBL_BitSetIterator(
*articleNumberBitSet );
ID_TYPE theRecordNumber = anIterator ->FirstItem();
again, three simple steps (I think I have it right).
I was wondering if in these cases where one *knows* there is only one
record to find
if there is a method like
ID_TYPE theRecordNumber =
theTable.articleNumber.FindFirstRecordMatching( &anArticleNumber );
which I imagine already exists in some form within the Valentina Kernel
which could be
exposed to developers. I know the existing methods allow you do
everything you need to
do, but I was just hoping to save calls to the memory manager. (It
seems wasteful to
allocate both a FBL_BitSet and either a FBL_ArraySet or
FBL_BitSetIterator just to
find a single record.)
Am I missing something simple, or is there a better way to do this?
- Matthew
More information about the Valentina
mailing list