MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
slice_algo.hpp File Reference
#include "optional.hpp"
#include "slice.hpp"
Include dependency graph for slice_algo.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mtcore::slices::SearchIndexes< T, N >
 
struct  mtcore::slices::SplitIter< T, Slice< T > >
 
struct  mtcore::slices::SplitIter< T, N >
 

Namespaces

namespace  mtcore
 Core library for C++ with Zig-related functionality.
 
namespace  mtcore::slices
 Additional algorithms that can be performed on slices, such as comparisons, searching, etc.
 

Functions

template<typename T>
bool mtcore::slices::starts_with (const Slice< T > &needle, const Slice< T > &haystack)
 Checks whether a slice (the haystack) starts with elements in another slice in the same order (the needle) - \(O(N)\) Uses the equality operator of the underlying type E.g.
 
template<typename T>
void mtcore::slices::shift (Slice< T > slice, size_t amt)
 
template<typename T>
bool mtcore::slices::starts_with (const std::remove_const_t< T > &needle, const Slice< T > &haystack)
 Checks whether a slice (the haystack) starts with a specific element (the needle) - \(O(N)\) Uses the equality operator of the underlying type E.g.
 
template<typename T>
bool mtcore::slices::contains (const std::remove_const_t< T > &needle, const Slice< T > &haystack)
 Checks whether a slice (the haystack) contains an element (the needle) Uses the equality operator of the underlying type E.g.
 
template<typename T>
bool mtcore::slices::contains (const Slice< T > &needle, const Slice< T > &haystack)
 Checks whether a slice (the haystack) contains elements in another slice in the same order (the needle) - \(O(N^2)\) Uses the equality operator of the underlying type E.g.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::first_index_not_proceeded_by (const std::remove_const_t< T > &prefix, const std::remove_const_t< 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 - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::first_index_not_proceeded_by (const std::remove_const_t< T > &prefix, 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 - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::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 - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::first_index_not (const std::remove_const_t< 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 - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::first_index (const std::remove_const_t< 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 - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::last_index (const Slice< T > &needle, const Slice< T > &haystack)
 Gets the last index that a needle appears in the haystack, or nullopt if the needle does not appear - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
mtcore::Optional< size_t > mtcore::slices::last_index (const std::remove_const_t< T > &needle, const Slice< T > &haystack)
 Gets the last index that a needle appears in the haystack, or nullopt if the needle does not appear - \(O(N^2)\) Uses the equality operator of the underlying type.
 
template<typename T>
SearchIndexes< T, Slice< T > > mtcore::slices::indexes_of (const Slice< T > &needle, const Slice< T > &haystack)
 Returns an iterator of all indexes of occurrences of a needle in a haystack If the needle isn't present, will return an empty iterator.
 
template<typename T>
SearchIndexes< T, std::remove_const_t< T > > mtcore::slices::indexes_of (const std::remove_const_t< T > &needle, const Slice< T > &haystack)
 Returns an iterator of all indexes of occurrences of a needle in a haystack If the needle isn't present, will return an empty iterator.
 
template<typename T>
SplitIter< T, Slice< T > > mtcore::slices::split (const Slice< T > &needle, const Slice< T > &haystack)
 Splits a slice into smaller sub slices.
 
template<typename T>
SplitIter< T, std::remove_const_t< T > > mtcore::slices::split (const std::remove_const_t< T > &needle, const Slice< T > &haystack)
 Splits a slice into smaller sub slices.