VB.NET Guru - How to Handle a Huge Collection of Strings

It's time for another July TechNet Guru winner!

Congratulations to Reed Kimble, our VB Guru winner for July! See the TechNet Guru Contributions for July 2013.

 

Reed Kimble's avatar 

About Reed: [Adult Swim] fan, EQII player, and has broad interests in computers, electronics, and programming. Enjoys outdoors in forest, mountain, and/or secluded lake settings. Fascinated by social and spiritual aspects of humanity.

 

 

   

Here is the gold-medal-winning article:

How to Handle a Huge Collection of Strings in VB.Net

 

 Now let's look at all the winning articles:

 

Guru Award  Visual Basic Technical Guru - July 2013  

Gold Award Winner

 

Reed Kimble How to Handle a Huge Collection of Strings in VB.Net MR: "Extremely well written article. Great details about tradeoffs of memory vs. performance. " Ed Price: "It looks fantastic and is easy to read. Great introductions/explanations for each code snippet!" Richard Mueller: "Outstanding article. Clear explanations and clear code. This can be extremely useful in cases where a dictionary object doesn't help." SB: "A nice article which details a problem, identifies a solution and gives credible numbers in the summary to show the performance improvement. The code is simple to understand and deals with a number of issues. with a nice description and the relevent code." Anthony D. Green: "I love how the author introduces the text with several practical examples of where such a technique might be valuable. Good coverage of implementing the .NET collection pattern and a more performant alternative to linear search."

Silver Award Winner

 

Paul Ishak Knife Thrower! Anthony D. Green: "It's great when learning can be made fun and game programming is the quintessential example of that. This article was a blast!" MR: "Great article. Could use more structure and formatting. Maybe trying to do too much? Article should try and teach, not just talk about the code" Ed Price: "So this is just hilarious. It's fun, and it has great interactions in the comments. From the Thinker: "Good article! I tried the code sample it was great!" As Mark mentioned, if this article sought to educate more on why and when the reader should do specific things, it would be perfect!" Richard Mueller: "Amazing. Detailed explanation. Perhaps we didn't need information on namespaces." SB: "The article was good, however there is a lot of code and the article feels as though its just documenting the application for the most part."

Bronze Award Winner

 

The Thinker Binary and Back Anthony D. Green: "Short and sweet. This article concisely covers a valuable beginner." SB: "Simple small article - straightforward and too the point. basic level but these are often what are asked on the forums and addresses the point." Ed Price: "I'm a big fan of geeky binary, so it's fantastic to see this! And I love the video reference at the end! Very entertaining! This would be even better if it explained all the core concepts." Richard Mueller: "Good explanation of very basic functions." MR: "Important topic (binary representation) but I felt that the article was too short and could dig more into how an integer is represented in binary and how to build code to use that concept. Also could show advanced ways."

Five articles, from three entrants, all who have won an award for July. Some great articles too! Thanks again folks, hopefully see you all in with a chance of winning more for August!

 

 

And here's an excerpt from the article:

 

 

Implementing the Collection

Although the basic premise of the collection is fairly straightforward, the code implementation can be a bit tricky in that our tree of characters must still be able to expose itself as a collection of complete strings.  To achieve this, we need to create a custom enumerator for our collection that knows how to find each complete string within the tree of characters.

We can begin by creating a “SearchableStringCollection” class which implements ICollection(Of String) and declares a backing store of Dictionary(Of Char, SearchableStringCollection) :

PublicClass SearchableStringCollection

Implements ICollection(Of ``String``)

 

Private _ListCore ``AsNew Dictionary(Of ``Char``, SearchableStringCollection)

 

EndClass

There are a few simple class members that we can implement without first defining our actual character storage and retrieval mechanisms.  First we can implement the Count property by simply defining a private _Count field to hold the number of full strings in the collection.  We’ll want to track this total manually as items are added to and removed from the collection because our backing store will not have this information readily at hand (we would have to enumerate the entire collection to find and count all of the complete strings, and that would have undesirable performance).

Private _Count ``AsInteger

PublicReadOnly Property Count ``AsInteger Implements System.Collections.Generic.ICollection(Of ``String``).Count

Get

Return_Count

EndGet

EndProperty

 

 

===================================

 

Read the rest here:

How to Handle a Huge Collection of Strings in VB.Net

 

 

Thanks to Reed Kimble for your great contribution to the TechNet Guru contest! You can read about all the July winners here: TechNet Guru Awards - July 2013

 

Also, for the August Guru competition, see TechNet Guru Contributions - August 2013.

 

 

Are you a Wiki Ninja? https://technet.com/wiki

    - User Ed