Book Image

Everyday data structures

By : William Smith
Book Image

Everyday data structures

By: William Smith

Overview of this book

Explore a new world of data structures and their applications easily with this data structures book. Written by software expert William Smith, you?ll learn how to master basic and advanced data structure concepts. ? Fully understand data structures using Java, C and other common languages ? Work through practical examples and learn real-world applications ? Get to grips with data structure problem solving using case studies
Table of Contents (20 chapters)
Everyday Data Structures
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Free Chapter
1
Data Types: Foundational Structures

Instantiating lists


Like other data structures, lists must be defined and instantiated prior to being used. Each of the four languages that we will examine in this text has varying support for, and unique implementations of, the list data structure. Let's briefly examine how to instantiate a list in each language.

C#

Instantiating lists in C# requires the use of the new keyword:

    //Array backed lists 
    ArrayList myArrayList = new ArrayList(); 
    List<string> myOtherArrayList = new List<string>(); 
 
    //Linked lists 
    LinkedList<string> myLinkedList = new LinkedList<string>(); 

The C# ArrayList class originated in .NET 1.0, and it is not used very often anymore. Most developers prefer to use the generic concrete implementation, List<of T>, for an array-based list. This is also true for the generic concrete linked list implementation, LinkedList<of T>. There is no non-generic linked list data structure in C#.

Java

Like...