Purdue ECE 462 - Container Classes (91 pages)

Previewing pages 1, 2, 3, 4, 5, 6, 42, 43, 44, 45, 46, 47, 86, 87, 88, 89, 90, 91 of 91 page document View the full content.
View Full Document

Container Classes



Previewing pages 1, 2, 3, 4, 5, 6, 42, 43, 44, 45, 46, 47, 86, 87, 88, 89, 90, 91 of actual document.

View the full content.
View Full Document
View Full Document

Container Classes

40 views

Lecture Notes


Pages:
91
School:
Purdue University
Course:
Ece 462 - Object-Oriented Programming using C++ and Java
Object-Oriented Programming using C++ and Java Documents

Unformatted text preview:

ECE 462 Object Oriented Programming using C and Java Container Classes Yung Hsiang Lu yunglu purdue edu YHL Container Class 1 Why Container Classes Many programs require arrays vectors lists queues stacks sets to store information Both C and Java provide container classes that automatically manage memory allocate additional memory when more elements are added The supported container classes greatly reduce the amount of code needed by programmers and improve productivity Container classes and OOP are closely related a container can hold objects of derived classes polymorphism properly invokes the correct methods YHL Container Class 2 Container Class For Code Reuse A container needs to be able to hold items of different types i e classes Examples list of strings integers floating points student objects queues of customer objects car objects maps name address student ID name course title classroom C standard template library STL and Java container classes provide such functionality YHL Container Class 3 Select Container Class random or sequential accesses allow unique or duplicate items O 1 or O N for array like access using index efficient insert delete front end middle Java containers cannot store primitive types int char float and can store objects only C containers can store primitives YHL Container Class 4 Efficiency operation vector deque list array like access O 1 O 1 O N insert delete at front O N O 1 O 1 insert delete at end O 1 O 1 O 1 insert delete in middle O N O N O 1 N current number of items YHL Container Class 5 Java Containers YHL Container Class 6 Java List YHL Container Class 7 YHL Container Class 8 Interface and Class A Java interface serves as an abstract class and cannot be instantiated An interface can be implemented by classes Typically an interface is a common base for several related classes for example interface List as the base of ArrayList LinkedList Stack and Vector YHL Container Class 9 YHL Container Class 10 YHL Container Class 11 YHL



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Container Classes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Container Classes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?