Data Structures Flashcards
What is the purpose of Data Structures?
To store information, allocate data, and provide helpful methods / instance variables for users
What are Data Structures essentially?
Managed Pointers
What functionality does a Vector provide?
Dynamically growing storage
How do you declare a vector?
vector<generic> var = …;
What does vector.size() return?
The number of elements currently in the vector
What does action vector.push_back(value) perform?
It pushes the value to the back of the vector
What action does vector.pop_back() perform?
Erases and returns a copy of the last element in the vector
What action does vector.erase(vector.begin+index) perform?
Removes elements individually or in a range.
What provides the rules for standard implementation of data structures in C++?
Containers
What rules do containers require?
- Default Ctor
- copy Ctor
- methods for empty, size, and capacity
- iterators
What is an Iterator?
A class defined inside a data structure to traverse the data.
What is the one rule for an iterator?
It can move forward
What are the 3 main types of iterators?
- ForwardIterator
- BiDirectionalIterator
- RandomAccessIterator
What are the minimum operators in an iterator?
- * (dereference)
- ->
- ==
- !=
- ++
- =
What method is used to increment an iterator 1 position? (++)
next(Iterator)