我怎样才能找到与向量中的单词匹配的所有元素。 [英] How Can I Find All Elements Matching With A Word In A Vector.

查看:62
本文介绍了我怎样才能找到与向量中的单词匹配的所有元素。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个二维向量,列号序列号和名称,

我想在名称列中找到与某个关键字匹配的所有元素并相应地过滤数据..





例子

1 XXX

2 bbb

3 xxx

4 aaa



现在在这个向量中如果我搜索xxx我应该得到与我的关键字匹配的元素位置。



有没有任何预定义的功能呢?,,



我可以使用每个元素比较找到它但我正在寻找高级解决方案。



任何人都可以建议我一个想法..

I have a 2-Dimensional vector with columns serial no and names,
I wanted to find all elements matching with a certain keyword in names column and filter data accordingly..


Example
1 XXX
2 bbb
3 xxx
4 aaa

now in this vector if i search for xxx i should get elements position matching with my keyword.

Is there any predefined functions do that??,,

I can find it using each element comparison but i am looking advanced solution.

Can any one suggest me an idea..

推荐答案

你可以使用 std :: find STL的算法。

http://www.cplusplus.com/reference/algorithm/find/ [ ^ ]

http://en.cppreference.com/w/ cpp / algorithm / find [ ^ ]

它会将迭代器返回到找到的元素。
You can use the std::find algorithm of STL.
http://www.cplusplus.com/reference/algorithm/find/[^]
http://en.cppreference.com/w/cpp/algorithm/find[^]
It will return the iterator to the element found.


这篇关于我怎样才能找到与向量中的单词匹配的所有元素。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆