CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Apr 2010
    Posts
    22

    Lightbulb Alternative to Sorted Dictionary

    Hi, guys.

    If you are developing for .NET 3.5, but the Sorted Dictionary collection works too slow (as usual),
    an alternative can be found on http://homedimension.webs.com
    The SingleDataHub collection has the same functionality, with up to 8 times better performance!
    Also the MultipleDataHub collection allows adding several values per key!

    Chec it out

  2. #2
    Join Date
    Dec 2007
    Posts
    234

    Re: Alternative to Sorted Dictionary

    "allows adding several values per key!"

    Then it's not much of a key if it can refer to multiple things. How do I get back to the one I want?

    -tg

  3. #3
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    "allows adding several values per key!"

    Then it's not much of a key if it can refer to multiple things. How do I get back to the one I want?

    -tg
    Not quite true. The primery key in a DB can point you to the values of all other columns, meaning multiple values, but still IS key. So the key does not point to values elsewhere in the collection, just has several of it's own. Check the doc. , there is a diagram, I hope it makes things clear
    Last edited by daniel_st; April 22nd, 2010 at 07:39 AM.

  4. #4
    Join Date
    Dec 2007
    Posts
    234

    Re: Alternative to Sorted Dictionary

    So, in short, you've re-invented a datatable.

    Effectively this is what it is:
    Dictionary (Of String, DataRow)


    -tg

  5. #5
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    So, in short, you've re-invented a datatable.

    Effectively this is what it is:
    Dictionary (Of String, DataRow)


    -tg

    Sure! Only 10 times faster!

    Edit: And sorted.
    Last edited by daniel_st; April 22nd, 2010 at 10:03 AM.

  6. #6
    Join Date
    Dec 2007
    Posts
    234

    Re: Alternative to Sorted Dictionary

    Huh.... just out of curiosity how are these additional columns referenced then?

    It would be nice if there was some sample code showing the items in use.

    I hope this isn't coming across as criticism, I'm just trying to get you to sell me on the idea. If what I have is basically a (Sorted)Dictionary with DataRows in it, why wouldn't I just use a datatable in the first place? Also does your uber dictionary support LINQ? So far the only advantage I've heard is performance. Sell it to me. Make me want it! :P

    (of course it doesn't help that I rarely use the Dictionary class in the first place, and I don't think I've ever come across a situation where I *needed* my dictionary sorted. - also I can't hit RS from the office, so I can't simply d/l it and tinker).

    -tg

  7. #7
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    Huh.... just out of curiosity how are these additional columns referenced then?

    It would be nice if there was some sample code showing the items in use.

    I hope this isn't coming across as criticism, I'm just trying to get you to sell me on the idea. If what I have is basically a (Sorted)Dictionary with DataRows in it, why wouldn't I just use a datatable in the first place? Also does your uber dictionary support LINQ? So far the only advantage I've heard is performance. Sell it to me. Make me want it! :P

    (of course it doesn't help that I rarely use the Dictionary class in the first place, and I don't think I've ever come across a situation where I *needed* my dictionary sorted. - also I can't hit RS from the office, so I can't simply d/l it and tinker).

    -tg
    Yes, I apprecciate it. This is contructive criticism, while some other people have just been a**holes, completely rejecting the idea, for the sole reason it's not theirs.

    The only advantage is performance. For now. And ease of use, if you wish.

    I personally *personally* find collections easier to manage than any DB implementation, also way cheaper than SQL engine. And not only from the financial point. SQLE requires time to install, and then resources to run.

    No, it does not support LINQ yet, but it's on the list for v2

    What I target here is not to reject DB. I jsut underlined one similarity. There is no integrated sorted collection, that represents columns. That's why I made it. It comes more like bonus, it is not the main focus of the assembly.
    The Single collection is. The one that outperforms the SortedDict, while having the same functionality. The rest is the gum that comes with the sandwitch.

    EDIT: To answer the actual question- there is an example in the Doc

  8. #8
    Join Date
    Dec 2007
    Posts
    234

    Re: Alternative to Sorted Dictionary

    When I need small light weigh databases, I usually resort to SQL CE (only 7 DLLs to xcopy and it's up and running). Naturally since it's stripped down, it looses some effectiveness, but then if what I'm losing is something I need SQL CE probalbly isn't the right tool in the first place... but I digress. As for the gum, I 'd rather it have lettuce, some tomatoes and a nice slice of ham.

    "there is an example in the Doc " -- I assumed as much but as I noted earlier: "I can't hit RS from the office, so I can't simply d/l it" ... gotta love firewalls.

    -tg

  9. #9
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    When I need small light weigh databases, I usually resort to SQL CE (only 7 DLLs to xcopy and it's up and running). Naturally since it's stripped down, it looses some effectiveness, but then if what I'm losing is something I need SQL CE probalbly isn't the right tool in the first place... but I digress. As for the gum, I 'd rather it have lettuce, some tomatoes and a nice slice of ham.

    "there is an example in the Doc " -- I assumed as much but as I noted earlier: "I can't hit RS from the office, so I can't simply d/l it" ... gotta love firewalls.

    -tg
    Oh, sorry, didn't get that part. I'll have to find better host, I know.. Well, you got an index, referring to the virtual "columns", so you just

    .Find(key).Value[columnIndex];

    And if you're gonna use a stripped DB, then you get pretty much only the read/write functionality. And you got the same with my collection, in 1 DLL (mm).

    But anyway, as I noted, the MultipleDataHub is an alternative for whoever cares for it.
    The SingleDataHub is an alternative for everyone.
    (even though I think both of them are same revolutionary)

  10. #10
    Join Date
    Dec 2007
    Posts
    234

    Re: Alternative to Sorted Dictionary

    Actually... I may give it a go this weekend... I think I just might have a pet project where something like this would work perfectly. I was originally going to use SQL CE for the data storage, but I'm thinking I might go with XML or binary serialization, and this might be handy for helping to keep things properly relationed after rehydrating.

    -tg

  11. #11
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    Actually... I may give it a go this weekend... I think I just might have a pet project where something like this would work perfectly. I was originally going to use SQL CE for the data storage, but I'm thinking I might go with XML or binary serialization, and this might be handy for helping to keep things properly relationed after rehydrating.

    -tg
    Great, keep me updated please, on the progress and the behaviour of my class

    good luck

    EDIT: Download the new version, i made some improvements, also tested the serialization: collection with 100,000 string keys and 3x100,000 string values, so total of 400,000 strings
    serializes in 4s
    deserializes in 15s
    (which might seem a lot, but I dare to say, Sorted Dict with far less entries (2x50,000) was deserializing over a minute)
    Last edited by daniel_st; April 22nd, 2010 at 03:22 PM.

  12. #12
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    Quote Originally Posted by TechGnome View Post
    Also does your uber dictionary support LINQ?
    Actually it does. Just I had never used LINQ and I did not understand what you mean by "support" by the time you asked.

  13. #13
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    A new version of the DataHub collection is available for download. A bug has been found and eliminated, so whoever uses my collection- please update. Also the MultipleDataHub class has been removed, and is available through the PRO version only, as I was advised by some people.

    However, if TechGnome is still interested in using it, I will provide. pm me for contact.

  14. #14
    Join Date
    Apr 2010
    Posts
    22

    Re: Alternative to Sorted Dictionary

    I have included improved versions of the DataHub classes in the new release of DataHubPro.

    Also there are some additional features.
    If you need a size-limitless collection (DataStorage)
    or a size-limitless in-memory encrypted String with enumerators (unlike .NET's SecureString)..
    go to http://homedimension.webs.com and check the WebStore for DataHubPro, v1.4

    PS: The price's not that high. There are some way less usefull assemblies that cost a lot more! +you get the new versions for free

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

Featured