Cursor.FindSingleValue

Thomas Flemming tf at ttqv.com
Tue Dec 29 13:10:07 CST 2009


Hi Ruslan,

 > I hope this is very clear and detailed description :)
It is, thanks alot  :-))

Was misunderstanding, I was looking the whole time for some dirty-c++ 
-memory-pointer-binary-hacks..

But you are right. Like this it will work nicely.

Thomas :-)



Ruslan Zasukhin schrieb:
> On 12/29/09 6:29 PM, "Thomas Flemming" <tf at ttqv.com> wrote:
> 
> Hi Thomas,
> 
>>> And you have cursor ordered by field 1.
>>> So binary search can be used on this field1.
>>> Binary search is FAST. Even for million record this is only 20 steps.
>> In c++, but also in vb.net?
>> Maybe you can give a short example, on how this could work.
> 
> 1) binary search do even children in game
>         Guess a number.
> 
> I have choose number from 1 to 1M.
> Thomas, please guess this number!
> 
> I think you first guess will be 500,000. Yes
> Then I say bigger.
> 
> You say - 750,000, yes?
> I say smaller
> 
> You say 625,000
> And so on.
> 
> Algorithm itself I think you can easy find in Google
> 
> BINARY SEARCH works on ANY SORTED ARRAY.
> 
> You say that you have
>     "select * from table order by field1"
> 
> This means that your cursor is SORTED BY FIELD field1, right?
> This means that you have SORTED ARRAY of fields in fact.
> 
> 
> 2) and your task solution is:
> 
> cursor2 find single record.
> You extract for this record value field1
> 
> And now do binary search in the cursor1.
> 10 steps only for 1K records.
> 20 steps only for 1M records
> 30 steps only for 1 billion recs
> 
> If field1 is not unique field, then you can find GROUP of recs with the same
> value in field1. Right? But this group will be small. And here you can do
> linear search using RecID value from curs2.
> 
> I hope this is very clear and detailed description :)
> 

-- 
/****************************************
**   Dipl.-Ing. Thomas Flemming
**   Software Development
**
**   Touratech AG
**   Auf dem Zimmermann 7-9
**   D-78078 Niedereschach
**
**   mail  tf at ttqv.com
**   fon   +49 (0) 7728 9279-206
**   fax   +49 (0) 7728 9279-29
**
**   http://www.ttqv.com
**   http://www.touratech.de
**
**   ... und immer dem Pfeil nach!
***************************************/


More information about the Valentina mailing list