Container Flashcards

1
Q

the library of pair

A

include<utility></utility>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

pair declaration

A

pair<F, S> newPair (newPair is the pair’s name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

create a pair with the specified first and second values, and how to access them

A

make_pair() ; name’s pair.first, name’s pair.second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

declare a pair playAttempts with an integer as the first element and a double as the second element

A

pair<int, double> playAttempts;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

the library of list

A

include <list></list>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

list declaration

A

list<T> newList;</T>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

push_back()

A

adds an element to the end of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

push_front()

A

adds an element to the front of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

front

A

returns the front element of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

back()

A

return the back element (last element) of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

pop_back, pop_front

A

removes element from the end of the list, from the front of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

remove

A

remove all the occurrences in the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to declare the iterator in the list

A

list<T>:: iterator iter;</T>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

insert

A

insert(iteratorPosition, newElement) -> insert newElement into the list before the iteratorPosition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

erase

A

erase(iteratorPosition) - removes a single element at iteratorPosition
erase(iteratorFirst, iteratorLast) - removes a range of elements from iteratorFirst(inclusive) to iteratorLast(exclusive)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

emplace() function in Map

A

emplace function associates a key with specified value. If the key does not exist, the map is not updated.

17
Q

how to update map entry

A

EX:
statePopulation.at(“CA”) = 39000

18
Q

how to determine if the key exists in the map

A

count(key)

19
Q

erase(key)

A

removes the map entry for the specified key if the key exists

20
Q

clear()

A

removes all map entries

21
Q

how to define function template

A

template<typename>
T TripleMin(T para1, T para2, T para3)</typename>

22
Q

function template with multiple parameters

A

template<typename T1, typename T2>
ReturnType FunctionName(Parameters){
….
}

23
Q

class template declaration

A

template<typename>
class TripleItem {</typename>

}

template<typename> T1
TripleItem<TheType>::</TheType></typename>