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

Splits a slice and iterates over the split portions. More...

#include <slice_algo.hpp>

Inheritance diagram for mtcore::slices::SplitIter< T, N >:

Public Member Functions

Optional< Slice< T > > next ()
 

Public Attributes

needle
 
Slice< T > haystack
 
bool emittedLast = true
 

Detailed Description

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

Splits a slice and iterates over the split portions.

Template Parameters
TSlice element type
NNeedle type

Definition at line 490 of file slice_algo.hpp.

Member Function Documentation

◆ next()

template<typename T, typename N>
Optional< Slice< T > > mtcore::slices::SplitIter< T, N >::next ( )
inline

Definition at line 495 of file slice_algo.hpp.

495 {
496 if (haystack.empty()) {
497 if (emittedLast) {
498 return nullopt;
499 }
500 emittedLast = true;
501 return haystack;
502 }
503
505 if (!nxt.has_value()) {
506 emittedLast = true;
507 auto res = haystack;
508 haystack = haystack.sub(haystack.size());
509 return res;
510 }
511
512 emittedLast = false;
513 auto res = haystack.sub(0, nxt.value());
514 haystack = haystack.sub(nxt.value() + 1);
515 return res;
516 }
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 ...
Splits a slice and iterates over the split portions.
Here is the call graph for this function:

Member Data Documentation

◆ emittedLast

template<typename T, typename N>
bool mtcore::slices::SplitIter< T, N >::emittedLast = true

Definition at line 493 of file slice_algo.hpp.

◆ haystack

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

Definition at line 492 of file slice_algo.hpp.

◆ needle

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

Definition at line 491 of file slice_algo.hpp.


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