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 stacks


Each language provides varying levels of support for the stack data structure. The following are some examples of initializing the collection, adding an object to the collection, and then removing the top object from the collection.

C#

C# provides a concrete implementation of the stack data structure through the Stack<T> generic class.

    Stack<MyObject> aStack = new Stack<MyObject>(); 
    aStack.Push(anObject); 
    aStack.Pop(); 

Java

Java provides a concrete implementation of the stack data structure through the Stack<T> generic class.

    Stack<MyObject> aStack = new Stack<MyObject>(); 
    aStack.push(anObject); 
    aStack.pop(); 

Objective-C

Objective-C does not provide a concrete implementation of the stack data structure, but one can be easily creating using the class cluster NSMutableArray. Be aware that this will create an array-based implementation of the stack, which is generally less efficient...