MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::slices::SearchIndexes< T, N > Struct Template Reference

#include <slice_algo.hpp>

Public Member Functions

Optional< size_t > next ()
 

Public Attributes

needle
 
Slice< T > haystack
 
size_t cur = 0
 

Detailed Description

template<typename T, typename N>
struct mtcore::slices::SearchIndexes< T, N >

Definition at line 355 of file slice_algo.hpp.

Member Function Documentation

◆ next()

template<typename T, typename N>
Optional< size_t > mtcore::slices::SearchIndexes< T, N >::next ( )
inline

Definition at line 360 of file slice_algo.hpp.

360 {
361 if (cur >= haystack.size()) {
362 return nullopt;
363 }
364
365 auto nxt = haystack.sub(cur);
366 const auto opt = slices::first_index(needle, nxt);
367 if (!opt.has_value()) {
368 return nullopt;
369 }
370
371 mtdefer { cur += opt.value() + 1; };
372 return cur + opt.value();
373 }
mtcore::Optional< size_t > first_index(const Slice< T > &needle, const Slice< T > &haystack)
Gets the first index that a needle appears in the haystack, or nullopt if the needle does not appear ...
Here is the call graph for this function:

Member Data Documentation

◆ cur

template<typename T, typename N>
size_t mtcore::slices::SearchIndexes< T, N >::cur = 0

Definition at line 358 of file slice_algo.hpp.

◆ haystack

template<typename T, typename N>
Slice<T> mtcore::slices::SearchIndexes< T, N >::haystack

Definition at line 357 of file slice_algo.hpp.

◆ needle

template<typename T, typename N>
N mtcore::slices::SearchIndexes< T, N >::needle

Definition at line 356 of file slice_algo.hpp.


The documentation for this struct was generated from the following file: