C# Data Structures AND Generics By Michael and Miles.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 The Collections API.
Advertisements

Stacks, Queues, and Linked Lists
Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
Containers CMPS Reusable containers Simple data structures in almost all nontrivial programs Examples: vectors, linked lists, stacks, queues, binary.
LINQ and Collections An introduction to LINQ and Collections.
Data Structures and Collections
Queues A waiting line that grows by adding elements to its end and shrinks by taking elements from its front Line at the grocery store Cars in traffic.
Arrays and Lists.  Properties ◦ Contents are stored in contiguous memory locations ◦ Elements of the array are of the same type  (Perl allows for.
CMPT 225 ADT List using Dynamic arrays A dynamic data structure is one that changes size, as needed, as items are inserted or removed The Java ArrayList.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
1 Collections Working with More than One Number or Data Type or Object.
Chapter 8 Lists. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-2 Chapter Objectives Examine list processing and various ordering techniques.
Abstract Data Types (ADTs) An ADT consists of: –a set of values –a set of operations on those values Rational numbers –15/7, -3/4, 123/1, 0/1 (but NOT.
Chapter 101 Dynamic Data Structures and Generics Chapter 10.
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
16 - Generics. 2 NOEA2009Java-kursus – Generics ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can.
Copyright © Texas Education Agency, Advanced Computer Programming Data Structures: Collections.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
Chapter 21 Generics 1. Generics - Overview Generic Methods specify a set of related methods Generic classes specify a set of related types Software reuse.
Effective Java: Generics Last Updated: Spring 2009.
Generics in.NET and C# Generics. ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can apply polymorphism.
Lists Ellen Walker CPSC 201 Data Structures Hiram College.
Data Structures and Java CS 105. L7: Java Slide 2 Data structure Data structure defined: A systematic way of organizing and accessing data Examples Dictionary:
111 © 2002, Cisco Systems, Inc. All rights reserved.
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
Generics and Collections. Introduction Generics New feature of J2SE 5.0 Provide compile-time type safety Catch invalid types at compile time Generic methods.
DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Chapter 18 Java Collections Framework
Data structures Abstract data types Java classes for Data structures and ADTs.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Singly Linked Lists Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University 1.
Generics. What is Generics Collections can store Objects of any Type Generics restricts the Objects to be put in a collection Generics ease identification.
Understanding Data Types and Collections Lesson 2.
Objects First With Java A Practical Introduction Using BlueJ Supplementary Material for Java
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Interface: (e.g. IDictionary) Specification class Appl{ ---- IDictionary dic; dic= new XXX(); application class: Dictionary SortedDictionary ----
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
1 CSE 331 Generics (Parametric Polymorphism) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
Generics Generics vs. heterogeneous collections Doing your own generics FEN 2014UCN Teknologi/act2learn1.
Session 07 Module 13 - Collections. Collections / Session 7 / 2 of 32 Review  A delegate in C# is used to refer to a method in a safe manner.  To invoke.
1 9/22/05CS360 Windows Programming Arrays, Collections, Hash Tables, Strings.
Object Oriented Software Development 6. Arrays and collections.
Data Structures and Collections Principles.NET: –Two libraries: System.Collections System.Collections.Generics FEN 2014UCN Teknologi/act2learn1 Deprecated.
1.Net programmingGenericsNOEA / 2009 Generics 11. Generics in.NET and C#
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Collections Presented By : Muhammad Atif Hussain Deputy Manager IT (Takaful.
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
1 Chapter 4 Unordered List. 2 Learning Objectives ● Describe the properties of an unordered list. ● Study sequential search and analyze its worst- case.
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
CS202 Java Object Oriented Programming Introduction to Collection Classes Chengyu Sun California State University, Los Angeles.
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
Understanding Data Types and Collections Lesson 2.
CSCI-255 LinkedList.
MIS 215 Module 1 – Unordered Lists
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Data Structures and Database Applications Queues in C#
MIS Professor Sandvig MIS 324 Professor Sandvig
MIS Professor Sandvig MIS 324 Professor Sandvig
Presentation transcript:

C# Data Structures AND Generics By Michael and Miles

Overview What are data structures? Benefits and uses What are generics? Benefits and uses Live samples Summary

Data Structures 1. Collections of data 2. Fetch and store 3. type of data structure depends on situation 4. Examples Array, arraylist, list, linkedlist, stack, queue, dictionary, etc. 5. Most basic is the array

Arrays 1. Most commonly used data structure 2.Contents are stored in contiguous memory 3.All data must be same type Pros: Quick direct access (for loop) Easy to use Cons: Searching is proportional to data size Cannot resize array

What are generics? 1.One of the most powerful features introduced in C# System.Collections.Generic… 3.Mainly used with collections/data structures 4.Type safety 5.Generic methods 1.Similar operations on different data types

1.Pros Type safety Reduces the need for type casting – less run-time errors Performance boost – No boxing/unboxing (less code) maximize code reuse 2.Cons Can get complex Learning curve

List 1.Similar to arrays – 2.A generic data structure 3.Type-safe 4. Dynamic resizing -.Add().Insert().Remove() 5.Built in search methods 6.flexibility

Like a circular array First come first serve Insertions made at the tail Pros: Good for processing Cons: Not searchable Not many uses Queues

Dictionaries Key value pairs Data is unordered Easy lookups Type safe (generic)

Drawbacks of non-generic data structures Data stored as type object – Casting: conversion of data types double x = ; int a; a = (int)x; // cast double to int – Limited type checking * Increased Overhead – More work to getting something done

“CANNOT IMPLICITLY CONVERT TYPE OBJECT TO INT”

And then there’s LINQ Write queries (similar to SQL queries) Retrieve info from many data structures – Arrays, List<> etc. Quick example -us/library/bb aspx

Summary Types of Structures Generics – What they are/how to use Practical uses

Questions/ comments/ compliments?