sanne
Uploaded by
7 SLIDES
240 VIEWS
80LIKES

Understanding Associative Containers: Sets and Maps in C++

DESCRIPTION

This guide provides an overview of associative containers in C++, focusing on sets and maps. Sets store unique keys and allow for efficient existence checks, enabling mathematical operations such as union, intersection, and difference. We cover set operations like insertion, erasure, and size determination. Additionally, we explore maps, which pair keys with values, allowing access and manipulation of key-value entries. Learn about their operations, including insertion, deletion, and size checks. This foundational knowledge is essential for effective data management and algorithm development in C++.

1 / 7

Download Presentation

Understanding Associative Containers: Sets and Maps in C++

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Associative Containers CIS 237 – Data Structures

  2. Sets • Stores keys • Duplicates not allowed • Simply needs to know if in set • Used to implement the mathematical concept

  3. 10 A A 10 5 ! H 34 32 B P 9 i 90 B 77 ; 27 Y 56 Set Examples Set of characters Set of integers Set of counters

  4. Set Operations • s.count() • s.empty() • s.size() • s.find(value) • s.insert(value) • s.erase(value) • s.erase(itr) • s.begin • s.end

  5. Mathematical Set Operations • Union (+) • Intersection (*) • Difference (-)

  6. B 5 A 3 X 9 Maps • Stores key-value pair • map<t1, t2>::value_type entry(keyValue, value) • Entries identified by key • Two templates

  7. Map Operations • map<keyType, dataType> m • map< keyType, dataType>::iterator itr • m.insert(key_value_pair) • m[key] • m.erase(key) • m.erase(itr) • m.size • m.empty • m.begin • m.end

More Related
SlideServe
Audio
Live Player
Audio Wave
Play slide audio to activate visualizer