Lec14 - Lecture 14: Generics PIC 10C Todd Wittman Exam 1...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 14: Generics PIC 10C Todd Wittman Exam 1 Monday s Meet in the PIC Lab Monday 11:00. (I will send you a reminder e-mail.) s Your exam will be 1/2 written, 1/2 programming. s The exam is open book, open notes. s The written part will focus on the C++ topics we covered in the first 2 weeks: STL containers & algorithms, Inheritance, Polymorphism. s The programming part will ask you to make a short program in C#. s Review questions are online.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Arrays s The built-in data container in C# is the Array. s It has more functionality than the C++ array, but it is still awkward for look-ups and making changes. s Ex Make a string array one bigger. string [] newArray = new string[array.Length+1]; for (int i=0; i<array.Length; i++) newArray[i] = array[i]; newArray[newArray.Length] = "Homer"; array = newArray; s This example is given on p. 295 of your book. Can you spot the error? Should be newArray.Length-1 Generics s C# is equipped with data structures similar to the STL containers. s C# calls them generics , because they can hold an abritrary data type. s The generics are defined in the library System.Collections.Generics , which is included for you automatically when you start a new project. s Their use is similar to C++, but the names are different so don't get them confused.
Background image of page 2
3 Generics (p.297) C# Generic Data Structure C++ STL container List dynamic array vector SortedList binary tree set Dictionary hash table map LinkedList linked list list Queue queue queue Stack stack stack s There is also a C# generic called SortedDictionary, which is a hybrid between a hash table and a binary
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2010 for the course PIC 10C taught by Professor Wittman during the Spring '10 term at UCLA.

Page1 / 8

Lec14 - Lecture 14: Generics PIC 10C Todd Wittman Exam 1...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online