Data structures and algorithm > ch.3 sets and maps > 3.2. maps
A map is a container for storing a collection of data records in which each record is associated with a unique key.
The key components must be comparable
Map()
# Creates a new empty map
length()
# returns the number of key/vlaue pairs in the map
contains(key)
# determines if the given key is in the map and returns True if the key is found and False otherwise
add(key, value)
# adds a new key/value pair to the map if the key is not already in themap or replaces the data associated with the key if the key is in the map
# returns True if this is a new key and False if the data associated with the existing key is replaced
remove(key)
# removes the key/value pair for the given key if iti s in the map and raises an exception otherwise
valueOf(key)
# returns the data record associated with the given key
# the key must exist in the map or an exception is raised
iterator()
# reates and returns an iterator that can be used to iterate over the keys in the map
'Python' 카테고리의 다른 글
3.3. Multi-dimensional arrays (0) | 2022.03.13 |
---|---|
3.1. Set (0) | 2022.03.13 |
Searching problem (linear, binary) (0) | 2022.03.10 |
[백준 단계별로 풀어보기] python3 문자열 (0) | 2022.01.04 |
[백준 단계별로 풀어보기] python3 함수 (0) | 2021.12.29 |