This question already has answers here:
What requirements must std::map key classes meet to be valid keys?
(4 answers)
Closed 8 years ago.
I have to keep count of the occurrences of various sub matrices that occur in a matrix. Can I use a map, keeping the Key as a 2D matrix and the Value as the count?
If I can, then what will the syntax be?
This has been addressed more generally in the following post:
What requirements must std::map key classes meet to be valid keys?
Related
This question already has answers here:
In which scenario do I use a particular STL container?
(10 answers)
Create a multidimensional array dynamically in C++
(1 answer)
Which is the fastest? A boost::multi_array or a std::vector?
(3 answers)
Closed 2 years ago.
I want to do some data-analysis, so I need at compile time unknown sized (large) arrays (of double or complex double). The number of dimensions is know at compile-time. What is the "right" way to do this in modern c++.
This question already has answers here:
Does clearing a vector affect its capacity?
(4 answers)
C++ delete vector, objects, free memory
(7 answers)
Closed 3 years ago.
Sometimes I detect in different c++ projects code like this:
std::vector<DataClass> _dataVec;
...
std::vector<DataClass>().swap(_dataVec);
Is this code more effective than obvious and simple clear call
_dataVec.clear();
or these code samples have some kind of difference?
For what purpose I should prefer first variant?
This question already has answers here:
How to choose between map and unordered_map?
(5 answers)
Closed 5 years ago.
According to: This Tutorial
I can't understand the difference between std::map and std::unorderedmap. When and Why we should use Map and Unorderedmap?
As I've read in tutorial you provided, search speed in std::unorderedmap is O(1). While in std::map it's O(log2(n)), where n is size of the map.
So if you have to call std::find often, you can consider this option. While choosing hash function isn't an easy task.
This question already has answers here:
What really is a deque in STL?
(8 answers)
Closed 6 years ago.
I am learning stl and learn how to use all stl containers and i need to knew
when i have to use deque in my program.
what is the different between deque and other stl containers
http://www.cplusplus.com/reference/deque/deque/
You can push elements to a deque on both ends.
Example:
You can use a deque as "history".
The oldest items are in front.
Now you have easy access on the newest element and the oldest. (It is good for a undo function)
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
C++ struct sorting
Is it possible to sort a vector in C++ according to a specified sorting method, like used in Java's Collections.sort that takes a Comparator?
Yes. See the answers to this question from this morning: C++ struct sorting
Yes, it is. Take a look here for an example.