Results 1 to 17 of 17

Thread: Collection implementatio

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Collection implementatio

    Here is my implementatio of collectio. It is faster and uses less memory. Every operation can be completed in log time in the worst case scenario. I'v been using it for the last 20 years and maybe now is time to share it with the world.


    Source can be found here:
    https://sourceforge.net/projects/van...htycollection/


    Here is an example of how to use it

    Code:
    Private Sub Command1_Click()
        Dim c As New VMMC, i As Long
        
        c.Cols = 2
        c.ColType(0) = vmeInteger
        c.ColType(1) = vmeString
        
        ' add million items at the end
        For i = 0 To 1000000
            c.Add , i
            c(i, , 0) = i
            c(i, , 1) = Str(i)
        Next
    
        ' delete 500000 items from the middle
        For i = 0 To 500000
            c.Remove Int(c.Count / 2)
        Next
    
        ' update values
        For i = 0 To c.Count - 1
            c.Cell(i, , 0) = 1000000 - i
        Next
    
        MsgBox c.Count
    End Sub

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    And COM DLL is also available in the sourceforge link.

  3. #3
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    It would be nice to be able to change the C++ code to VB6 code.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    Quote Originally Posted by SearchingDataOnly View Post
    It would be nice to be able to change the C++ code to VB6 code.
    I don't think many people would care for such project. It is faster this way and it works well as it is.

  5. #5
    Fanatic Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    579

    Re: Collection implementatio

    Nice project works very well.
    I haven't had time to investigate the dll.
    is it possible to use it without registering it like other dlls are used.
    example.
    Code:
    Private Declare Function getNumPages Lib "pdftotext.dll" (ByVal lpFileName As String, Optional ByVal lpLogCallbackFunc As Long, Optional ByVal lpOwnerPassword As String, Optional ByVal lpUserPassword As String) As Integer
    Regards thanks

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    Quote Originally Posted by yokesee View Post
    Nice project works very well.
    I haven't had time to investigate the dll.
    is it possible to use it without registering it like other dlls are used.
    example.
    Code:
    Private Declare Function getNumPages Lib "pdftotext.dll" (ByVal lpFileName As String, Optional ByVal lpLogCallbackFunc As Long, Optional ByVal lpOwnerPassword As String, Optional ByVal lpUserPassword As String) As Integer
    Regards thanks
    This is COM dll and it should be used as such. I don't remember that there are any other exported functions except those required by COM specifications.

  7. #7
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    Quote Originally Posted by vamvam View Post
    I don't think many people would care for such project. It is faster this way and it works well as it is.
    An open source collection class that is better than VB6.Collection will be very popular with VB6ers.

    I'll take the time to compare your VMMC with RC6.MemDB/RC6.Recordset to see which one performs better. Thank you for sharing.
    Last edited by SearchingDataOnly; Jan 21st, 2025 at 05:04 AM.

  8. #8

  9. #9
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    Quote Originally Posted by VanGoghGaming View Post
    There are also the StringMap and PropertySet classes from WinRT, both highly optimized for their purposes.
    Very good information. Thank you, VanGoghGaming. Are StringMaps and PropertySets open source?

  10. #10
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,273

    Re: Collection implementatio

    These are high-level abstractions but the source code is readily available in the SDK and if you dig deep enough you can find the underlying hash_bytes function.

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    Quote Originally Posted by SearchingDataOnly View Post
    An open source collection class that is better than VB6.Collection will be very popular with VB6ers.

    I'll take the time to compare your VMMC with RC6.MemDB/RC6.Recordset to see which one performs better. Thank you for sharing.
    I would describe performance of VMMC as "jack of all trades, master of none". This means that if you have a problem you can solve with a map, if you use some implementation of hash map, it will probably perform better. If you have a problem you can solve with a simple array, it will perform better if you just use VB's Array. But if you need something that acts as an array, map and both, you probably won't find anything better than VMMC because VMMC can perform ANY operation in O(n)=log (n) (or O(n)=c) and still use memory gently.

  12. #12
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    Quote Originally Posted by VanGoghGaming View Post
    These are high-level abstractions but the source code is readily available in the SDK and if you dig deep enough you can find the underlying hash_bytes function.
    Thank you, VanGoghGaming.

  13. #13
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    Quote Originally Posted by vamvam View Post
    I would describe performance of VMMC as "jack of all trades, master of none". This means that if you have a problem you can solve with a map, if you use some implementation of hash map, it will probably perform better. If you have a problem you can solve with a simple array, it will perform better if you just use VB's Array. But if you need something that acts as an array, map and both, you probably won't find anything better than VMMC because VMMC can perform ANY operation in O(n)=log (n) (or O(n)=c) and still use memory gently.
    I tested your VMMC and it has excellent performance. I've always wanted to have a VMMC-like high-performance multi-column collection. It would be nice to be able to change VMMC's C++ code to VB6 code.

  14. #14

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    Quote Originally Posted by SearchingDataOnly View Post
    I tested your VMMC and it has excellent performance. I've always wanted to have a VMMC-like high-performance multi-column collection. It would be nice to be able to change VMMC's C++ code to VB6 code.
    And how would you implement columns in VB6? It is not fun if all the columns are just variants.

  15. #15
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    Quote Originally Posted by vamvam View Post
    And how would you implement columns in VB6? It is not fun if all the columns are just variants.
    Yes, that's probably the crux of the matter. From this point of view, it is almost impossible to use VB6 to achieve high performance and use less memory like VMMC. Thank you, vamvam.

    Multi-Column collection are one of the key classes that RC6 lacks the most.
    Last edited by SearchingDataOnly; Jan 22nd, 2025 at 09:58 PM.

  16. #16
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,644

    Re: Collection implementatio

    I wrote a simple MuliColumnList with RC6.ArrayList. I tested VMMC against MyMuliColumnList and the results are as follows:

    In VB6-IDE Mode
    Code:
    ====================================
    Test VMMC
    
    Add million items at the end:  3,911.42msec
    Delete 500000 items from the middle:  1,279.59msec
    Update values:  1,248.95msec
    Item count: 500000
    
    ====================================
    Test MyMultiColumnList
    
    Add million items at the end:  6,605.85msec
    Delete 500000 items from the middle: the operation was canceled because it took too long.
    Update values:  1,781.10msec
    Item count: 1000001
    In Exe Mode
    Code:
    ====================================
    Test VMMC
    
    Add million items at the end:  3,014.03msec
    Delete 500000 items from the middle:  333.41msec
    Update values:  808.62msec
    Item count: 500000
    
    ====================================
    Test MyMultiColumnList
    
    Add million items at the end:  3,677.15msec
    Delete 500000 items from the middle: the operation was canceled because it took too long.
    Update values:  1,163.66msec
    Item count: 1000001
    
    Delete 500000 items from the middle: 1,055,231.86msec
    Attached Files Attached Files
    Last edited by SearchingDataOnly; Jan 22nd, 2025 at 10:03 PM.

  17. #17

    Thread Starter
    New Member
    Join Date
    Jan 2025
    Posts
    7

    Re: Collection implementatio

    Quote Originally Posted by SearchingDataOnly View Post
    I wrote a simple MuliColumnList with RC6.ArrayList. I tested VMMC against MyMuliColumnList and the results are as follows:

    In VB6-IDE Mode
    Code:
    ====================================
    Test VMMC
    
    Add million items at the end:  3,911.42msec
    Delete 500000 items from the middle:  1,279.59msec
    Update values:  1,248.95msec
    Item count: 500000
    
    ====================================
    Test MyMultiColumnList
    
    Add million items at the end:  6,605.85msec
    Delete 500000 items from the middle: the operation was canceled because it took too long.
    Update values:  1,781.10msec
    Item count: 1000001
    In Exe Mode
    Code:
    ====================================
    Test VMMC
    
    Add million items at the end:  3,014.03msec
    Delete 500000 items from the middle:  333.41msec
    Update values:  808.62msec
    Item count: 500000
    
    ====================================
    Test MyMultiColumnList
    
    Add million items at the end:  3,677.15msec
    Delete 500000 items from the middle: the operation was canceled because it took too long.
    Update values:  1,163.66msec
    Item count: 1000001
    
    Delete 500000 items from the middle: 1,055,231.86msec
    As I see it, they both have similar performance and if ArrayList would have a cursor that moves forward and backward it would slightly outperform VMMC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width