BitSet operations

Ruslan Zasukhin sunshine at public.kherson.ua
Fri May 5 00:41:45 CDT 2006


On 5/5/06 12:15 AM, "Joakim Schramm" <joakim at astrocalc.com> wrote:

Hi Joakim,

> Can you give some example on how to use BitSet operations? There is nothing
> in the examples and I tried to browse the mailing list without finding
> anything... There is a small part about it in the kernel doc but
> unfortunately too sparse for me to really grasp how to use it - I am sure
> it's very easy for you who have constructed it :-)
> 
> Basically what I want to do is this. I have a table were I like to find
> records that has some values in common. Lets say I have f1 and f2, and I
> have first done a FindLinked to get a sub set.

Already STOP. 

So we talk about SINLE table with fields f1 and f2 ?
It seems about single table. Then FindLinked() is our of game here.

> I have 2 value e.g 30 and 12,
> so I want to find all records that have these value 30 in f1 and 12 in f2 -

On SQL this looks simply:

    select * 
    from T1
    WHERE f1 = 30 AND f2 = 12

With Bitsets:

    res1 = f1.FindValue( 30 )
    res2 = f2.FindValue( 12 )

    res1.Intersect( res2 )      // AND of 2 sets.

    // res1 - now keep result

> or a range in one of them if nil is returned, like 30 AND 11-13?

SQL

    select * 
    from T1
    WHERE f1 = 30 AND f2 BETWEEN 11 AND 13

With Bitsets:

    res1 = f1.FindValue( 30 )
    res2 = f2.FindRange( true, 11, 13, true )  // this is math: [11, 13]

    res1.Intersect( res2 )      // AND of 2 sets.

    // res1 - now keep result

 
> I am sure this is very simple and I could quite easy do it in SQL BUT I like
> to learn working the API way with set's. If I have understand right
> "Interception" has to do with AND and Union with OR, just not clear on the
> rules in using the methods having more then 1 set.
> 
> Also, I know what "Difference", but again how it works with Set's - And what
> is "SymmetricDifference"?

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list