Tuesday, March 19, 2024 02:20

Archive for June, 2018

Handling exceptions with Try Catch

Thursday, June 28th, 2018

Usually, when an exception is thrown, the program crashes or begins to malfunction. Fortunately, there is a way to prevent this that allows us to run codes that may generate exceptions, and still safely continue the execution in case of an error.… Read more

Exceptions

Sunday, June 17th, 2018

In an ideal world, a computer program will execute anything the programmer intended, the way the programmer intended. But since we don’t live in an ideal world (sadly), there are moments when due to the programmer’s mistake or to external conditions, these programs will malfunction or function in a way not intended, causing an exception from what we would normally expect.… Read more

Other Data Structures

Saturday, June 16th, 2018

Surprisingly, you will notice that we have already used these data structures before, without knowing they were data structures: the class and the structure. Whenever we instantiate one of these, we are actually using it as a data structure (more or less).… Read more

Sorted Set

Saturday, June 16th, 2018

Sorted Set is the preferred data structure when we want to have sorted items and also to eliminate duplicate elements. Unfortunately, its performance is worse than that of a Hash Set or a Dictionary. The following program declares a new Sorted Set and adds elements to it:

Read more

Hash Set

Thursday, June 14th, 2018

There are two types of Sets in the System.Collections.Generic namespace: SortedSet and HashSet. Both of them offer the functionality of storing non-duplicate items. The main difference between them is the fact that the SortedSet obviously has its items sorted. Therefor, if you do not care about the order in which the items are stored, you are better off performance-wise to use a HashSet.… Read more

Sorted Dictionary

Friday, June 8th, 2018

Sorted Dictionary is just a normal Dictionary data structure, but with its keys sorted. Of course, it is obvious that having its elements sorted will make this data structure slightly slower than a normal Dictionary, but it does offer the advantage of making an in memory sorted lookup very easy.… Read more

Dictionary

Friday, June 1st, 2018

The data structure Dictionary suggests storing key-value pairs and provides a quick search by key. In common language, this means that instead of elements receiving a numerical index, as in the array case, they receive a specific type as a key (this is what the K stands for in the Dictionary<K, T> concept; T stands for the type of the values stored in the dictionary) for accessing elements.… Read more


Follow the white rabbit