Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
MixinVector< T > Class Template Reference

Simple test container using std::vector internally but with Aleph mixins. More...

Inheritance diagram for MixinVector< T >:
[legend]
Collaboration diagram for MixinVector< T >:
[legend]

Classes

class  Iterator
 

Public Types

using Item_Type = T
 

Public Member Functions

 MixinVector ()=default
 
 MixinVector (std::initializer_list< T > init)
 
void append (const T &item)
 
void insert (const T &item)
 
size_t size () const noexcept
 
bool is_empty () const noexcept
 
Iterator get_it () const
 
bool operator== (const MixinVector &other) const
 
- Public Member Functions inherited from Aleph::TraverseMixin< MixinVector< T >, T >
bool traverse (Operation &operation) const
 Traverse all elements, applying an operation to each.
 
bool traverse (Operation &operation)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool traverse (Operation and operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool traverse (Operation and operation=Operation())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
- Public Member Functions inherited from Aleph::LocateMixin< MixinVector< T >, T >
T & nth (const size_t n) const
 Access the n-th element (bounds-checked).
 
T & nth_ne (const size_t n) const noexcept
 Access the n-th element (unchecked).
 
T * find_ptr (Operation &operation)
 Find the first element satisfying a predicate.
 
T * find_ptr (Operation &operation) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
T * find_ptr (Operation and operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
T * find_ptr (Operation and operation=Operation())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::tuple< bool, T > find_item (Operation &operation)
 Find element with success flag.
 
std::tuple< bool, T > find_item (Operation &operation) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::tuple< bool, T > find_item (Operation &&operation=Operation())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::tuple< bool, T > find_item (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
- Public Member Functions inherited from Aleph::FunctionalMixin< MixinVector< T >, T >
auto for_each (Operation &operation) const -> decltype(self())
 Apply an operation to each element (read-only).
 
auto for_each (Operation &operation) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto for_each (Operation &&operation=Operation()) const -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto for_each (Operation &&operation=Operation()) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto mutable_for_each (Operation &operation) -> decltype(self())
 Apply an operation to each element (mutable).
 
auto mutable_for_each (Operation &&operation=Operation()) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool all (Operation &operation) const
 Test if all elements satisfy a predicate.
 
bool all (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool forall (Operation &operation) const
 Alias for all().
 
bool forall (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool exists (Operation &operation) const
 Test if any element satisfies a predicate.
 
bool exists (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Container< __Type > maps (Operation &operation) const
 Transform elements using a mapping function.
 
Container< __Type > maps (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
__Type foldl (const __Type &init, std::function< __Type(const __Type &, const T &)> operation) const
 Left fold (reduce) with initial value.
 
__Type fold_left (std::function< __Type(const __Type &, const T &)> operation, const __Type &init) const
 Left fold with operation first (alternative signature).
 
T fold (const T &init, Operation &operation) const
 Simple fold with same type for accumulator and elements.
 
T fold (const T &init, Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
DynList< T > filter (Operation &operation) const
 Filter elements by a predicate.
 
DynList< T > filter (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter with position information.
 
DynList< std::tuple< T, size_t > > pfilter (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::pair< DynList< T >, DynList< T > > partition (Operation &op) const
 Partition elements by a predicate.
 
std::pair< DynList< T >, DynList< T > > partition (Operation &&op=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::tuple< DynList< T >, DynList< T > > tpartition (Operation &op) const
 Partition returning tuple instead of pair.
 
std::tuple< DynList< T >, DynList< T > > tpartition (Operation &&op=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
size_t length () const noexcept
 Count the number of elements.
 
Container< T > rev () const
 Create a reversed copy.
 
Container< T > take (const size_t n) const
 Take the first n elements.
 
Container< T > drop (const size_t n) const
 Skip the first n elements.
 
T sum (const T &init=T {}) const
 Compute the sum of all elements.
 
T product (const T &init) const
 Compute the product of all elements.
 
const T * min () const
 Find the minimum element.
 
const T * max () const
 Find the maximum element.
 
const T * min_by (Compare cmp) const
 Find the minimum element using a custom comparator.
 
const T * max_by (Compare cmp) const
 Find the maximum element using a custom comparator.
 
bool has_value (const T &val) const
 Check if container has a value.
 
bool none (Predicate &pred) const
 Check if no element satisfies a predicate.
 
bool none (Predicate &&pred) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
size_t count_if (Predicate pred) const
 Count elements satisfying a predicate.
 
const T * first () const
 Get the first element.
 
T first_or (const T &default_val) const
 Get the first element or a default value.
 
const T * last () const
 Get the last element.
 
T last_or (const T &default_val) const
 Get the last element or a default value.
 
Container< std::pair< size_t, T > > enumerate () const
 Enumerate elements with their indices.
 
size_t find_index (Predicate pred) const
 Find the index of the first element satisfying a predicate.
 
size_t index_of (const T &val) const
 Find the index of a specific value.
 
Container< T > unique () const
 Remove consecutive duplicate elements.
 
Container< T > unique_by (EqPred eq) const
 Remove consecutive duplicates using a custom equality predicate.
 
Container< T > intersperse (const T &sep) const
 Intersperse a separator between elements.
 
Container< Container< T > > chunk (size_t n) const
 Split into chunks of fixed size.
 
Container< Container< T > > sliding (size_t size, size_t step=1) const
 Create sliding windows of fixed size.
 
std::vector< T > to_vector () const
 Convert to std::vector.
 
DynListType to_dynlist () const
 Convert container to DynList.
 
StringType join (const StringType &sep=StringType{", "}) const
 Join elements into a string with separator.
 
std::string join_str (const std::string &sep=", ") const
 Join string elements with separator.
 
Container< std::pair< T, typename Other::Item_Type > > zip_with (const Other &other) const
 Zip with another container.
 
- Public Member Functions inherited from Aleph::KeysMixin< MixinVector< T >, T >
Container< T > keys () const
 Extract all keys as a list.
 
Container< T > items () const
 Alias for keys().
 

Private Attributes

std::vector< T > data
 

Additional Inherited Members

- Protected Member Functions inherited from Aleph::TraverseMixin< MixinVector< T >, T >
const MixinVector< T > & self () const noexcept
 Access the derived class (const version).
 
MixinVector< T > & self () noexcept
 Access the derived class (mutable version).
 
- Protected Member Functions inherited from Aleph::LocateMixin< MixinVector< T >, T >
const MixinVector< T > & self () const noexcept
 
MixinVector< T > & self () noexcept
 
- Protected Member Functions inherited from Aleph::FunctionalMixin< MixinVector< T >, T >
const MixinVector< T > & self () const noexcept
 
MixinVector< T > & self () noexcept
 
- Protected Member Functions inherited from Aleph::KeysMixin< MixinVector< T >, T >
const MixinVector< T > & self () const noexcept
 

Detailed Description

template<typename T>
class MixinVector< T >

Simple test container using std::vector internally but with Aleph mixins.

Definition at line 56 of file ah-dry-mixin_test.cc.

Member Typedef Documentation

◆ Item_Type

Definition at line 64 of file ah-dry-mixin_test.cc.

Constructor & Destructor Documentation

◆ MixinVector() [1/2]

template<typename T >
MixinVector< T >::MixinVector ( )
default

◆ MixinVector() [2/2]

template<typename T >
MixinVector< T >::MixinVector ( std::initializer_list< T >  init)
inline

Definition at line 67 of file ah-dry-mixin_test.cc.

Member Function Documentation

◆ append()

template<typename T >
void MixinVector< T >::append ( const T &  item)
inline

Definition at line 69 of file ah-dry-mixin_test.cc.

References MixinVector< T >::data.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ get_it()

template<typename T >
Iterator MixinVector< T >::get_it ( ) const
inline

Definition at line 90 of file ah-dry-mixin_test.cc.

◆ insert()

template<typename T >
void MixinVector< T >::insert ( const T &  item)
inline

Definition at line 70 of file ah-dry-mixin_test.cc.

References MixinVector< T >::data.

◆ is_empty()

template<typename T >
bool MixinVector< T >::is_empty ( ) const
inlinenoexcept

Definition at line 72 of file ah-dry-mixin_test.cc.

References MixinVector< T >::data.

◆ operator==()

template<typename T >
bool MixinVector< T >::operator== ( const MixinVector< T > &  other) const
inline

◆ size()

template<typename T >
size_t MixinVector< T >::size ( ) const
inlinenoexcept

Definition at line 71 of file ah-dry-mixin_test.cc.

References MixinVector< T >::data.

Member Data Documentation

◆ data


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