Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.

Slides:



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

Concrete collections in Java library
JAVA Programming (Session 7) When you are willing to make sacrifices for a great cause, you will never be alone. Instructor:
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
CSci 143 Sets & Maps Adapted from Marty Stepp, University of Washington
1 L43 Collections (3). 2 OBJECTIVES  To use the collections framework interfaces to program with collections polymorphically.  To use iterators to “walk.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
© 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.
CSSE221: Software Dev. Honors Day 14 Announcements Announcements Pass in Homework 5 now Pass in Homework 5 now Questions on Cars, Trucks, Trains? Questions.
CSE 143 Lecture 7 Sets and Maps reading: ; 13.2 slides created by Marty Stepp
Java's Collection Framework
Collections. Why collections? Collections are used to hold a collection of objects. List holds objects based on order of insertion and can hold non unique.
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
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.
1 Java's Collection Framework By Rick Mercer with help from The Java Tutorial, The Collections Trail, by Joshua BlockThe Collections Trail.
1 Sets and Maps Starring: keySet Co-Starring: Collections.
Big Java Chapter 16.
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,
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Object Oriented Programming Ders 10: Data Structures Mustafa Emre İlal
Building Java Programs Chapter 11 Lecture 11-1: Sets and Maps reading:
תוכנה 1 תרגול 8 – מבני נתונים גנריים. 2 Java Collections Framework Collection: a group of elements Interface Based Design: Java Collections Framework.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Data structures and algorithms in the collection framework 1.
Arrays, ArrayLists, and Collections. Rationale Suppose we have a program to compute the average of three numbers. We could write a simple little method.
Correction of quizzes. ADTs and implementations Hash tables Graphs.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
Contest Algorithms January Collections 1Contest Algorithms: 3. Collections.
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.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Data-structure-palooza Checkout DataStructures from SVN.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CS Fall 2012, Lab 04 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Changes of Office Hours  Monday.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
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
CSE 143 Lecture 11: Sets and Maps reading:
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
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.
©Karsten Lundqvist Example: Array and Arrays 1 import java.util.*; public class Example { private int intValues[] = { 1, 2, 3, 4, 5, 6 }; private double.
Using the Java Collection Libraries COMP 103 # T2
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.
Some Collections: BAGS, SETS, and STACKS
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
University of Central Florida COP 3330 Object Oriented Programming
CSE 373: Data Structures and Algorithms
CS240: Advanced Programming Concepts
Week 2: 10/1-10/5 Monday Tuesday Wednesday Thursday Friday
Road Map CS Concepts Data Structures Java Language Java Collections
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
structures and their relationships." - Linus Torvalds
Môn: Lập trình Hướng đối tượng (Object Oriented Programming)
Welcome to CSE 143! Go to pollev.com/cse143.
Exercise Write a program that counts the number of unique words in a large text file (say, Moby Dick or the King James Bible). Store the words in a collection.
Collections Framework
Road Map CS Concepts Data Structures Java Language Java Collections
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
CSE 373 Java Collection Framework reading: Weiss Ch. 3, 4.8
CS 240 – Advanced Programming Concepts
structures and their relationships." - Linus Torvalds
Presentation transcript:

Java Collections

Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms

List List interface A sequence of elements accessed by index get(index), set(index, value) ArrayList (resizable array implementation) LinkedList (doubly-linked list implementation)

Set Set interface A collection that contains no duplicates add(value), contains(value), remove(value) HashSet (hash table implementation) TreeSet (bst implementation) LinkedHashSet (hash table + linked list impl)

Queue Queue interface A collection designed for holding elements prior to processing add(value), peek(), remove() ArrayDeque (fifo, resizable array impl) LinkedList (fifo, linked list implementation) PriorityQueue (priority queue, binary heap impl)

Deque Deque interface A queue that supports efficient insertion and removal at both ends addFirst(value), addLast(value), peekFirst(), peekLast(), removeFirst(), removeLast() ArrayDeque (resizable array implementation) LinkedList (linked list implementation)

Stack Java’s Stack class is deprecated If you need a stack, use a Deque push() => Deque.addFirst() pop() => Deque.removeFirst() peek() => Deque.peekFirst()

Map Map interface A collection that maps keys to values – A set of (key, value) pairs where keys are unique put(key, value), get(key), contains(key), remove(key) keySet(), values(), entrySet() HashMap (hash table implementation) TreeMap (bst implementation) LinkedHashMap (hash table + linked list impl)