mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Completed tests for const_map, const_multimap, const_setand const_multiset
This commit is contained in:
parent
89647c14f2
commit
67dfd5c0dd
574
include/etl/const_multiset.h
Normal file
574
include/etl/const_multiset.h
Normal file
@ -0,0 +1,574 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_CONST_MULTISET_INCLUDED
|
||||
#define ETL_CONST_MULTISET_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if ETL_NOT_USING_CPP11
|
||||
#error NOT SUPPORTED FOR C++03 OR BELOW
|
||||
#endif
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "type_traits.h"
|
||||
#include "functional.h"
|
||||
#include "nth_type.h"
|
||||
#include "span.h"
|
||||
|
||||
#include "private/comparator_is_transparent.h"
|
||||
|
||||
///\defgroup const_multiset const_multiset
|
||||
///\ingroup containers
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <typename TKey, typename TKeyCompare = etl::less<TKey>>
|
||||
class iconst_multiset
|
||||
{
|
||||
public:
|
||||
|
||||
using key_type = TKey;
|
||||
using value_type = TKey;
|
||||
using key_compare = TKeyCompare;
|
||||
using value_compare = TKeyCompare;
|
||||
using const_reference = const value_type&;
|
||||
using const_pointer = const value_type*;
|
||||
using const_iterator = const value_type*;
|
||||
using size_type = size_t;
|
||||
|
||||
//*************************************************************************
|
||||
/// Check that the elements are valid for a multiset.
|
||||
/// The elements must be sorted.
|
||||
/// \return <b>true</b> if the elements are valid for the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::is_sorted(begin(), end(), vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the beginning of the multiset.
|
||||
///\return <code>const_iterator</code> to the beginning of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator begin() const ETL_NOEXCEPT
|
||||
{
|
||||
return element_list;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the beginning of the multiset.
|
||||
///\return <code>const_iterator</code> to the beginning of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator cbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return element_list;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the end of the multiset.
|
||||
///\return <code>const_iterator</code> to the end of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator end() const ETL_NOEXCEPT
|
||||
{
|
||||
return element_list_end;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the end of the multiset.
|
||||
///\return <code>const_iterator</code> to the end of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator cend() const ETL_NOEXCEPT
|
||||
{
|
||||
return element_list_end;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the beginning of the multiset.
|
||||
///\return <code>const_pointer</code> to the beginning of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_pointer data() const ETL_NOEXCEPT
|
||||
{
|
||||
return element_list;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets a const_iterator to the value at the key index.
|
||||
///\param key The key of the element to find.
|
||||
///\return A <code>const_iterator</code> to the value at the index,
|
||||
/// or end() if not found.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator find(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if ((itr != end()) && (keys_are_equal(*itr, key)))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets a const_iterator to the value at the key index.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element to find.
|
||||
///\return A <code>const_iterator</code> to the value at the index,
|
||||
/// or end() if not found.
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 const_iterator find(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if ((itr != end()) && (keys_are_equal(*itr, key)))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Checks if the multiset contains an element with key.
|
||||
///\param key The key of the element to check.
|
||||
///\return <b>true</b> if the multiset contains an element with key.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 bool contains(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return find(key) != end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Checks if the multiset contains an element with key.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element to check.
|
||||
///\return <b>true</b> if the multiset contains an element with key.
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 bool contains(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return find(key) != end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Counts the numbeer elements with key.
|
||||
///\param key The key of the element to count.
|
||||
///\return 0 or 1
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type count(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
auto range = equal_range(key);
|
||||
|
||||
return size_type(etl::distance(range.first, range.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Counts the numbeer elements with key.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element to count.
|
||||
///\return 0 or 1
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 size_type count(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
auto range = equal_range(key);
|
||||
|
||||
return size_type(etl::distance(range.first, range.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a range containing all elements with the key.
|
||||
/// The range is defined by a pair of two iterators, one to the
|
||||
/// first element that is not less than the key and second to the first
|
||||
/// element greater than the key.
|
||||
///\param key The key of the element
|
||||
///\return etl::pair or std::pair containing a pair of iterators.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::equal_range(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a range containing all elements with the key.
|
||||
/// The range is defined by a pair of two iterators, one to the
|
||||
/// first element that is not less than the key and second to the first
|
||||
/// element greater than the key.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element
|
||||
///\return etl::pair or std::pair containing a pair of iterators.
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator> equal_range(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::equal_range(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a const_iterator to the first element that is not less than the key.
|
||||
/// Returns a const_iterator to the first element that is not less than the key.
|
||||
///\param key The key of the element
|
||||
///\return const_iterator to the element or end()
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::lower_bound(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a const_iterator to the first element that is not less than the key.
|
||||
/// Returns a const_iterator to the first element that is not less than the key.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element
|
||||
///\return const_iterator to the element or end()
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::lower_bound(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a const_iterator to the first element that is greater than the key.
|
||||
/// Returns a const_iterator to the first element that is greater than the key.
|
||||
///\param key The key of the element
|
||||
///\return const_iterator to the element or end()
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::upper_bound(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Returns a const_iterator to the first element that is greater than the key.
|
||||
/// Returns a const_iterator to the first element that is greater than the key.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element
|
||||
///\return const_iterator to the element or end()
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return etl::upper_bound(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks if the multiset is empty.
|
||||
///\return <b>true</b> if the multiset is empty.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type empty() const ETL_NOEXCEPT
|
||||
{
|
||||
return size() == 0U;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks if the multiset is full.
|
||||
///\return <b>true</b> if the multiset is full.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT
|
||||
{
|
||||
return (max_elements != 0) && (size() == max_elements);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the size of the multiset.
|
||||
///\return The size of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type size() const ETL_NOEXCEPT
|
||||
{
|
||||
return size_type(element_list_end - element_list);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum size of the multiset.
|
||||
///\return The maximum size of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type max_size() const ETL_NOEXCEPT
|
||||
{
|
||||
return max_elements;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the capacity of the multiset.
|
||||
/// This is always equal to max_size().
|
||||
///\return The capacity of the multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type capacity() const ETL_NOEXCEPT
|
||||
{
|
||||
return max_elements;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
///\return An instance of the key_compare type.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 key_compare key_comp() const ETL_NOEXCEPT
|
||||
{
|
||||
return kcompare;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
///\return An instance of the value_compare type.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 value_compare value_comp() const ETL_NOEXCEPT
|
||||
{
|
||||
return vcompare;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
//*************************************************************************
|
||||
template <typename... TElements>
|
||||
ETL_CONSTEXPR14 explicit iconst_multiset(const value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT
|
||||
: element_list(element_list_)
|
||||
, element_list_end{element_list_ + size_}
|
||||
, max_elements(max_elements_)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//*********************************************************************
|
||||
/// Check to see if the keys are equal.
|
||||
//*********************************************************************
|
||||
ETL_CONSTEXPR14 bool keys_are_equal(const key_type& key1, const key_type& key2) const ETL_NOEXCEPT
|
||||
{
|
||||
return !key_compare()(key1, key2) && !key_compare()(key2, key1);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Check to see if the keys are equal.
|
||||
/// Enabled if the comparator is transparent.
|
||||
//*********************************************************************
|
||||
template <typename K1, typename K2, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 bool keys_are_equal(const K1& key1, const K2& key2) const ETL_NOEXCEPT
|
||||
{
|
||||
return !key_compare()(key1, key2) && !key_compare()(key2, key1);
|
||||
}
|
||||
|
||||
key_compare kcompare;
|
||||
value_compare vcompare;
|
||||
|
||||
const value_type* element_list;
|
||||
const value_type* element_list_end;
|
||||
size_type max_elements;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Multiset type designed for constexpr.
|
||||
//*************************************************************************
|
||||
template <typename TKey, size_t Size, typename TKeyCompare = etl::less<TKey>>
|
||||
class const_multiset : public iconst_multiset<TKey, TKeyCompare>
|
||||
{
|
||||
public:
|
||||
|
||||
using base_t = iconst_multiset<TKey, TKeyCompare>;
|
||||
|
||||
using key_type = typename base_t::key_type;
|
||||
using value_type = typename base_t::value_type;
|
||||
using key_compare = typename base_t::key_compare;
|
||||
using const_reference = typename base_t::const_reference;
|
||||
using const_pointer = typename base_t::const_pointer;
|
||||
using const_iterator = typename base_t::const_iterator;
|
||||
using size_type = typename base_t::size_type;
|
||||
|
||||
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Construct a const_set from a variadic list of elements.
|
||||
/// Static asserts if the element type is not constructible.
|
||||
/// Static asserts if the elements are not of type <code>value_type</code>.
|
||||
/// Static asserts if the number of elements is greater than the capacity of the const_set.
|
||||
//*************************************************************************
|
||||
template <typename... TElements>
|
||||
ETL_CONSTEXPR14 explicit const_multiset(TElements&&... elements) ETL_NOEXCEPT
|
||||
: iconst_multiset<TKey, TKeyCompare>(element_list, sizeof...(elements), Size)
|
||||
, element_list{etl::forward<TElements>(elements)...}
|
||||
{
|
||||
static_assert((etl::are_all_same<value_type, etl::decay_t<TElements>...>::value), "All elements must be value_type");
|
||||
static_assert(sizeof...(elements) <= Size, "Number of elements exceeds capacity");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
value_type element_list[Size];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... TElements>
|
||||
const_multiset(TElements...) -> const_multiset<etl::nth_type_t<0, TElements...>, sizeof...(TElements)>;
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Multiset type designed for constexpr.
|
||||
//*********************************************************************
|
||||
template <typename TKey, typename TKeyCompare = etl::less<TKey>>
|
||||
class const_multiset_ext : public iconst_multiset<TKey, TKeyCompare>
|
||||
{
|
||||
public:
|
||||
|
||||
using base_t = iconst_multiset<TKey, TKeyCompare>;
|
||||
|
||||
using key_type = typename base_t::key_type;
|
||||
using value_type = typename base_t::value_type;
|
||||
using key_compare = typename base_t::key_compare;
|
||||
using const_reference = typename base_t::const_reference;
|
||||
using const_pointer = typename base_t::const_pointer;
|
||||
using const_iterator = typename base_t::const_iterator;
|
||||
using size_type = typename base_t::size_type;
|
||||
|
||||
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Default construct a const_multiset.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_multiset_ext() ETL_NOEXCEPT
|
||||
: iconst_multiset<TKey, TKeyCompare>(nullptr, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Construct a const_multiset from a variadic list of elements.
|
||||
//*************************************************************************
|
||||
template <size_type Size>
|
||||
ETL_CONSTEXPR14 explicit const_multiset_ext(const etl::span<const value_type, Size>& sp) ETL_NOEXCEPT
|
||||
: iconst_multiset<TKey, TKeyCompare>(sp.data(), Size, Size)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Construct a const_multiset from an array.
|
||||
//*************************************************************************
|
||||
template <size_type Size>
|
||||
ETL_CONSTEXPR14 explicit const_multiset_ext(const value_type(&begin_)[Size]) ETL_NOEXCEPT
|
||||
: iconst_multiset<TKey, TKeyCompare>(begin_, Size, Size)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP17
|
||||
template <typename TElements, size_t N>
|
||||
const_multiset_ext(const etl::span<TElements, N>&) -> const_multiset_ext<typename TElements>;
|
||||
|
||||
template <typename TElements, size_t N>
|
||||
const_multiset_ext(const TElements(&)[N]) -> const_multiset_ext<typename TElements>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality test.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator ==(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality test.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator !=(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less than operator.
|
||||
///\param lhs Reference to the first list.
|
||||
///\param rhs Reference to the second list.
|
||||
///\return <b>true</b> if the first list is lexicographically less than the
|
||||
/// second, otherwise <b>false</b>.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator <(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::lexicographical_compare(lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end(),
|
||||
lhs.value_comp());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater than operator.
|
||||
///\param lhs Reference to the first list.
|
||||
///\param rhs Reference to the second list.
|
||||
///\return <b>true</b> if the first list is lexicographically greater than the
|
||||
/// second, otherwise <b>false</b>.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator >(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less than or equal operator.
|
||||
///\param lhs Reference to the first list.
|
||||
///\param rhs Reference to the second list.
|
||||
///\return <b>true</b> if the first list is lexicographically less than or equal
|
||||
/// to the second, otherwise <b>false</b>.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator <=(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater than or equal operator.
|
||||
///\param lhs Reference to the first list.
|
||||
///\param rhs Reference to the second list.
|
||||
///\return <b>true</b> if the first list is lexicographically greater than or
|
||||
/// equal to the second, otherwise <b>false</b>.
|
||||
//*************************************************************************
|
||||
template <typename TKey, typename TKeyCompare>
|
||||
ETL_CONSTEXPR14 bool operator >=(const etl::iconst_multiset<TKey, TKeyCompare>& lhs,
|
||||
const etl::iconst_multiset<TKey, TKeyCompare>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -398,7 +398,7 @@ namespace etl
|
||||
/// Defines the parameter types
|
||||
using const_key_reference = const key_type&;
|
||||
|
||||
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
|
||||
static_assert((etl::is_default_constructible<key_type>::value), "key_type must be default constructible");
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Construct a const_set from a variadic list of elements.
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -102,7 +102,7 @@ namespace
|
||||
using IDataTransparentComparator = etl::iconst_map<Key, int, etl::greater<>>;
|
||||
#else
|
||||
using Data = etl::const_map<Key, int, Max_Size, etl::less<Key>>;
|
||||
using Data2 = etl::const_map<Key, int, Max_Size + 1, etl::greater<Key>>;
|
||||
using Data2 = etl::const_map<Key, int, Max_Size + 1, etl::less<Key>>;
|
||||
using IData = etl::iconst_map<Key, int, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_map<Key, int, Max_Size, etl::less<>>;
|
||||
using DataTransparentComparator2 = etl::const_map<Key, int, Max_Size + 1, etl::less<>>;
|
||||
@ -114,7 +114,7 @@ namespace
|
||||
using mapped_type = Data::mapped_type;
|
||||
using const_iterator = Data::const_iterator;
|
||||
|
||||
SUITE(test_const_map)
|
||||
SUITE(test_const_map_constexpr)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -96,9 +96,9 @@ namespace
|
||||
using DataTransparentComparator = etl::const_map_ext<Key, int, etl::greater<>>;
|
||||
using IDataTransparentComparator = etl::iconst_map<Key, int, etl::greater<>>;
|
||||
#else
|
||||
using Data = etl::const_map<Key, int, etl::less<Key>>;
|
||||
using Data = etl::const_map_ext<Key, int, etl::less<Key>>;
|
||||
using IData = etl::iconst_map<Key, int, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_map<Key, int, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_map_ext<Key, int, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_map<Key, int, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -108,7 +108,7 @@ namespace
|
||||
using const_iterator = Data::const_iterator;
|
||||
using span_type = etl::span<const value_type, Max_Size>;
|
||||
|
||||
SUITE(test_const_map)
|
||||
SUITE(test_const_map_ext)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -96,9 +96,9 @@ namespace
|
||||
using DataTransparentComparator = etl::const_map_ext<Key, int, etl::greater<>>;
|
||||
using IDataTransparentComparator = etl::iconst_map<Key, int, etl::greater<>>;
|
||||
#else
|
||||
using Data = etl::const_map<Key, int, etl::less<Key>>;
|
||||
using Data = etl::const_map_ext<Key, int, etl::less<Key>>;
|
||||
using IData = etl::iconst_map<Key, int, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_map<Key, int, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_map_ext<Key, int, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_map<Key, int, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -108,7 +108,7 @@ namespace
|
||||
using const_iterator = Data::const_iterator;
|
||||
using span_type = etl::span<const value_type, Max_Size>;
|
||||
|
||||
SUITE(test_const_map)
|
||||
SUITE(test_const_map_ext_constexpr)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -113,7 +113,7 @@ namespace
|
||||
using mapped_type = Data::mapped_type;
|
||||
using const_iterator = Data::const_iterator;
|
||||
|
||||
SUITE(test_const_multimap)
|
||||
SUITE(test_const_multimap_constexpr)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -98,7 +98,7 @@ namespace
|
||||
#else
|
||||
using Data = etl::const_multimap_ext<Key, int, etl::less<Key>>;
|
||||
using IData = etl::iconst_multimap<Key, int, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_multimap_ext<Key, inte, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_multimap_ext<Key, int, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_multimap<Key, int, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -108,7 +108,7 @@ namespace
|
||||
using const_iterator = Data::const_iterator;
|
||||
using span_type = etl::span<const value_type, Max_Size>;
|
||||
|
||||
SUITE(test_const_multimap)
|
||||
SUITE(test_const_multimap_ext)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -98,7 +98,7 @@ namespace
|
||||
#else
|
||||
using Data = etl::const_multimap_ext<Key, int, etl::less<Key>>;
|
||||
using IData = etl::iconst_multimap<Key, int, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_multimap_ext<Key, inte, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_multimap_ext<Key, int, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_multimap<Key, int, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -108,7 +108,7 @@ namespace
|
||||
using const_iterator = Data::const_iterator;
|
||||
using span_type = etl::span<const value_type, Max_Size>;
|
||||
|
||||
SUITE(test_const_multimap)
|
||||
SUITE(test_const_multimap_ext_constexpr)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
|
||||
1326
test/test_const_multiset.cpp
Normal file
1326
test/test_const_multiset.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1326
test/test_const_multiset_constexpr.cpp
Normal file
1326
test/test_const_multiset_constexpr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1423
test/test_const_multiset_ext.cpp
Normal file
1423
test/test_const_multiset_ext.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1423
test/test_const_multiset_ext_constexpr.cpp
Normal file
1423
test/test_const_multiset_ext_constexpr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -102,7 +102,7 @@ namespace
|
||||
using Data2 = etl::const_set<Key, Max_Size + 1, etl::less<Key>>;
|
||||
using IData = etl::iconst_set<Key, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_set<Key, Max_Size, etl::less<>>;
|
||||
using DataTransparentComparator2 = etl::const_set<Key, Max_Size + 1, etl::greater<>>;
|
||||
using DataTransparentComparator2 = etl::const_set<Key, Max_Size + 1, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_set<Key, etl::less<>>;
|
||||
#endif
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -102,9 +102,9 @@ namespace
|
||||
using DataTransparentComparator = etl::const_set_ext<Key, etl::greater<>>;
|
||||
using IDataTransparentComparator = etl::iconst_set<Key, etl::greater<>>;
|
||||
#else
|
||||
using Data = etl::const_set<Key, etl::less<Key>>;
|
||||
using Data = etl::const_set_ext<Key, etl::less<Key>>;
|
||||
using IData = etl::iconst_set<Key, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_set<Key, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_set_ext<Key, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_set<Key, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -269,8 +269,8 @@ namespace
|
||||
static const span_type span(values);
|
||||
static const etl::const_set_ext data{span};
|
||||
|
||||
etl::const_set<Key, int, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
etl::const_set<Key, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
|
||||
CHECK_TRUE(data.is_valid());
|
||||
CHECK_TRUE(data.size() == Max_Size);
|
||||
@ -289,8 +289,8 @@ namespace
|
||||
|
||||
static const etl::const_set_ext data{values};
|
||||
|
||||
etl::const_set<Key, int, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
etl::const_set<Key, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
|
||||
CHECK_TRUE(data.is_valid());
|
||||
CHECK_TRUE(data.size() == Max_Size);
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2025 John Wellbelove, rlindeman
|
||||
Copyright(c) 2025 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the 'Software'), to deal
|
||||
@ -102,9 +102,9 @@ namespace
|
||||
using DataTransparentComparator = etl::const_set_ext<Key, etl::greater<>>;
|
||||
using IDataTransparentComparator = etl::iconst_set<Key, etl::greater<>>;
|
||||
#else
|
||||
using Data = etl::const_set<Key, etl::less<Key>>;
|
||||
using Data = etl::const_set_ext<Key, etl::less<Key>>;
|
||||
using IData = etl::iconst_set<Key, etl::less<Key>>;
|
||||
using DataTransparentComparator = etl::const_set<Key, etl::less<>>;
|
||||
using DataTransparentComparator = etl::const_set_ext<Key, etl::less<>>;
|
||||
using IDataTransparentComparator = etl::iconst_set<Key, etl::less<>>;
|
||||
#endif
|
||||
|
||||
@ -269,8 +269,8 @@ namespace
|
||||
static constexpr span_type span(values);
|
||||
static constexpr etl::const_set_ext data{span};
|
||||
|
||||
etl::const_set<Key, int, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
etl::const_set<Key, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
|
||||
CHECK_TRUE(data.is_valid());
|
||||
CHECK_TRUE(data.size() == Max_Size);
|
||||
@ -289,8 +289,8 @@ namespace
|
||||
|
||||
static constexpr etl::const_set_ext data{values};
|
||||
|
||||
etl::const_set<Key, int, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
etl::const_set<Key, 10U> check{ Key('A'), Key('B'), Key('C'), Key('D'), Key('E'),
|
||||
Key('F'), Key('G'), Key('H'), Key('I'), Key('J') };
|
||||
|
||||
CHECK_TRUE(data.is_valid());
|
||||
CHECK_TRUE(data.size() == Max_Size);
|
||||
|
||||
@ -3293,6 +3293,7 @@
|
||||
<ClInclude Include="..\..\include\etl\constant.h" />
|
||||
<ClInclude Include="..\..\include\etl\const_map.h" />
|
||||
<ClInclude Include="..\..\include\etl\const_multimap.h" />
|
||||
<ClInclude Include="..\..\include\etl\const_multiset.h" />
|
||||
<ClInclude Include="..\..\include\etl\const_set.h" />
|
||||
<ClInclude Include="..\..\include\etl\correlation.h" />
|
||||
<ClInclude Include="..\..\include\etl\covariance.h" />
|
||||
@ -9281,6 +9282,10 @@
|
||||
<ClCompile Include="..\test_const_multimap_constexpr.cpp" />
|
||||
<ClCompile Include="..\test_const_multimap_ext.cpp" />
|
||||
<ClCompile Include="..\test_const_multimap_ext_constexpr.cpp" />
|
||||
<ClCompile Include="..\test_const_multiset.cpp" />
|
||||
<ClCompile Include="..\test_const_multiset_constexpr.cpp" />
|
||||
<ClCompile Include="..\test_const_multiset_ext.cpp" />
|
||||
<ClCompile Include="..\test_const_multiset_ext_constexpr.cpp" />
|
||||
<ClCompile Include="..\test_const_set.cpp" />
|
||||
<ClCompile Include="..\test_const_set_constexpr.cpp" />
|
||||
<ClCompile Include="..\test_const_set_ext.cpp" />
|
||||
|
||||
@ -1521,6 +1521,9 @@
|
||||
<ClInclude Include="..\..\include\etl\const_set.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\const_multiset.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test_string_char.cpp">
|
||||
@ -3638,6 +3641,18 @@
|
||||
<ClCompile Include="..\test_const_set_ext_constexpr.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_const_multiset.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_const_multiset_constexpr.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_const_multiset_ext.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_const_multiset_ext_constexpr.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user