BitSet operations

Joakim Schramm joakim at astrocalc.com
Fri May 5 12:48:08 CDT 2006


 

> -----Original Message-----
> From: valentina-bounces at lists.macserve.net 
> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of 
> Ruslan Zasukhin
> Sent: 04 May 2006 23:42
> To: valentina at lists.macserve.net
> Subject: Re: BitSet operations
> 
> 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 
> 
> Already STOP. 
> 
> So we talk about SINLE table with fields f1 and f2 ?

Yes. But you can do this with more then 1 table, right?

> 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
> 
>  
The following code doesn't work, and I don't know why, it allways returns a
NIL for the object to set. The Vset object passed to the function has over
5000 records and I know there is values in the range I look. But maybe you
can see why?

Public Function AddPlaceRec(uPlace As AtlDataUDT) As Boolean
Dim NewId As Long, NewPtr As Long
Dim lnk As VLink
Dim Res As VSet
Dim arr As VArraySet

With uPlace

    If Len(Trim$(.TownName)) Then
        If .CountryID = 0 Then
            .CountryID = mCountryID
        End If

        Set lnk = mAtlasDB.Link(lnkCountryHasZones)
        Set arr = lnk.FindLinked(.CountryID, tCountry, tZones)
        Set Res = arr

        If Res.Count > 1 Then
            Set lnk = mAtlasDB.Link(lnkCountryHasPlaces)
            Set Res = lnk.FindLinked(.CountryID, tCountry, tPlaces)
            NewPtr = FindZoneDataID(.LatDeg, .LongDeg, .LatSign, .LongSign,
Res)<---Function not working below
        Else
            NewPtr = arr.GetItemAt(1)
        End If

        tPlaces.SetBlank forAdd
......
End Function

Private Function FindZoneDataID(ByVal Lat As Long, ByVal Lng As Long, ByVal
SgnLat As Long, SgnLng As Long, oAllPlaces As VSet) As Long
Dim diffM As Long, diffP As Long, Fact As Long, Pid As Long, ptr As Long
Dim Itr As VSetIterator
Dim oSet As Vset
Dim oLatPlaces As VArraySet 'Try to use VBitSet gives arror on set below
Dim oLngPlaces As VArraySet

Set oLngPlaces = fLngDeg.FindValue(Lng, oAllPlaces)' always returns nil

'If no hit try close to values.
If oLngPlaces Is Nothing Then
    diffM = Lng
    diffP = Lng

    Do
        diffP = diffP + 1

        If diffP > 180 Then
            diffP = 180
            Fact = Fact + 1
        End If

        diffM = diffM - 1

        If diffM < 0 Then
            diffM = 0
            Fact = Fact + 1
        End If

        Set oLngPlaces = fLngDeg.FindRangeAsArraySet(True, diffM, diffP,
True, oAllPlaces)
    Loop While oLngPlaces Is Nothing

End If

Set oLatPlaces = fLatDeg.FindValue(Lat, oLngPlaces)

...
End Function

Joakim
> 
> --
> 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]
> 
> 
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
> 



More information about the Valentina mailing list