mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Removed non-const iterator and pointer types
Updated Doxygen comments
This commit is contained in:
parent
697cd0a5aa
commit
4d10d47f5e
@ -53,12 +53,8 @@ namespace etl
|
||||
using value_type = ETL_OR_STD::pair<const TKey, TMapped>;
|
||||
using mapped_type = TMapped ;
|
||||
using key_compare = TKeyCompare;
|
||||
using reference = const value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using rvalue_reference = value_type&&;
|
||||
using pointer = const value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using iterator = const value_type*;
|
||||
using const_iterator = const value_type*;
|
||||
using size_type = size_t;
|
||||
|
||||
@ -73,28 +69,34 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
// value_compare two value types.
|
||||
// Compare two value types.
|
||||
ETL_CONSTEXPR14 bool operator ()(const value_type& element1, const value_type& element2) const ETL_NOEXCEPT
|
||||
{
|
||||
return kcompare(element1.first, element2.first);
|
||||
}
|
||||
|
||||
// Compare value type and key.
|
||||
ETL_CONSTEXPR14 bool operator ()(const value_type& element, const_key_reference key) const ETL_NOEXCEPT
|
||||
{
|
||||
return kcompare(element.first, key);
|
||||
}
|
||||
|
||||
// Compare value types and key.
|
||||
// Enabled for transparent comparators.
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 bool operator ()(const value_type& element, const K& key) const ETL_NOEXCEPT
|
||||
{
|
||||
return kcompare(element.first, key);
|
||||
}
|
||||
|
||||
// Compare key and value type.
|
||||
ETL_CONSTEXPR14 bool operator ()(const_key_reference key, const value_type& element) const ETL_NOEXCEPT
|
||||
{
|
||||
return kcompare(key, element.first);
|
||||
}
|
||||
|
||||
// Compare key and value type.
|
||||
// Enabled for transparent comparators.
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 bool operator ()(const K& key, const value_type& element) const ETL_NOEXCEPT
|
||||
{
|
||||
@ -173,6 +175,7 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Index operator.
|
||||
///\param key The key of the element to return.
|
||||
///\return A <code>const_mapped_reference</code> to the mapped value at the index.
|
||||
/// Undefined behaviour if the key is not in the map.
|
||||
//*************************************************************************
|
||||
@ -186,6 +189,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
///\brief Key index operator.
|
||||
/// Enabled for transparent comparators.
|
||||
///\param key The key of the element to return.
|
||||
///\return A <code>const_mapped_reference</code> to the mapped value at the key index.
|
||||
/// Undefined behaviour if the key is not in the map.
|
||||
//*************************************************************************
|
||||
@ -199,6 +203,7 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the mapped value at the key index.
|
||||
///\param key The key of the element to return.
|
||||
///\return A <code>const_mapped_reference</code> to the mapped value at the index.
|
||||
/// Undefined behaviour if the key is not in the map.
|
||||
//*************************************************************************
|
||||
@ -209,6 +214,12 @@ namespace etl
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets the mapped value at the key index.
|
||||
/// Enabled if the comparator is transparent.
|
||||
///\param key The key of the element to return.
|
||||
///\return A <code>const_mapped_reference</code> to the mapped value at the index.
|
||||
/// Undefined behaviour if the key is not in the map.
|
||||
//*************************************************************************
|
||||
template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 const_mapped_reference at(const K& key) const ETL_NOEXCEPT
|
||||
@ -218,54 +229,60 @@ namespace etl
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets a const_iterator to the mapped value at the key index.
|
||||
///\param key The key of the element to find.
|
||||
///\return A <code>const_iterator</code> to the mapped value at the index,
|
||||
/// or end() if not found.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 const_iterator find(const_key_reference key) const ETL_NOEXCEPT
|
||||
{
|
||||
iterator itr = lower_bound(key);
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
if ((itr != end()) && (keys_are_equal(itr->first, key)))
|
||||
{
|
||||
if (keys_are_equal(itr->first, key))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
return itr;
|
||||
}
|
||||
|
||||
return end();
|
||||
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Gets a const_iterator to the mapped 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 mapped 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
|
||||
{
|
||||
iterator itr = lower_bound(key);
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
if ((itr != end()) && (keys_are_equal(itr->first, key)))
|
||||
{
|
||||
if (keys_are_equal(itr->first, key))
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
return itr;
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Checks if the map contains an element with key.
|
||||
///\param key The key of the element to check.
|
||||
///\return <b>true</b> if the map contains an element with key.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 bool contains(const_key_reference key) const ETL_NOEXCEPT
|
||||
{
|
||||
return find(key) != end();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\brief Checks if the map 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 map 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
|
||||
@ -273,12 +290,21 @@ namespace etl
|
||||
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_reference key) const ETL_NOEXCEPT
|
||||
{
|
||||
return contains(key) ? 1 : 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\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
|
||||
@ -286,12 +312,27 @@ namespace etl
|
||||
return contains(key) ? 1 : 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
///\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_reference 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
|
||||
@ -299,12 +340,23 @@ namespace etl
|
||||
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_reference 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
|
||||
@ -312,12 +364,23 @@ namespace etl
|
||||
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_reference 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
|
||||
@ -325,30 +388,46 @@ namespace etl
|
||||
return etl::upper_bound(begin(), end(), key, vcompare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks if the map is empty.
|
||||
///\return <b>true</b> if the map is empty.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type empty() const ETL_NOEXCEPT
|
||||
{
|
||||
return size() == 0U;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks if the map is full.
|
||||
///\return <b>true</b> if the map is full.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT
|
||||
{
|
||||
return size() == Size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the size of the map.
|
||||
///\return The size of the map.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type size() const ETL_NOEXCEPT
|
||||
{
|
||||
return size_type(element_list_end - element_list);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum size of the map.
|
||||
///\return The maximum size of the map.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type max_size() const ETL_NOEXCEPT
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the capacity of the map.
|
||||
/// This is always equal to max_size().
|
||||
///\return The capacity of the map.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 size_type capacity() const ETL_NOEXCEPT
|
||||
{
|
||||
@ -357,6 +436,7 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
///\return An instance of the key_compare type.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 key_compare key_comp() const ETL_NOEXCEPT
|
||||
{
|
||||
@ -365,6 +445,7 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
///\return An instance of the value_compare type.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 value_compare value_comp() const ETL_NOEXCEPT
|
||||
{
|
||||
@ -381,6 +462,9 @@ namespace etl
|
||||
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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3291,6 +3291,7 @@
|
||||
<ClInclude Include="..\..\include\etl\combinations.h" />
|
||||
<ClInclude Include="..\..\include\etl\compare.h" />
|
||||
<ClInclude Include="..\..\include\etl\constant.h" />
|
||||
<ClInclude Include="..\..\include\etl\const_map.h" />
|
||||
<ClInclude Include="..\..\include\etl\correlation.h" />
|
||||
<ClInclude Include="..\..\include\etl\covariance.h" />
|
||||
<ClInclude Include="..\..\include\etl\crc.h" />
|
||||
@ -9270,6 +9271,7 @@
|
||||
<ClCompile Include="..\test_circular_buffer.cpp" />
|
||||
<ClCompile Include="..\test_circular_buffer_external_buffer.cpp" />
|
||||
<ClCompile Include="..\test_circular_iterator.cpp" />
|
||||
<ClCompile Include="..\test_const_map.cpp" />
|
||||
<ClCompile Include="..\test_correlation.cpp" />
|
||||
<ClCompile Include="..\test_covariance.cpp" />
|
||||
<ClCompile Include="..\test_crc1.cpp" />
|
||||
|
||||
@ -1512,6 +1512,9 @@
|
||||
<ClInclude Include="..\..\include\etl\private\chrono\clocks.h">
|
||||
<Filter>ETL\Private\chrono</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\const_map.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test_string_char.cpp">
|
||||
@ -3593,6 +3596,9 @@
|
||||
<ClCompile Include="..\test_chrono_literals.cpp">
|
||||
<Filter>Tests\Chrono</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_const_map.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user