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

Initializing queues


Each language provides varying levels of support for the queue data structure. Here are some examples of initializing the collection, adding an object to the back of the collection, and then removing the head object from the head of the collection.

C#

C# provides a concrete implementation of the queue data structure through the Queue<T> generic class:

    Queue<MyObject> aQueue = new Queue<MyObject>(); 
    aQueue.Enqueue(anObject); 
    aQueue.Dequeue(); 
Java

Java provides the abstract Queue<E> interface, and several concrete implementations of the queue data structure use this interface. Queue is also extended to the Deque<E> interface that represents a double-ended queue. The ArrayDeque<E> class is one concrete implementation of the Deque<E> interface:

    ArrayDeque<MyObject> aQueue = new ArrayDeque<MyObject>(); 
    aQueue.addLast(anObject); 
    aQueue.getFirst(); 

Objective-C

Objective...