- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
char * pStart = ...;
char * pLast = ...;
std::string pattern("wn3901s");
std::string::const_iterator it = boost::algorithm::boyer_moore_search<>(
???,
???,
pattern.begin(),
pattern.end()
);
我试图在内存中搜索一个大的char*
字符串,pStart
指向它的第一个字符地址; pLast
指向最后一个。
但是,我不想将 char*
字符串转换为 std::string
,因为那样的话内存会被复制,这就是我想要的避免。
现在我遇到了为 boyer_moore_search
方法传递前 2 个参数的问题,该方法在那里接受 const_iterator
。
我应该从 const_iterator
添加一个新的继承类来模拟 char*
字符串吗?能举个例子吗?
谢谢
最佳答案
你可以使用 char *
作为迭代器
char *iterator_ = boost::algorithm::boyer_moore_search(pStart, pLast, pattern.begin(), pattern.end());
An iterator is any object that, pointing to some element in a range of elements (such as an array or a container), has the ability to iterate through the elements of that range using a set of operators (with at least the increment (++) and dereference (*) operators).
The most obvious form of iterator is a pointer.
关于c++ - 如何使用boyer_moore_search在内存中搜索char * string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20933618/
我想尝试使用 std::boyer_moore_searcher类(class)。但是我遇到了两个问题: 它在哪里?我正在使用 Visual Studio 2019,但它报告“namespace st
请帮助我获得面向对象的 boost::algorithm::boyer_moore_search 接口(interface)工作的基本示例。 程序界面对我有用,例如编译并打印“找到模式”: #incl
我是一名优秀的程序员,十分优秀!