All Questions
595
questions
0
votes
3
answers
111
views
Can find_if be used to find a key in std::map/std::unordered_map?
This is a simple program consisting of adding an element into the std::unordered_map. But before it's added, first check if the key already exists, if it does then don't add it.
My problem is that ...
1
vote
1
answer
70
views
How to find an element in a vector of class objects, based on one of the class members, and delete it
I have a vector of classes. Each class has two member variables, a name (string) and time spent working (integer).
My goal is simply delete an element of an array that contains a specific name.
I know ...
-2
votes
1
answer
176
views
Iterator with find() in c++
I want to know how to get the position of the result when I use the find() command.
My code have the command:
vector<int>::iterator result = find(list_of_number.begin(), list_of_number.end(), ...
0
votes
1
answer
1k
views
C++20 contains and get value VS find
I understand that some containers in C++, such as map or unordered_map, have a mechanism that allows accessing values directly if you have the key.
I'm not sure if this is entirely correct...
The ...
-1
votes
1
answer
246
views
How can I find if a substring is present in a string or not without using find() function?
How can I find if a substring is present in a string or not without using find() function? Is there any efficient way to find the substring than using find() function?
`
#include <bits/stdc++.h>
...
0
votes
1
answer
476
views
error C2676 binary '==': 'block' does not define this operator or a conversion to a type acceptable to the predefined operator
#include <iostream>
#include <vector>
using namespace std;
class block {
public:
int x, y;
block(int in_x = 0, int in_y = 0) {
x = in_x;
y = in_y;
}
int ...
0
votes
0
answers
166
views
Search a pair in unordered_set of pairs from first element in C++
I want to erase the pair: (x,"whatever"), and i want:
1)find an iterator position of the pair with x as first element
2)after that erase the element in the position of the iterator
typedef ...
0
votes
1
answer
44
views
How to start fresh on a while / do-while loop?
using namespace std;
int main()
{
char repeat;
do
{
string str;
cout << "What is your first and last name? " << endl;
getline(cin, str);
...
0
votes
3
answers
794
views
Find all substring in a given string c++
I've got a problem with a program which finds all substring in a given string.
I've tried to make variable "found", which would contain a position of a previously found substring and then ...
0
votes
2
answers
489
views
Time complexity for std::find_if() using set in C++
What is time complexity for std::find_if() function using std::set in C++?
Consider we have the following example:
auto cmp = [&](const pair<int, set<int>>& a , const pair<int, ...
0
votes
1
answer
186
views
Is there a find algorithm for Google Protocol Buffers (Protobuf)?
Is there a find algorithm for Google Protobuf array objects?
eg, if I have a protobuf with a repeated field such as
message MyProto {
repeated int32 intArray = 1;
}
how can I find a particular ...
1
vote
2
answers
100
views
How can i properly use the .find() function from set in C++?
Here is the struct for 'point'
struct point
{
double x;
double y;
};
and here is the function that produces an error,
there is an issue with my use of .find() as show in the pic below.
When I ...
0
votes
0
answers
29
views
The use of std::map find is throwing compiler error C2675 and I can't figure out why [duplicate]
Why is my find failing to compile for the class below? Error reads:
Severity Code Description Project File Line Suppression State
Error C2675 unary '++': '_Iter' does not define this ...
0
votes
1
answer
478
views
C++, Find out if a string contains a substring?
I don't know how to use the find() function to check if a string contains a substring, then the program should print out all Words, and "Contains" if Sentence contains at least one of them. ...
0
votes
1
answer
311
views
Finding the last index of the first substring found in a string
I was looking through a lot of the solutions on here and there doesn't seem to be anything that does this with a built-in c++ method.
std::string str = "Hey I'm John, John's friend";
int ...