slide1
Download
Skip this Video
Download Presentation
13 Collections Framework

Loading in 2 Seconds...

play fullscreen
1 / 18

13 Collections Framework - PowerPoint PPT Presentation


  • 97 Views
  • Uploaded on

13 Collections Framework. Contents. What is Collection? Collections Framework Collections Hierarchy Collections Implementations Set List Map. Objectives. Define a collection Describe the collections framework Describe the collections hierarchy

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' 13 Collections Framework' - lucien


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
contents
Contents
  • What is Collection?
  • Collections Framework
  • Collections Hierarchy
  • Collections Implementations
    • Set
    • List
    • Map
objectives
Objectives
  • Define a collection
  • Describe the collections framework
  • Describe the collections hierarchy
  • Demonstrate each collection implementation
what is a collection
What is a Collection?
  • A Collection (also known as container) is an object that contains a group of objects treated as a single unit.
  • Any type of objects can be stored, retrieved and manipulated as elements of collections.
collections framework
Collections Framework
  • Collections Framework is a unified architecture for managing collections

Main Parts of Collections Framework

    • Interfaces
      • Core interfaces defining common functionality exhibited by collections
    • Implementations
      • Concrete classes of the core interfaces providing data structures
    • Operations
      • Methods that perform various operations on collections
collections framework implementations
Collections FrameworkImplementations

Note: Hashtable uses a lower-case “t”

collections framework operations
Collections FrameworkOperations

Basic collection operations:

    • Check if collection is empty
    • Check if an object exists in collection.
    • Retrieve an object from collection
    • Add object to collection
    • Remove object from collection
    • Iterate collection and inspect each object
  • Each operation has a corresponding method implementation for each collection type
collections characteristics
Collections Characteristics
  • Ordered
    • Elements are stored and accessed in a specific order
  • Sorted
    • Elements are stored and accessed in a sorted order
  • Indexed
    • Elements can be accessed using an index
  • Unique
    • Collection does not allow duplicates
iterator
Iterator
  • An iterator is an object used to mark a position in a collection of data and to move from item to item within the collection

Syntax:

Iterator <variable> = <CollectionObject>.iterator();

collections hierarchy set and list

Collection

implements

extends

extends

Set

List

implements

implements

HashSet

SortedSet

implements

ArrayList

Vector

LinkedList

LinkedHashSet

TreeSet

Collections HierarchySet and List
collections hierarchy map

Map

extends

extends

implements

SortedMap

implements

TreeMap

Hashtable

HashMap

LinkedHashMap

Collections HierarchyMap
collection implementations
Collection Implementations

List : Lists of things (classes that implement List)

Set : Unique things (classes that implement Set)

Map : Things with a unique ID (classes that implement Map)

Next!

slide14

“Paul”

“Mark”

“Luke”

“John”

“Paul”

value

index

3

1

4

2

0

List

A List cares about the index.

ArrayList

Vector

LinkedList

slide15
Set

A Set cares about uniqueness, it doesn’t allow duplicates.

“John”

“Luke”

“Paul”

“Mark”

“Fred”

“Peter”

HashSet

LinkedHashSet

TreeSet

slide16
Map

A Map cares about unique identifiers.

“ul”

key

value

“Ma”

“Le”

“Jn”

“Pl”

“Paul”

“Mark”

“Luke”

“John”

“Paul”

Hashtable

LinkedHashMap

TreeMap

HashMap

collection classes summary

Class

Map

Set

List

Ordered

Sorted

HashMap

X

No

No

Hashtable

X

No

No

TreeMap

X

Sorted

By natural order or custom comparison rules

LinkedHashMap

X

By insertion order or last access order

No

HashSet

X

No

No

TreeSet

X

Sorted

By natural order or custom comparison rules

LinkedHashSet

X

By insertion order or last access order

No

ArrayList

X

By index

No

Vector

X

By index

No

LinkedList

X

By index

No

Collection Classes Summary
key points
Key Points
  • Collections Framework contains:
      • Interfaces
      • Implementations
      • Operations
  • A list cares about the index.
  • A set cares about uniqueness, it does not allow duplicates.
  • A map cares about unique identifiers.
ad