Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# Data Structures and Algorithms

You're reading from   C# Data Structures and Algorithms Explore the possibilities of C# for developing a variety of efficient applications

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788833738
Length 292 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Marcin Jamro Marcin Jamro
Author Profile Icon Marcin Jamro
Marcin Jamro
Arrow right icon
View More author details
Toc

Sorted dictionaries

Both non-generic and generic variants of the hash table-related classes do not keep the order of the elements. For this reason, if you need to present data from the collection sorted by keys, you need to sort them prior to presentation. However, you can use another data structure, the sorted dictionary, to solve this problem and keep keys sorted all the time. Therefore, you can easily get the sorted collection whenever necessary.

The sorted dictionary is implemented as the SortedDictionary generic class, available in the System.Collections.Generic namespace. You can specify types for keys and values while creating a new instance of the SortedDictionary class. Moreover, the class contains similar properties and methods to Dictionary.

First of all, you can use the indexer to get access to a particular element within the collection, as shown in the following line...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime