JUCE API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
juce::OrderedContainerHelpers Struct Reference

A helper struct providing functions for managing sorted containers. More...

Public Member Functions

 OrderedContainerHelpers ()=delete
 

Static Public Member Functions

template<typename A , typename B , typename Less = std::less<>>
static constexpr bool equivalent (const A &a, const B &b, Less less={})
 Returns true if neither value compares less than the other.
 
template<typename OrderedContainer , typename ValueType , typename Less = std::less<>>
static auto find (const OrderedContainer &container, const ValueType &valueToFind, Less less={})
 Searches for an element in a sorted container using binary search.
 
template<typename OrderedContainer , typename ValueType , typename Less = std::less<>>
static void insertOrAssign (OrderedContainer &container, const ValueType &valueToInsert, Less less={})
 If the container already contains a value equivalent to the valueToInsert, assigns the new value over the old one; otherwise, if no equivalent tag exists, inserts the new value preserving the sorted property of the container.
 
template<typename OrderedContainer , typename ValueType , typename Less = std::less<>>
static bool remove (OrderedContainer &container, const ValueType &valueToRemove, Less less={})
 Removes a specific element from a sorted array, preserving order.
 
template<typename OrderedContainer , typename ValueType , typename Less = std::less<>>
static bool contains (const OrderedContainer &container, const ValueType &valueToFind, Less less={})
 Searches for an element in a sorted container and returns true if a match is found.
 

Detailed Description

A helper struct providing functions for managing sorted containers.

These helper functions simplify common operations on containers that are kept in a sorted order.

Constructor & Destructor Documentation

◆ OrderedContainerHelpers()

juce::OrderedContainerHelpers::OrderedContainerHelpers ( )
delete

Member Function Documentation

◆ equivalent()

template<typename A , typename B , typename Less = std::less<>>
static constexpr bool juce::OrderedContainerHelpers::equivalent ( const A &  a,
const B &  b,
Less  less = {} 
)
inlinestaticconstexpr

Returns true if neither value compares less than the other.

This is the same definition of equivalence as used by the std containers "set" and "map".

◆ find()

static auto juce::OrderedContainerHelpers::find ( const OrderedContainer &  container,
const ValueType &  valueToFind,
Less  less = {} 
)
inlinestatic

Searches for an element in a sorted container using binary search.

This returns an iterator to the found element, or container.end() if not found.

◆ insertOrAssign()

static void juce::OrderedContainerHelpers::insertOrAssign ( OrderedContainer &  container,
const ValueType &  valueToInsert,
Less  less = {} 
)
inlinestatic

If the container already contains a value equivalent to the valueToInsert, assigns the new value over the old one; otherwise, if no equivalent tag exists, inserts the new value preserving the sorted property of the container.

◆ remove()

static bool juce::OrderedContainerHelpers::remove ( OrderedContainer &  container,
const ValueType &  valueToRemove,
Less  less = {} 
)
inlinestatic

Removes a specific element from a sorted array, preserving order.

Searches for an element in the container that compares equivalent to valueToRemove and erases it if present, preserving the sorted property of the container.

Returns true if the array was modified or false otherwise (i.e. the element was not removed).

◆ contains()

static bool juce::OrderedContainerHelpers::contains ( const OrderedContainer &  container,
const ValueType &  valueToFind,
Less  less = {} 
)
inlinestatic

Searches for an element in a sorted container and returns true if a match is found.


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