Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760) 845-3320.

Slides:



Advertisements
Similar presentations
1 Visual C# "Whidbey": Language Enhancements Anders Hejlsberg Distinguished Engineer Microsoft Corporation Anders Hejlsberg Distinguished.
Advertisements

Review Generics and the ArrayList Class
COMP 121 Week 9: AbstractList and ArrayList. Objectives List common operations and properties of Lists as distinct from Collections Extend the AbstractCollection.
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Generics, Lists, Interfaces
Samlingsklasser Istället för vektorer ArrayList Hashtable Mer om sorteringar.
LINQ and Collections An introduction to LINQ and Collections.
Data Structures and Collections
1 Generic Collections Chapter Objectives You will be able to Use generic collection classes available in the.NET framework.
Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer Wintellect Power Collections, C 5 Collections.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Java Collections Framework COMP53 Oct 24, Collections Framework A unified architecture for representing and manipulating collections Allows collections.
 2006 Pearson Education, Inc. All rights reserved Collections.
Collections. 2 Objectives Explore collections in System.Collections namespace –memory management –containment testing –sorting –traversal.
Generic Classes and 'for each' Loops List zoo = new ArrayList (); // … add several Animals to the zoo for (Animal animal : zoo) // do something with animal.
 2006 Pearson Education, Inc. All rights reserved Collections Many slides modified by Prof. L. Lilien (even many without an explicit message indicating.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 22 Lists, Stacks, Queues, and Priority.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
Collection types Collection types.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Windows Programming Using C# Arrays, Collections.
Stacks, Queues Bryce Boe 2013/07/30 CS24, Summer 2013 C.
Arrays, Lists, Stacks, Queues Static and Dynamic Implementation Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
(c) University of Washington14-1 CSC 143 Java Collections.
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.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Evolution of.NET Collections (C#) Chen Dong
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Holding Your Objects Generics and type-safe containers One of the problems of using pre-Java SE5 containers was that the compiler allowed.
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.
Understanding Data Types and Collections Lesson 2.
Windows Database Applications CIS 341 Chapter 11.
2013-T2 Lecture 18 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
Arrays and Collections Tonga Institute of Higher Education.
Advanced C# Types Tom Roeder CS fa. From last time out parameters difference is that the callee is required to assign it before returning not the.
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.
Advanced C#, part I Niels Hallenberg IT University of Copenhagen BAAAP – Spring 2009.
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.
C# Collections & Generics C#.NET Software Development Version 1.0.
1 9/22/05CS360 Windows Programming Arrays, Collections, Hash Tables, Strings.
Data Structures and Collections Principles.NET: –Two libraries: System.Collections System.Collections.Generics FEN 2014UCN Teknologi/act2learn1 Deprecated.
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
Generics & Collection Classes Version 1.0. Topics Generic Methods and Classes Generic Collection Classes List Enumerators Queue Stack LinkedList.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
2015-T2 Lecture 19 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
1 New Features in C# 2.0 Generic Types Iterators Simplified Delegates Anonymous Methods Partial Types Various © University of Linz, Institute for System.
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
C# Collections & Generics
Module 5: Programming with C#. Overview Using Arrays Using Collections Using Interfaces Using Exception Handling Using Delegates and Events.
Murach's C# 2012, C15© 2013, Mike Murach & Associates, Inc.Slide 1.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 2 nd Lecture Pavel Ježek
Advanced .NET Programming I 2nd Lecture
Chapter 5: Programming with C#
Collections 24: Collections Programming C# © 2003 DevelopMentor, Inc.
Web Services אוספים - Collections ליווי מקצועי : ארז קלר
CS1S467 GUI Programming LECTURE 11 Collections
Lecture 10: Collections.
Arrays and Collections
Basic Collections.
Defining Interfaces using C#
Advanced .NET Programming I 3rd Lecture
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760)

In the beginning… There were arrays… And there were System.Collections – ArrayList : IList : ICollection : IEnumerable – Hashtable : IDictionary : ICollection … – Various others Queue, Stack, SortedList

IEnumerable and IEnumerator Pull style iteration (better than Java :) IEnumerable – IEnumerator GetEnumerator() IEnumerator – bool MoveNext(); – object Current { get; } What foreach uses – foreach (object item in arrayList)

ICollection Count CopyTo SyncRoot and IsSynchronized*

IList Adding and removal – Add, Insert, Remove, RemoveAt Clearing (via Clear) Random access – has an indexer Finding – Contains, IndexOf Properties – IsFixedSize, IsReadOnly

IDictionary Adding and removal – Add, Remove and Clear only Random access – has an indexer Finding – Contains only Properties – IsFixedSize, IsReadOnly Collections – Keys and Values

Side note: What about Arrays? int[] : Array : IList : ICollection : IEnumerable Fixed size collections – Add and Remove not supported

What is the problem? Dangerous - Type safety Ugly - Casting Performance of value types (boxing and unboxing)

System.Collections.Generic ObjectGenerics IEnumeratorIEnumerator (inherit non generics) ICollectionICollection (modifyable - more like IList) IListIList (adds random access) IDictionaryIDictionary (adds TryGetValue) ArrayListList (still an array) HashtableDictionary SortedList Queue, Stack LinkedList, and LinkedListNode

Extras FindAll Sort FxCop warnings BindingLists ObservableCollections DataTable yield

Thank You Scott Reed Brain Hz Software (760)