CS240: Advanced Programming Concepts

Slides:



Advertisements
Similar presentations
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Advertisements

Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Data Structures A data structure is a collection of data organized in some fashion that permits access to individual elements stored in the structure This.
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
1 L43 Collections (3). 2 OBJECTIVES  To use the collections framework interfaces to program with collections polymorphically.  To use iterators to “walk.
Java Collection Framework. Interface Collection add(o) Add a new element clear() Remove all elements contains(o) Membership checking. IsEmpty() Whether.
© The McGraw-Hill Companies, 2006 Chapter 17 The Java Collections Framework.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
Java Collections Framework A presentation by Eric Fabricant.
Sets and Maps Part of the Collections Framework. The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Collections in Java. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection with no duplicates SortedSet.
1 Java's Collection Framework By Rick Mercer with help from The Java Tutorial, The Collections Trail, by Joshua BlockThe Collections Trail.
(c) University of Washington14-1 CSC 143 Java Collections.
Big Java Chapter 16.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington2012 More Collections: Queues,
Chapter 18 Java Collections Framework
תוכנה 1 תרגול 8 – מבני נתונים גנריים. 2 Java Collections Framework Collection: a group of elements Interface Based Design: Java Collections Framework.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Data structures and algorithms in the collection framework 1.
3-February-2003cse Collections © 2003 University of Washington1 Java Collections CSE 403, Winter 2003 Software Engineering
Computer Science 209 The Factory Pattern. Collections and Iterators List list1 = new ArrayList (); List list2 = new LinkedList (); Set set1 = new HashSet.
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Copyright 2010 by Pearson Education Building Java Programs Chapter 10, 11 Lecture 22: 143 Preview optional reading: 10.1,
Recitation 5 Enums and The Java Collections classes/interfaces 1.
Priority Queues. Priority Queue ADT A priority queue stores a collection of entries Each entry is a pair (key, value) Main methods of the Priority Queue.
Maps Nick Mouriski.
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CMSC 202 Containers and Iterators. Container Definition A “container” is a data structure whose purpose is to hold objects. Most languages support several.
1 Maps, Stacks and Queues Maps Reading:  2 nd Ed: 20.4, 21.2, 21.7  3 rd Ed: 15.4, 16.2, 16.7 Additional references: Online Java Tutorial at
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 21 Sets and Maps.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
CS202 Java Object Oriented Programming Introduction to Collection Classes Chengyu Sun California State University, Los Angeles.
COMP 103 Maps and Queues. RECAP  Iterators (for-each loop)  Bag, Sets, and Stacks - a class, not interface TODAY  Maps and Queues 2 RECAP-TODAY QUICK.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Java Collections CHAPTER 3-February-2003
Slides by Donald W. Smith
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Slides by Donald W. Smith
Some Collections: BAGS, SETS, and STACKS
Use of Java’s HashMap.
Chapter 19 Java Data Structures
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
University of Central Florida COP 3330 Object Oriented Programming
JCF Hashmap & Hashset Winter 2005 CS-2851 Dr. Mark L. Hornick.
Road Map CS Concepts Data Structures Java Language Java Collections
Building Java Programs
Road Map CS Concepts Data Structures Java Language Java Collections
Road Map - Quarter CS Concepts Data Structures Java Language
Introduction to Collections
Introduction to Collections
Part of the Collections Framework
Môn: Lập trình Hướng đối tượng (Object Oriented Programming)
Welcome to CSE 143! Go to pollev.com/cse143.
Collections James Brucker.
CSE 373 Java Collection Framework, Part 2: Priority Queue, Map
CSE 1020: The Collection Framework
Containers and Iterators
Road Map CS Concepts Data Structures Java Language Java Collections
Podcast Ch21f Title: HashSet Class
CS 240 – Advanced Programming Concepts
Presentation transcript:

CS240: Advanced Programming Concepts Week 4 Thursday

Inheritance

Java Collections Framework

List ArrayList LinkedList ”Random Access”

Iterator Collection < String > coll = ...; Iterator < String > iter = coll.iterator(); while (iter.hasNext()) { String element = iter.next(); Process element } Horstmann, Cay S.. Core Java for the Impatient (p. 232). Pearson Education. Kindle Edition.

Enhanced For Loops (arrays/collections)… for (String element : coll) { Process element } What actually “happens”?… Horstmann, Cay S.. Core Java for the Impatient (p. 232). Pearson Education. Kindle Edition.

Set HashSet TreeSet (SortedSet/NavigableSet) Fast Ordered “Constant” time access TreeSet (SortedSet/NavigableSet) Ordered Comparable interface or… Supply a Comparator in the constuctor

Map Key value pairs What is a key? “What is a value”? One value per key Map < String, Integer > counts = new HashMap < >(); counts.put(" Alice", 1); // Adds the key/ value pair to the map counts.put(" Alice", 2); // Updates the value for the key (Horstmann, Cay S.. Core Java for the Impatient (p. 237). Pearson Education. Kindle Edition. ) What is a key? “What is a value”?

Views Set < K > keySet() Set < Map.Entry < K, V > > entrySet() Collection < K > values() “The collections that are returned are not copies of the map data, but they are connected to the map. If you remove a key or entry from the view, then the entry is also removed from the underlying map.” Horstmann, Cay S.. Core Java for the Impatient (p. 237). Pearson Education. Kindle Edition.

Stacks, Queues, Deques, Priority Queues Push/Pop Queue Add/remove Priority Queues “Comparable” https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html Weak Hash Maps Weak References

From Stroustrup’s Presentation… https://www.youtube.com/watch?v=YQs6IC-vgmo