Collection of utility functions operating on STL containers.
- See also
- ImFusionCoreContainer
|
|
template<typename ContainerT, typename T> |
| auto | find (ContainerT &&container, const T &value) -> decltype(container.begin()) |
| | Convenience function wrapping std::find() for the given container.
|
| |
|
template<typename ContainerT, typename UnaryPredicate> |
| auto | findIf (ContainerT &&container, UnaryPredicate &&predicate) -> decltype(container.begin()) |
| | Convenience function wrapping std::find_if() for the given container.
|
| |
| template<typename ContainerT, typename T> |
| auto | findPtr (ContainerT &&container, T &&pointer) -> decltype(container.begin()) |
| | Convenience function to search for a raw pointer in a container of smart pointers.
|
| |
| template<typename ContainerT, typename ElementType, typename T> |
| auto | findIfMember (ContainerT &&container, T ElementType::*member, const T &value) -> decltype(container.begin()) |
| | Return an iterator to the first element where member equals value.
|
| |
| template<typename ContainerT, typename T> |
| int64_t | indexOf (ContainerT &&container, const T &value) |
| | Find the index of the first element that is equal to value inside container.
|
| |
| template<typename ContainerT, typename UnaryPredicate> |
| int64_t | indexOfIf (ContainerT &&container, UnaryPredicate &&predicate) |
| | Find the index of the first element that matches predicate.
|
| |
| template<typename ContainerT, typename T> |
| int64_t | indexOfPtr (ContainerT &&container, T &&pointer) |
| | Convenience function to get the index of the first occurence of pointer in a container of smart pointers.
|
| |
|
template<typename ContainerT, typename T> |
| bool | contains (const ContainerT &container, const T &value) |
| | Return true if container contains value or false otherwise.
|
| |
|
template<typename ContainerT, typename UnaryPredicate> |
| bool | containsIf (const ContainerT &container, UnaryPredicate &&predicate) |
| | Return true if container contains any value that matches predicate.
|
| |
| template<typename ContainerT, typename T> |
| bool | containsPtr (const ContainerT &container, T &&pointer) |
| | Convenience function check whether a container of smart pointers contains a given raw pointer.
|
| |
| template<typename ContainerT, typename ElementType, typename T> |
| bool | containsIfMember (const ContainerT &container, T ElementType::*member, const T &value) |
| | Return true if the container contains an element where member equals value.
|
| |
| template<typename ContainerT, typename T> |
| int64_t | countValue (const ContainerT &c, const T &value) |
| | Return the number of elements in c that are equal to value.
|
| |
| template<typename ContainerT, class UnaryPredicate> |
| int64_t | countIf (const ContainerT &c, UnaryPredicate &&pred) |
| | Return the number of elements in c that match the given predicate.
|
| |
|
| template<typename ContainerT, typename T> |
| int64_t | erase (ContainerT &container, T &&value) |
| | Convenience function to remove and erase all elements matching value from container.
|
| |
| template<typename ContainerT, typename UnaryPredicate> |
| int64_t | eraseIf (ContainerT &container, UnaryPredicate &&predicate) |
| | Convenience function to remove and erase all elements from container that match the predicate.
|
| |
| template<typename ContainerT> |
| int64_t | eraseDuplicates (ContainerT &container) |
| | Removes all duplicates from the given container by calling std::sort(), std::unique() and std::erase().
|
| |
| template<typename ContainerT> |
| int64_t | eraseDuplicatesStable (ContainerT &container) |
| | Removes all duplicates from the given container keeping the original order intact.
|
| |
| template<typename ContainerT, typename UnaryPredicate> |
| ContainerT | extractIf (ContainerT &container, UnaryPredicate &&predicate) |
| | Move-extracts all elements from container that match the given predicate.
|
| |
|
| template<typename ContainerT, typename UnaryOp> |
| auto | transformed (ContainerT &&container, UnaryOp &&op) -> std::vector< std::decay_t< decltype(op(*std::begin(container)))> > |
| | A container-based wrapper for std::transform.
|
| |
| template<typename T, class UnaryOperation> |
| auto | transformed (std::initializer_list< T > elements, UnaryOperation &&op) -> std::vector< std::decay_t< decltype(op(*elements.begin()))> > |
| | An overload for the container-based wrapper for std::transform, taking an initializer list as the container.
|
| |
| template<typename T, typename U, class BinaryOperation> |
| auto | transformed (const std::vector< T > &containerA, const std::vector< U > &containerB, BinaryOperation &&op) -> std::vector< std::decay_t< decltype(op(containerA.front(), containerB.front()))> > |
| | A container-based wrapper for std::transform taking two constainers.
|
| |
| template<typename T, template< typename... > class SmartPtr> |
| std::vector< T * > | asRawPointers (const std::vector< SmartPtr< T > > &container) |
| | Converts a vector of smart pointers (such as std::unique_ptr or std::shared_ptr) to a vector of corresponding raw pointers.
|
| |
| template<typename T, typename ContainerT> |
| std::vector< T > | casted (const ContainerT &container) |
| | Converts the input container to a std::vector<T> by casting each element to T.
|
| |
| template<typename T, typename U, class BinaryOperation> |
| void | forEachZip (const std::vector< T > &containerA, const std::vector< U > &containerB, BinaryOperation &&op) |
| | A convenience function which applies a binary operator to two containers.
|
| |
| template<typename ContainerT, typename UnaryPred> |
| ContainerT | filtered (const ContainerT &container, UnaryPred &&pred) |
| | Filters certain elements out of a container.
|
| |
| template<typename ContainerT, typename UnaryPred, typename UnaryOperation> |
| auto | filteredTransform (const ContainerT &container, UnaryPred &&predicate, UnaryOperation &&op) -> std::vector< std::decay_t< decltype(op(*container.begin()))> > |
| | Combines filtered() and transformed() into a single pass operation.
|
| |
|
|
template<typename ContainerT, class UnaryPredicate> |
| bool | allOf (const ContainerT &container, UnaryPredicate &&predicate) |
| | Checks whether all elements in container match predicate.
|
| |
|
template<typename ContainerT, class UnaryPredicate> |
| bool | anyOf (const ContainerT &container, UnaryPredicate &&predicate) |
| | Checks whether any element in container match predicate.
|
| |
|
template<typename ContainerT, class UnaryPredicate> |
| bool | noneOf (const ContainerT &container, UnaryPredicate &&predicate) |
| | Checks whether no elements in container match predicate.
|
| |
| template<typename ContainerT, class BinaryPredicate> |
| bool | allEqual (const ContainerT &container, BinaryPredicate &&predicate) |
| | A container-based algorithms that checks whether all elements in a container are equal to each other.
|
| |
| template<typename ContainerT> |
| bool | allEqual (const ContainerT &container) |
| | A container-based algorithm that checks whether all elements in a container are equal to each other.
|
| |
| template<typename ContainerT> |
| void | renameKey (ContainerT &container, const typename ContainerT::key_type &oldKey, const typename ContainerT::key_type &newKey) |
| | Convenience function to change the key for a map entry.
|
| |
| template<typename ContainerT> |
| void | naturalSort (ContainerT &container) |
| | Utility function implementing a "natural sort" algorithm for strings.
|
| |