|
| | Stack () |
| |
| nonvirtual void | Push (ArgByValueType< value_type > item) |
| |
| nonvirtual value_type | Pop () |
| |
| nonvirtual void | RemoveAll () |
| |
| nonvirtual bool | operator== (const Stack &rhs) const |
| |
| nonvirtual auto | operator<=> (const Stack &rhs) const |
| |
| nonvirtual void | clear () |
| | STL-ish alias for RemoveAll ().
|
| |
|
| Iterable (const Iterable &) noexcept=default |
| | Iterable are safely copyable (by value). Since Iterable uses COW, this just copies the underlying pointer and increments the reference count.
|
| |
|
| Iterable (Iterable &&) noexcept=default |
| | Iterable are safely moveable.
|
| |
template<IIterableOfTo< T > CONTAINER_OF_T>
requires (not derived_from<remove_cvref_t<CONTAINER_OF_T>, Iterable<T>> and (copyable<remove_cvref_t<CONTAINER_OF_T>> or same_as<remove_cvref_t<CONTAINER_OF_T>, initializer_list<T>>) ) |
| | Iterable (CONTAINER_OF_T &&from) |
| |
| | Iterable (const initializer_list< T > &from) |
| |
| nonvirtual | operator bool () const |
| |
| nonvirtual Iterator< T > | MakeIterator () const |
| | Create an iterator object which can be used to traverse the 'Iterable'.
|
| |
| nonvirtual size_t | size () const |
| | Returns the number of items contained.
|
| |
| nonvirtual bool | empty () const |
| | Returns true iff size() == 0.
|
| |
| template<Common::IPotentiallyComparer< T > EQUALS_COMPARER = equal_to<T>> |
| nonvirtual bool | Contains (ArgByValueType< T > element, EQUALS_COMPARER &&equalsComparer=EQUALS_COMPARER{}) const |
| |
| nonvirtual Iterator< T > | begin () const |
| | Support for ranged for, and STL syntax in general.
|
| |
| nonvirtual void | Apply (const function< void(ArgByValueType< T > item)> &doToElement) const |
| | Run the argument function (or lambda) on each element of the container.
|
| |
| template<predicate< T > THAT_FUNCTION> |
| nonvirtual Iterator< T > | Find (THAT_FUNCTION &&that) const |
| | Run the argument bool-returning function (or lambda) on the elements of the container, and return an iterator pointing at AN element for which it returned true - not necessarily the first (see the note below; use First () if you need the first).
|
| |
| template<IIterableOfFrom< T > CONTAINER_OF_T, typename... CONTAINER_OF_T_CONSTRUCTOR_ARGS> |
| nonvirtual CONTAINER_OF_T | As (CONTAINER_OF_T_CONSTRUCTOR_ARGS... args) const |
| |
| nonvirtual T | Nth (ptrdiff_t n) const |
| | Find the Nth element of the Iterable<>
|
| |
| nonvirtual T | NthValue (ptrdiff_t n, ArgByValueType< T > defaultValue={}) const |
| | Find the Nth element of the Iterable<>, but allow for n to be out of range, and just return argument default-value.
|
| |
| template<derived_from< Iterable< T > > RESULT_CONTAINER = Iterable<T>, predicate< T > INCLUDE_PREDICATE> |
| nonvirtual RESULT_CONTAINER | Where (INCLUDE_PREDICATE &&includeIfTrue) const |
| | produce a subset of this iterable where argument function returns true
|
| |
| template<Common::IPotentiallyComparer< T > EQUALS_COMPARER = equal_to<T>> |
| nonvirtual Iterable< T > | Distinct (EQUALS_COMPARER &&equalsComparer=EQUALS_COMPARER{}) const |
| |
template<ranges::range RESULT_CONTAINER = Iterable<T>, invocable< T > ELEMENT_MAPPER>
requires (convertible_to<invoke_result_t<ELEMENT_MAPPER, T>, typename RESULT_CONTAINER::value_type> or convertible_to<invoke_result_t<ELEMENT_MAPPER, T>, optional<typename RESULT_CONTAINER::value_type>>) |
| nonvirtual RESULT_CONTAINER | Map (ELEMENT_MAPPER &&elementMapper) const |
| | functional API which iterates over all members of an Iterable, applies a map function to each element, and collects the results in a new Iterable
|
| |
| template<typename REDUCED_TYPE = T> |
| nonvirtual optional< REDUCED_TYPE > | Reduce (const function< REDUCED_TYPE(ArgByValueType< T >, ArgByValueType< T >)> &op) const |
| | Walk the entire list of items, and use the argument 'op' to combine (reduce) items to a resulting single item.
|
| |
| template<typename REDUCED_TYPE = T> |
| nonvirtual REDUCED_TYPE | ReduceValue (const function< REDUCED_TYPE(ArgByValueType< T >, ArgByValueType< T >)> &op, ArgByValueType< REDUCED_TYPE > defaultValue={}) const |
| |
template<typename RESULT_T = Characters::String, invocable< T > CONVERT_TO_RESULT = decltype (kDefaultToStringConverter<>), invocable< RESULT_T, RESULT_T, bool > COMBINER = decltype (Characters::kDefaultStringCombiner)>
requires (convertible_to<invoke_result_t<CONVERT_TO_RESULT, T>, RESULT_T> and convertible_to<invoke_result_t<COMBINER, RESULT_T, RESULT_T, bool>, RESULT_T>) |
| nonvirtual RESULT_T | Join (const CONVERT_TO_RESULT &convertToResult=kDefaultToStringConverter<>, const COMBINER &combiner=Characters::kDefaultStringCombiner) const |
| | ape the JavaScript/python 'join' function - take the parts of 'this' iterable and combine them into a new object (typically a string)
|
| |
| nonvirtual Iterable< T > | Skip (size_t nItems) const |
| |
| nonvirtual Iterable< T > | Take (size_t nItems) const |
| |
| nonvirtual Iterable< T > | Slice (size_t from, size_t to) const |
| |
| nonvirtual optional< T > | Top () const |
| | return the top/largest value (or the top N values) from this Iterable<T>
|
| |
| template<Common::IPotentiallyComparer< T > INORDER_COMPARER_TYPE = less<T>> |
| nonvirtual Iterable< T > | OrderBy (INORDER_COMPARER_TYPE &&inorderComparer=INORDER_COMPARER_TYPE{}) const |
| |
| template<Common::IPotentiallyComparer< T > INORDER_COMPARER_TYPE = less<T>> |
| nonvirtual bool | IsOrderedBy (INORDER_COMPARER_TYPE &&inorderComparer=INORDER_COMPARER_TYPE{}) const |
| |
| nonvirtual optional< T > | First () const |
| | return first element in iterable, or if 'that' specified, first where 'that' is true, (or return nullopt if none)
|
| |
| nonvirtual T | FirstValue (ArgByValueType< T > defaultValue={}) const |
| | return first element in iterable provided default
|
| |
| nonvirtual optional< T > | Last () const |
| | return last element in iterable, or if 'that' specified, last where 'that' is true, (or return missing)
|
| |
| nonvirtual T | LastValue (ArgByValueType< T > defaultValue={}) const |
| |
| nonvirtual bool | All (const function< bool(ArgByValueType< T >)> &testEachElt) const |
| | return true iff argument predicate returns true for each element of the iterable
|
| |
| nonvirtual optional< T > | Min () const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual RESULT_TYPE | MinValue (ArgByValueType< RESULT_TYPE > defaultValue={}) const |
| |
| nonvirtual optional< T > | Max () const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual RESULT_TYPE | MaxValue (ArgByValueType< RESULT_TYPE > defaultValue={}) const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual optional< RESULT_TYPE > | Mean () const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual RESULT_TYPE | MeanValue (ArgByValueType< RESULT_TYPE > defaultValue={}) const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual optional< RESULT_TYPE > | Sum () const |
| |
| template<typename RESULT_TYPE = T> |
| nonvirtual RESULT_TYPE | SumValue (ArgByValueType< RESULT_TYPE > defaultValue={}) const |
| |
| template<constructible_from< T > RESULT_TYPE = T, Common::IPotentiallyComparer< RESULT_TYPE > INORDER_COMPARE_FUNCTION = less<RESULT_TYPE>> |
| nonvirtual optional< RESULT_TYPE > | Median (const INORDER_COMPARE_FUNCTION &compare={}) const |
| |
| template<constructible_from< T > RESULT_TYPE = T> |
| nonvirtual RESULT_TYPE | MedianValue (ArgByValueType< RESULT_TYPE > defaultValue={}) const |
| |
| nonvirtual Iterable< T > | Repeat (size_t count) const |
| |
| nonvirtual bool | Any () const |
| | Any() same as not empty (); Any (includeIfTrue) returns true iff includeIfTrue returns true on any values in iterable.
|
| |
| nonvirtual size_t | Count () const |
| | with no args, same as size, with function filter arg, returns number of items that pass.
|
| |
|
nonvirtual size_t | length () const |
| | STL-ish alias for size() - really in STL only used in string, I think, but still makes sense as an alias.
|
| |
template<
typename T>
class Stroika::Foundation::Containers::Stack< T >
Standard LIFO (Last in first out) Stack. See Sedgewick, 30-31.
- Note
- Iteration proceeds from the top (last in & first out) to the bottom of the stack (first in & last out). Top is the LAST IN (also first out).
Design Note: We considered NOT having Stack<T> inherit from Iterable<T>, but that made copying of a stack intrinsically more costly, as you had to copy, and then pop items to see them, and put them into a new stack. A special copy API (private to stack) would have limited the ease of interoperating the Stack<T> container with other sorts of containers.
Concrete Implementations: o
- See also
- Concrete::Stack_LinkedList<>
Factory:
- See also
- Stack_Factory<> to see default implementations.
- Note
- Thread-Safety C++-Standard-Thread-Safety
-
See ReadMe.md for common features of all Stroika containers (especially constructors, iterators, etc)
-
Comparisons: o static_assert (equality_comparable<T> ==> equality_comparable<Stack<T>>); o EqualsComparer provided as alias to SequentialEqualsComparer Two Queues are considered equal if they contain the same elements (by comparing them with EQUALS_COMPARER (which defaults to equal_to<T>) in exactly the same order (iteration). o Since ordering in a Queue is well defined, we can use this ordering between elements to define the obvious sequential ordering three way comparison on queues (Iterable::SequentialThreeWayComparer)
Definition at line 71 of file Stack.h.