mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Merge remote-tracking branch 'origin/master' into feature/no_stl
# Conflicts: # include/etl/memory.h # include/etl/private/ivectorpointer.h # include/etl/stl/alternate/limits.h # include/etl/stl/iterator.h # test/test_no_stl_algorithm.cpp # test/test_no_stl_functional.cpp # test/test_no_stl_limits.cpp # test/test_no_stl_utility.cpp # test/test_vector_pointer.cpp # test/vs2017/etl.vcxproj.filters
This commit is contained in:
parent
7a9ade20c2
commit
df83a04166
@ -34,11 +34,8 @@ add_library(etl
|
||||
)
|
||||
target_include_directories(etl
|
||||
PUBLIC
|
||||
include/etl
|
||||
include/etl/atomic
|
||||
include
|
||||
include/etl/profiles
|
||||
PRIVATE
|
||||
include/etl/private
|
||||
)
|
||||
|
||||
if (${ETL_PROFILE} STREQUAL DEFAULT)
|
||||
|
||||
4
LICENSE
4
LICENSE
@ -1,8 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 jwellbelove
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
Copyright (c) 2016 jwellbelove, https://github.com/ETLCPP/etl, http://www.etlcpp.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Embedded Template Library (ETL)
|
||||
-------------------------
|
||||
|
||||
AppVeyor [](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
|
||||
AppVeyor [](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [](https://opensource.org/licenses/MIT)
|
||||
|
||||
**Motivation**
|
||||
|
||||
|
||||
@ -336,7 +336,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\src;..\ArmTimerCallbacks - C++</IncludePath>
|
||||
<IncludePath>..\..\include;..\ArmTimerCallbacks - C++</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
||||
@ -9,13 +9,14 @@
|
||||
#define ETL_IVECTOR_REPAIR_ENABLE
|
||||
#define ETL_IDEQUE_REPAIR_ENABLE
|
||||
#define ETL_IN_UNIT_TEST
|
||||
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
|
||||
|
||||
#if (__CC_ARM == 1)
|
||||
// ARM5 compiler
|
||||
#include "profiles/armv5.h"
|
||||
#include "etl/profiles/armv5.h"
|
||||
#else
|
||||
// ARM6 compiler
|
||||
#include "profiles/armv6.h"
|
||||
#include "etl/profiles/armv6.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -9,8 +9,23 @@ extern "C"
|
||||
#include "stm32f4xx.h" // Device header
|
||||
}
|
||||
|
||||
#include "function.h"
|
||||
#include "callback_timer.h"
|
||||
#include "etl/function.h"
|
||||
#include "etl/callback_timer.h"
|
||||
#include "etl/vector.h"
|
||||
|
||||
struct FP
|
||||
{
|
||||
void (*function)();
|
||||
};
|
||||
|
||||
static etl::vector<FP, 10> power_callbacks;
|
||||
|
||||
void register_poweroff_callback(void (*function)())
|
||||
{
|
||||
FP fp = { function };
|
||||
power_callbacks.push_back(fp);
|
||||
}
|
||||
|
||||
|
||||
const int N_TIMERS = 4;
|
||||
|
||||
|
||||
@ -617,7 +617,11 @@ namespace etl
|
||||
|
||||
for (TIterator1 i = begin1; i != end1; ++i)
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1)))
|
||||
#else
|
||||
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i)))
|
||||
#endif
|
||||
{
|
||||
size_t n = std::count(begin2, end2, *i);
|
||||
|
||||
@ -650,7 +654,11 @@ namespace etl
|
||||
{
|
||||
for (TIterator1 i = begin1; i != end1; ++i)
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1)))
|
||||
#else
|
||||
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i)))
|
||||
#endif
|
||||
{
|
||||
size_t n = std::count(begin2, end2, *i);
|
||||
|
||||
|
||||
@ -124,8 +124,7 @@ namespace etl
|
||||
/// Construct from std::array or etl::array or other type that supports
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TArray,
|
||||
typename TDummy = typename etl::enable_if<!etl::is_same<T, TArray>::value, void>::type>
|
||||
template <typename TArray>
|
||||
explicit array_view(TArray& a)
|
||||
: mbegin(a.data()),
|
||||
mend(a.data() + a.size())
|
||||
@ -135,8 +134,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
template <typename TIterator>
|
||||
array_view(TIterator begin_, TIterator end_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + std::distance(begin_, end_))
|
||||
@ -147,8 +145,7 @@ namespace etl
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
typename TSize>
|
||||
array_view(TIterator begin_, TSize size_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + size_)
|
||||
@ -355,24 +352,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assign from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
template <typename TIterator>
|
||||
void assign(TIterator begin_, TIterator end_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
mend = etl::addressof(*begin_) + std::distance(begin_, end_);
|
||||
mend = etl::addressof(*begin_) + std::distance(begin_, end_);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assign from iterator and size.
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
typename TSize>
|
||||
void assign(TIterator begin_, TSize size_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
mend = etl::addressof(*begin_) + size_;
|
||||
mend = etl::addressof(*begin_) + size_;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -519,8 +514,7 @@ namespace etl
|
||||
/// Construct from std::array or etl::array or other type that supports
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TArray,
|
||||
typename TDummy = typename etl::enable_if<!etl::is_same<T, TArray>::value, void>::type>
|
||||
template <typename TArray>
|
||||
explicit const_array_view(TArray& a)
|
||||
: mbegin(a.data()),
|
||||
mend(a.data() + a.size())
|
||||
@ -530,8 +524,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
template <typename TIterator>
|
||||
const_array_view(TIterator begin_, TIterator end_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + std::distance(begin_, end_))
|
||||
@ -542,7 +535,7 @@ namespace etl
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize, typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
typename TSize>
|
||||
const_array_view(TIterator begin_, TSize size_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + size_)
|
||||
@ -706,8 +699,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assign from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
template <typename TIterator>
|
||||
void assign(TIterator begin_, TIterator end_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
@ -718,8 +710,7 @@ namespace etl
|
||||
/// Assign from iterator and size.
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize,
|
||||
typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
|
||||
typename TSize>
|
||||
void assign(TIterator begin_, TSize size_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
@ -834,7 +825,7 @@ namespace etl
|
||||
size_t operator()(const etl::array_view<T>& view) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&view[0]),
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
@ -844,7 +835,7 @@ namespace etl
|
||||
size_t operator()(const etl::const_array_view<T>& view) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&view[0]),
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -34,7 +34,7 @@ SOFTWARE.
|
||||
#include "../static_assert.h"
|
||||
#include "../nullptr.h"
|
||||
|
||||
#include <stdatomic.h>
|
||||
//#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
@ -222,12 +222,12 @@ namespace etl
|
||||
}
|
||||
|
||||
// Load
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst)
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) const
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
@ -429,7 +429,7 @@ namespace etl
|
||||
atomic& operator =(const atomic&);
|
||||
atomic& operator =(const atomic&) volatile;
|
||||
|
||||
volatile T value;
|
||||
mutable volatile T value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -562,12 +562,12 @@ namespace etl
|
||||
}
|
||||
|
||||
// Load
|
||||
T* load(etl::memory_order order = etl::memory_order_seq_cst)
|
||||
T* load(etl::memory_order order = etl::memory_order_seq_cst) const
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
|
||||
T* load(etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
T* load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
@ -736,7 +736,7 @@ namespace etl
|
||||
atomic& operator =(const atomic&);
|
||||
atomic& operator =(const atomic&) volatile;
|
||||
|
||||
volatile T* value;
|
||||
mutable volatile T* value;
|
||||
};
|
||||
|
||||
typedef etl::atomic<char> atomic_char;
|
||||
|
||||
@ -210,12 +210,12 @@ namespace etl
|
||||
}
|
||||
|
||||
// Load
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst)
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) const
|
||||
{
|
||||
return value.load(order);
|
||||
}
|
||||
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
T load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
{
|
||||
return value.load(order);
|
||||
}
|
||||
|
||||
@ -41,12 +41,12 @@ SOFTWARE.
|
||||
|
||||
#if defined(ETL_DEBUG_COUNT)
|
||||
|
||||
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count
|
||||
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count
|
||||
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count
|
||||
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n)
|
||||
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n)
|
||||
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear()
|
||||
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count;
|
||||
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count;
|
||||
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count;
|
||||
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n);
|
||||
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n);
|
||||
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear();
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -84,25 +84,15 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline debug_count& operator +=(int32_t n)
|
||||
{
|
||||
count += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline debug_count& operator -=(int32_t n)
|
||||
{
|
||||
count -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline debug_count& operator +=(size_t n)
|
||||
template <typename T>
|
||||
inline debug_count& operator +=(T n)
|
||||
{
|
||||
count += int32_t(n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline debug_count& operator -=(size_t n)
|
||||
template <typename T>
|
||||
inline debug_count& operator -=(T n)
|
||||
{
|
||||
count -= int32_t(n);
|
||||
return *this;
|
||||
@ -135,4 +125,3 @@ namespace etl
|
||||
#endif // ETL_DEBUG_COUNT
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ namespace etl
|
||||
size_type current_size; ///< The current number of elements in the deque.
|
||||
const size_type CAPACITY; ///< The maximum number of elements in the deque.
|
||||
const size_type BUFFER_SIZE; ///< The number of elements in the buffer.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -935,7 +935,7 @@ namespace etl
|
||||
--_begin;
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
@ -943,7 +943,7 @@ namespace etl
|
||||
p = etl::addressof(*_end);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
@ -1000,7 +1000,7 @@ namespace etl
|
||||
--_begin;
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
@ -1008,7 +1008,7 @@ namespace etl
|
||||
p = etl::addressof(*_end);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
@ -1065,7 +1065,7 @@ namespace etl
|
||||
--_begin;
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
@ -1073,7 +1073,7 @@ namespace etl
|
||||
p = etl::addressof(*_end);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
@ -1130,7 +1130,7 @@ namespace etl
|
||||
--_begin;
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
@ -1138,7 +1138,7 @@ namespace etl
|
||||
p = etl::addressof(*_end);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
@ -1538,7 +1538,7 @@ namespace etl
|
||||
::new (&(*_end)) T(value1);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1555,7 +1555,7 @@ namespace etl
|
||||
::new (&(*_end)) T(value1, value2);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1572,7 +1572,7 @@ namespace etl
|
||||
::new (&(*_end)) T(value1, value2, value3);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1589,7 +1589,7 @@ namespace etl
|
||||
::new (&(*_end)) T(value1, value2, value3, value4);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1645,7 +1645,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(value1);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1662,7 +1662,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(value1, value2);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1679,7 +1679,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(value1, value2, value3);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1696,7 +1696,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(value1, value2, value3, value4);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1811,7 +1811,7 @@ namespace etl
|
||||
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
|
||||
{
|
||||
current_size = 0;
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1850,7 +1850,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T();
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -1882,7 +1882,7 @@ namespace etl
|
||||
::new (&(*item++)) T(*from);
|
||||
++from;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
} while (n-- != 0);
|
||||
}
|
||||
|
||||
@ -1894,7 +1894,7 @@ namespace etl
|
||||
::new (&(*_end)) T();
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -1905,7 +1905,7 @@ namespace etl
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(value);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -1916,7 +1916,7 @@ namespace etl
|
||||
::new (&(*_end)) T(value);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -1926,7 +1926,7 @@ namespace etl
|
||||
{
|
||||
(*_begin).~T();
|
||||
--current_size;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
++_begin;
|
||||
}
|
||||
|
||||
@ -1938,7 +1938,7 @@ namespace etl
|
||||
--_end;
|
||||
(*_end).~T();
|
||||
--current_size;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -40,7 +40,7 @@ SOFTWARE.
|
||||
#include "alignment.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_lookup.h"
|
||||
#include <pool.h>
|
||||
#include "pool.h"
|
||||
|
||||
#if defined(ETL_COMPILER_GCC)
|
||||
#warning THIS CLASS IS DEPRECATED!USE VARIANT_POOL INSTEAD.
|
||||
|
||||
@ -101,13 +101,15 @@ namespace etl
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -234,7 +236,7 @@ namespace etl
|
||||
{
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type();
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
std::pair<iterator, bool> result = refmap_t::insert_at(i_element, *pvalue);
|
||||
i_element->second = result.first->second;
|
||||
@ -300,13 +302,13 @@ namespace etl
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != value.first)))
|
||||
if ((i_element == end()) || compare(i_element->first, value.first) || compare(value.first, i_element->first))
|
||||
{
|
||||
ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_map_full));
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
@ -367,7 +369,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -399,7 +401,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -431,7 +433,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -463,7 +465,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -495,7 +497,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -525,7 +527,7 @@ namespace etl
|
||||
i_element->~value_type();
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refmap_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -539,7 +541,7 @@ namespace etl
|
||||
i_element->~value_type();
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refmap_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -558,7 +560,7 @@ namespace etl
|
||||
itr->~value_type();
|
||||
storage.release(etl::addressof(*itr));
|
||||
++itr;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
refmap_t::erase(first, last);
|
||||
@ -585,7 +587,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
refmap_t::clear();
|
||||
}
|
||||
|
||||
@ -764,8 +766,10 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -103,13 +103,15 @@ namespace etl
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -260,7 +262,7 @@ namespace etl
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
|
||||
return result;
|
||||
@ -313,7 +315,7 @@ namespace etl
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
@ -331,7 +333,7 @@ namespace etl
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
@ -349,7 +351,7 @@ namespace etl
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
@ -367,7 +369,7 @@ namespace etl
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
@ -385,7 +387,7 @@ namespace etl
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
@ -420,7 +422,7 @@ namespace etl
|
||||
i_element->~value_type();
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refmap_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -439,7 +441,7 @@ namespace etl
|
||||
itr->~value_type();
|
||||
storage.release(etl::addressof(*itr));
|
||||
++itr;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
refmap_t::erase(first, last);
|
||||
@ -466,7 +468,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
refmap_t::clear();
|
||||
}
|
||||
|
||||
@ -646,7 +648,7 @@ namespace etl
|
||||
storage_t& storage;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -232,11 +232,11 @@ namespace etl
|
||||
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, compare);
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
|
||||
return result;
|
||||
@ -292,7 +292,7 @@ namespace etl
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ namespace etl
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ namespace etl
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ namespace etl
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*i_element));
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refset_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -399,7 +399,7 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*itr));
|
||||
storage.release(etl::addressof(*itr));
|
||||
++itr;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
refset_t::erase(first, last);
|
||||
@ -426,7 +426,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
refset_t::clear();
|
||||
}
|
||||
|
||||
@ -605,8 +605,10 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -233,13 +233,13 @@ namespace etl
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != value)))
|
||||
if ((i_element == end()) || compare(*i_element, value) || compare(value, *i_element))
|
||||
{
|
||||
ETL_ASSERT(!refset_t::full(), ETL_ERROR(flat_set_full));
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -333,7 +333,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -366,7 +366,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -399,7 +399,7 @@ namespace etl
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
@ -431,7 +431,7 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*i_element));
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refset_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -445,7 +445,7 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*i_element));
|
||||
storage.release(etl::addressof(*i_element));
|
||||
refset_t::erase(i_element);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -464,7 +464,7 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*itr));
|
||||
storage.release(etl::addressof(*itr));
|
||||
++itr;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
refset_t::erase(first, last);
|
||||
@ -488,11 +488,11 @@ namespace etl
|
||||
etl::destroy_at(etl::addressof(*itr));
|
||||
storage.release(etl::addressof(*itr));
|
||||
++itr;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
}
|
||||
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
refset_t::clear();
|
||||
}
|
||||
|
||||
@ -671,8 +671,10 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -236,17 +236,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Get the head node.
|
||||
//*************************************************************************
|
||||
node_t& get_head()
|
||||
node_t* get_head()
|
||||
{
|
||||
return *start_node.next;
|
||||
return start_node.next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get the head node.
|
||||
//*************************************************************************
|
||||
const node_t& get_head() const
|
||||
const node_t* get_head() const
|
||||
{
|
||||
return *start_node.next;
|
||||
return start_node.next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -278,7 +278,7 @@ namespace etl
|
||||
node_t start_node; ///< The node that acts as the forward_list start.
|
||||
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
|
||||
const size_type MAX_SIZE; ///< The maximum size of the forward_list.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -329,8 +329,8 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
iterator(node_t& node)
|
||||
: p_node(&node)
|
||||
iterator(node_t* node)
|
||||
: p_node(node)
|
||||
{
|
||||
}
|
||||
|
||||
@ -417,13 +417,13 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(node_t& node)
|
||||
: p_node(&node)
|
||||
const_iterator(node_t* node)
|
||||
: p_node(node)
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const node_t& node)
|
||||
: p_node(&node)
|
||||
const_iterator(const node_t* node)
|
||||
: p_node(node)
|
||||
{
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(data_cast(get_head()));
|
||||
return iterator(get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -501,7 +501,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(data_cast(get_head()));
|
||||
return const_iterator(get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -509,7 +509,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator before_begin()
|
||||
{
|
||||
return iterator(static_cast<data_node_t&>(start_node));
|
||||
return iterator(&start_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -517,7 +517,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator before_begin() const
|
||||
{
|
||||
return const_iterator(static_cast<const data_node_t&>(start_node));
|
||||
return const_iterator(&start_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -565,7 +565,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
{
|
||||
return data_cast(get_head()).value;
|
||||
return data_cast(*get_head()).value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -573,7 +573,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return data_cast(get_head()).value;
|
||||
return data_cast(*get_head()).value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -658,7 +658,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -673,7 +673,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -688,7 +688,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -703,7 +703,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -780,7 +780,7 @@ namespace etl
|
||||
data_node_t& data_node = allocate_data_node(value);
|
||||
insert_node_after(*position.p_node, data_node);
|
||||
|
||||
return iterator(data_node);
|
||||
return iterator(&data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -793,10 +793,10 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -809,10 +809,10 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -825,10 +825,10 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -841,10 +841,10 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -931,7 +931,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
return iterator(*p_last);
|
||||
return iterator(p_last);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1023,7 +1023,7 @@ namespace etl
|
||||
return;
|
||||
}
|
||||
|
||||
node_t* last = &get_head();
|
||||
node_t* last = get_head();
|
||||
node_t* current = last->next;
|
||||
|
||||
while (current != nullptr)
|
||||
@ -1247,7 +1247,7 @@ namespace etl
|
||||
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
|
||||
{
|
||||
p_node_pool->release_all();
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1326,7 +1326,7 @@ namespace etl
|
||||
{
|
||||
data_node_t* p_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_node->value)) T(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return *p_node;
|
||||
}
|
||||
@ -1338,7 +1338,7 @@ namespace etl
|
||||
{
|
||||
node.value.~T();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Disable copy construction.
|
||||
|
||||
@ -390,6 +390,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -451,6 +455,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -511,6 +519,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -570,6 +582,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -627,6 +643,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -683,6 +703,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -738,6 +762,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -792,6 +820,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -844,6 +876,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -895,6 +931,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -945,6 +985,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -994,6 +1038,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -1041,6 +1089,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -1087,6 +1139,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -1132,6 +1188,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -1176,6 +1236,10 @@ namespace etl
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
@ -1216,6 +1280,12 @@ namespace etl
|
||||
: ifsm_state(STATE_ID)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~fsm_state()
|
||||
{
|
||||
}
|
||||
|
||||
inline TContext& get_fsm_context() const
|
||||
{
|
||||
|
||||
@ -411,6 +411,10 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl("protected:")
|
||||
cog.outl("")
|
||||
cog.outl(" ~fsm_state()")
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" inline TContext& get_fsm_context() const")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
|
||||
@ -484,6 +488,10 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl("protected:")
|
||||
cog.outl("")
|
||||
cog.outl(" ~fsm_state()")
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" inline TContext& get_fsm_context() const")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
|
||||
@ -538,6 +546,12 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl("protected:")
|
||||
cog.outl("")
|
||||
cog.outl(" ~fsm_state()")
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" inline TContext& get_fsm_context() const")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
|
||||
|
||||
@ -278,17 +278,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Get the head link.
|
||||
//*************************************************************************
|
||||
link_type& get_head()
|
||||
link_type* get_head()
|
||||
{
|
||||
return *start_link.etl_next;
|
||||
return start_link.etl_next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get the head link.
|
||||
//*************************************************************************
|
||||
const link_type& get_head() const
|
||||
const link_type* get_head() const
|
||||
{
|
||||
return *start_link.etl_next;
|
||||
return start_link.etl_next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -338,8 +338,8 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
iterator(value_type& value)
|
||||
: p_value(&value)
|
||||
iterator(value_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
@ -428,8 +428,8 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const value_type& value)
|
||||
: p_value(&value)
|
||||
const_iterator(const value_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(static_cast<value_type&>(this->get_head()));
|
||||
return iterator(static_cast<value_type*>(this->get_head()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -534,7 +534,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(this->get_head()));
|
||||
return const_iterator(static_cast<const value_type*>(this->get_head()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -542,7 +542,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator before_begin()
|
||||
{
|
||||
return iterator(static_cast<value_type&>(this->start_link));
|
||||
return iterator(&(static_cast<value_type&>(this->start_link)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -550,7 +550,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator before_begin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(this->start_link));
|
||||
return const_iterator(&(static_cast<const value_type&>(this->start_link)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -558,7 +558,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(this->get_head()));
|
||||
return const_iterator(static_cast<const value_type*>(this->get_head()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -590,7 +590,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
{
|
||||
return static_cast<value_type&>(this->get_head());
|
||||
return static_cast<value_type&>(*(this->get_head()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -598,7 +598,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return static_cast<const value_type&>(this->get_head());;
|
||||
return static_cast<const value_type&>(*(this->get_head()));;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -607,7 +607,7 @@ namespace etl
|
||||
iterator insert_after(iterator position, value_type& value)
|
||||
{
|
||||
this->insert_link_after(*position.p_value, value);
|
||||
return iterator(value);
|
||||
return iterator(&value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -686,7 +686,7 @@ namespace etl
|
||||
return;
|
||||
}
|
||||
|
||||
link_type* last = &this->get_head();
|
||||
link_type* last = this->get_head();
|
||||
link_type* current = last->etl_next;
|
||||
|
||||
while (current != nullptr)
|
||||
@ -886,7 +886,7 @@ namespace etl
|
||||
{
|
||||
if (!other.empty())
|
||||
{
|
||||
link_type& first = other.get_head();
|
||||
link_type& first = *other.get_head();
|
||||
|
||||
if (&other != this)
|
||||
{
|
||||
@ -982,7 +982,7 @@ namespace etl
|
||||
ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_forward_list_unsorted));
|
||||
#endif
|
||||
|
||||
value_type* other_begin = static_cast<value_type*>(&other.get_head());
|
||||
value_type* other_begin = static_cast<value_type*>(other.get_head());
|
||||
value_type* other_terminal = nullptr;
|
||||
|
||||
value_type* before = static_cast<value_type*>(&this->start_link);
|
||||
|
||||
@ -320,7 +320,7 @@ namespace etl
|
||||
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
|
||||
node_t terminal_node; ///< The node that acts as the list start and end.
|
||||
const size_type MAX_SIZE; ///< The maximum size of the list.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -789,7 +789,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
@ -804,7 +804,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
@ -819,7 +819,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
@ -880,7 +880,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -895,7 +895,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -910,7 +910,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -925,7 +925,7 @@ namespace etl
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
@ -964,7 +964,7 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
@ -980,7 +980,7 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
@ -996,7 +996,7 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
@ -1012,7 +1012,7 @@ namespace etl
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
@ -1456,7 +1456,7 @@ namespace etl
|
||||
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
|
||||
{
|
||||
p_node_pool->release_all();
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1549,7 +1549,7 @@ namespace etl
|
||||
{
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return *p_data_node;
|
||||
}
|
||||
@ -1561,7 +1561,7 @@ namespace etl
|
||||
{
|
||||
node.value.~T();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Disable copy construction.
|
||||
|
||||
@ -452,14 +452,14 @@ namespace etl
|
||||
size_type current_size; ///< The number of the used nodes.
|
||||
const size_type CAPACITY; ///< The maximum size of the map.
|
||||
Node* root_node; ///< The node that acts as the map root.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A templated base for all etl::map types.
|
||||
///\ingroup map
|
||||
//***************************************************************************
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare>
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> >
|
||||
class imap : public etl::map_base
|
||||
{
|
||||
public:
|
||||
@ -481,7 +481,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -492,7 +492,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
{
|
||||
return key_compare()(value1.first, value2.first);
|
||||
return compare(value1.first, value2.first);
|
||||
}
|
||||
};
|
||||
|
||||
@ -524,15 +524,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value.first, node2.value.first);
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
}
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value.first, key);
|
||||
return compare(node.value.first, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value.first);
|
||||
return compare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -540,6 +540,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the map.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
@ -1262,7 +1264,7 @@ namespace etl
|
||||
{
|
||||
Data_Node& node = *p_node_pool->allocate<Data_Node>();
|
||||
::new (&node.value) const value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -1273,7 +1275,7 @@ namespace etl
|
||||
{
|
||||
node.value.~value_type();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
51
include/etl/math_constants.h
Normal file
51
include/etl/math_constants.h
Normal file
@ -0,0 +1,51 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2018 jwellbelove
|
||||
|
||||
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_MATH_CONSTANTS_INCLUDED
|
||||
#define ETL_MATH_CONSTANTS_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
const double pi = 3.14159265358979;
|
||||
const double pi_reciprocal = 0.31830988618379;
|
||||
const double pi_squared = 9.86960440108936;
|
||||
const double e = 2.71828182845905;
|
||||
const double e_reciprocal = 0.36787944117144;
|
||||
const double e_squared = 7.38905609893065;
|
||||
const double root2 = 1.41421356237310;
|
||||
const double root2_reciprocal = 0.70710678118655;
|
||||
const double euler = 0.57721566490153;
|
||||
const double golden_ratio = 1.61803398874989;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 jwellbelove
|
||||
|
||||
@ -31,13 +31,14 @@ SOFTWARE.
|
||||
#ifndef ETL_MEMORY_INCLUDED
|
||||
#define ETL_MEMORY_INCLUDED
|
||||
|
||||
#include "algorithm.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "algorithm.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include "stl/iterator.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
///\defgroup memory memory
|
||||
///\ingroup etl
|
||||
namespace etl
|
||||
@ -96,7 +97,7 @@ namespace etl
|
||||
count += int32_t(std::distance(o_begin, o_end));
|
||||
|
||||
std::fill(o_begin, o_end, value);
|
||||
|
||||
|
||||
return o_end;
|
||||
}
|
||||
|
||||
@ -121,7 +122,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename TOutputIterator, typename TSize, typename T>
|
||||
inline TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T& value)
|
||||
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T& value)
|
||||
{
|
||||
return etl::uninitialized_fill(o_begin, o_begin + n, value);
|
||||
}
|
||||
@ -132,7 +133,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename TOutputIterator, typename TSize, typename T, typename TCounter>
|
||||
inline TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T& value, TCounter& count)
|
||||
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T& value, TCounter& count)
|
||||
{
|
||||
count += n;
|
||||
|
||||
@ -208,7 +209,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename TInputIterator, typename TSize, typename TOutputIterator>
|
||||
inline TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
|
||||
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
|
||||
{
|
||||
return etl::uninitialized_copy(i_begin, i_begin + n, o_begin);
|
||||
}
|
||||
@ -219,7 +220,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename TInputIterator, typename TSize, typename TOutputIterator, typename TCounter>
|
||||
inline TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
|
||||
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
|
||||
{
|
||||
count += n;
|
||||
|
||||
@ -340,7 +341,7 @@ namespace etl
|
||||
/// Default initialises N objects to uninitialised memory.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename TOutputIterator, typename TSize>
|
||||
template <typename TOutputIterator, typename TSize>
|
||||
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
|
||||
uninitialized_default_construct_n(TOutputIterator o_begin, TSize n)
|
||||
{
|
||||
@ -390,7 +391,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
inline void create_value_at(T* p)
|
||||
void create_value_at(T* p)
|
||||
{
|
||||
::new (p) T();
|
||||
}
|
||||
@ -400,7 +401,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TCounter>
|
||||
inline void create_value_at(T* p, TCounter& count)
|
||||
void create_value_at(T* p, TCounter& count)
|
||||
{
|
||||
::new (p) T();
|
||||
++count;
|
||||
@ -411,7 +412,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
inline void create_copy_at(T* p, const T& value)
|
||||
void create_copy_at(T* p, const T& value)
|
||||
{
|
||||
::new (p) T(value);
|
||||
}
|
||||
@ -421,7 +422,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TCounter>
|
||||
inline void create_copy_at(T* p, const T& value, TCounter& count)
|
||||
void create_copy_at(T* p, const T& value, TCounter& count)
|
||||
{
|
||||
::new (p) T(value);
|
||||
++count;
|
||||
@ -432,7 +433,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
inline T& make_default_at(T* p)
|
||||
T& make_default_at(T* p)
|
||||
{
|
||||
::new (p) T();
|
||||
return *reinterpret_cast<T*>(p);
|
||||
@ -443,7 +444,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TCounter>
|
||||
inline T& make_default_at(T* p, TCounter& count)
|
||||
T& make_default_at(T* p, TCounter& count)
|
||||
{
|
||||
::new (p) T();
|
||||
++count;
|
||||
@ -455,7 +456,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
inline T& make_copy_at(T* p, const T& other)
|
||||
T& make_copy_at(T* p, const T& other)
|
||||
{
|
||||
::new (p) T(other);
|
||||
return *reinterpret_cast<T*>(p);
|
||||
@ -466,7 +467,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TCounter>
|
||||
inline T& make_copy_at(T* p, const T& other, TCounter& count)
|
||||
T& make_copy_at(T* p, const T& other, TCounter& count)
|
||||
{
|
||||
::new (p) T(other);
|
||||
++count;
|
||||
@ -478,7 +479,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TParameter>
|
||||
inline T& make_value_at(T* p, const TParameter& value)
|
||||
T& make_value_at(T* p, const TParameter& value)
|
||||
{
|
||||
::new (p) T(value);
|
||||
return *reinterpret_cast<T*>(p);
|
||||
@ -489,7 +490,7 @@ namespace etl
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TParameter, typename TCounter>
|
||||
inline T& make_value_at(T* p, const TParameter& value, TCounter& count)
|
||||
T& make_value_at(T* p, const TParameter& value, TCounter& count)
|
||||
{
|
||||
::new (p) T(value);
|
||||
++count;
|
||||
@ -768,6 +769,321 @@ namespace etl
|
||||
return *reinterpret_cast<T*>(p);
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Default deleter.
|
||||
///\tparam T The pointed to type type.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
struct default_delete
|
||||
{
|
||||
void operator()(T* p) const
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Default deleter for arrays.
|
||||
///\tparam T The pointed to type type.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
struct default_delete<T[]>
|
||||
{
|
||||
template <class U>
|
||||
void operator()(U* p) const
|
||||
{
|
||||
delete[] p;
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Unique pointer.
|
||||
///\tparam T The pointed to type type.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T, typename TDeleter = etl::default_delete<T> >
|
||||
class unique_ptr
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T element_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
|
||||
ETL_CONSTEXPR unique_ptr()
|
||||
: p(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR explicit unique_ptr (pointer p_)
|
||||
: p(p_)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
unique_ptr (unique_ptr&& p_)
|
||||
: p(p_.release())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
~unique_ptr()
|
||||
{
|
||||
deleter(p);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR pointer get() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
TDeleter& get_deleter()
|
||||
{
|
||||
return deleter;
|
||||
}
|
||||
|
||||
const TDeleter& get_deleter() const
|
||||
{
|
||||
return deleter;
|
||||
}
|
||||
|
||||
pointer release()
|
||||
{
|
||||
pointer value = p;
|
||||
p = nullptr;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void reset(pointer p_ = pointer())
|
||||
{
|
||||
assert(p_ != p);
|
||||
|
||||
pointer value = p;
|
||||
p = p_;
|
||||
delete value;
|
||||
}
|
||||
|
||||
void swap(unique_ptr& value)
|
||||
{
|
||||
std::swap(p, value.p);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR explicit operator bool() const
|
||||
{
|
||||
return (p != nullptr);
|
||||
}
|
||||
|
||||
unique_ptr& operator =(pointer p_)
|
||||
{
|
||||
reset(p_);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
unique_ptr& operator =(unique_ptr&& p_)
|
||||
{
|
||||
reset(p_.release());
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
ETL_CONSTEXPR reference operator *() const
|
||||
{
|
||||
return *get();
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR pointer operator ->() const
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR reference operator [](size_t i) const
|
||||
{
|
||||
return get()[i];
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator== (const pointer p_) const
|
||||
{
|
||||
return p == p_;
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator== (const unique_ptr& p_) const
|
||||
{
|
||||
return p == p_.p;
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator< (const unique_ptr& p_) const
|
||||
{
|
||||
return p < p_.p;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Deleted.
|
||||
unique_ptr(const unique_ptr&);
|
||||
unique_ptr& operator =(const unique_ptr&);
|
||||
|
||||
TDeleter deleter;
|
||||
|
||||
pointer p;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Unique pointer for arrays.
|
||||
///\tparam T The pointed to type type.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template<typename T, typename TDeleter>
|
||||
class unique_ptr<T[], TDeleter>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T element_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
|
||||
ETL_CONSTEXPR unique_ptr()
|
||||
: p(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR explicit unique_ptr(pointer p_)
|
||||
: p(p_)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
unique_ptr(unique_ptr&& p_)
|
||||
: p(p_.release())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
~unique_ptr()
|
||||
{
|
||||
deleter(p);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR pointer get() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
TDeleter& get_deleter()
|
||||
{
|
||||
return deleter;
|
||||
}
|
||||
|
||||
const TDeleter& get_deleter() const
|
||||
{
|
||||
return deleter;
|
||||
}
|
||||
|
||||
pointer release()
|
||||
{
|
||||
pointer value = p;
|
||||
p = nullptr;
|
||||
return value;
|
||||
}
|
||||
|
||||
void reset(pointer p_)
|
||||
{
|
||||
assert(p_ != p);
|
||||
|
||||
pointer value = p;
|
||||
p = p_;
|
||||
delete[] value;
|
||||
}
|
||||
|
||||
void swap(unique_ptr& v)
|
||||
{
|
||||
std::swap(p, v.p);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR explicit operator bool() const
|
||||
{
|
||||
return (p != nullptr);
|
||||
}
|
||||
|
||||
unique_ptr& operator =(pointer p_)
|
||||
{
|
||||
reset(p_);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
unique_ptr& operator =(unique_ptr&& p_)
|
||||
{
|
||||
reset(p_.release());
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
ETL_CONSTEXPR reference operator *() const
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR pointer operator ->() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR reference operator [](size_t i) const
|
||||
{
|
||||
return p[i];
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator ==(const pointer p_) const
|
||||
{
|
||||
return (p == p_);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator ==(const unique_ptr& p_) const
|
||||
{
|
||||
return (p == p_.p);
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR bool operator <(const unique_ptr& p_) const
|
||||
{
|
||||
return (p < p_.p);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Deleted.
|
||||
unique_ptr(const unique_ptr&);
|
||||
unique_ptr& operator =(const unique_ptr&);
|
||||
|
||||
TDeleter deleter;
|
||||
|
||||
pointer p;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Base class for objects that require their memory to be wiped after use.
|
||||
/// Erases the object's memory to zero.
|
||||
/// Note: This <b>must</b> be the last destructor called for the derived object.
|
||||
///\tparam T The derived type.
|
||||
///\ingroup memory
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
struct wipe_on_destruct
|
||||
{
|
||||
~wipe_on_destruct()
|
||||
{
|
||||
char* pobject = reinterpret_cast<char*>(static_cast<T*>(this));
|
||||
memset(pobject, 0, sizeof(T));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -32,14 +32,44 @@ SOFTWARE.
|
||||
#define ETL_MEMORY_MODEL_INCLUDED
|
||||
|
||||
#include "user_type.h"
|
||||
#include <stdint.h>
|
||||
#include "type_lookup.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
ETL_DECLARE_USER_TYPE(memory_model, int)
|
||||
ETL_USER_TYPE(MM_SMALL, 0)
|
||||
ETL_USER_TYPE(MM_MEDIUM, 1)
|
||||
ETL_USER_TYPE(MM_LARGE, 2)
|
||||
ETL_USER_TYPE(MEMORY_MODEL_SMALL, 0)
|
||||
ETL_USER_TYPE(MEMORY_MODEL_MEDIUM, 1)
|
||||
ETL_USER_TYPE(MEMORY_MODEL_LARGE, 2)
|
||||
ETL_USER_TYPE(MEMORY_MODEL_HUGE, 3)
|
||||
ETL_END_USER_TYPE(memory_model)
|
||||
|
||||
template <const size_t MEMORY_MODEL>
|
||||
struct size_type_lookup;
|
||||
|
||||
template <>
|
||||
struct size_type_lookup<etl::memory_model::MEMORY_MODEL_SMALL>
|
||||
{
|
||||
typedef uint_least8_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct size_type_lookup<etl::memory_model::MEMORY_MODEL_MEDIUM>
|
||||
{
|
||||
typedef uint_least16_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct size_type_lookup<etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
{
|
||||
typedef uint_least32_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct size_type_lookup<etl::memory_model::MEMORY_MODEL_HUGE>
|
||||
{
|
||||
typedef uint_least64_t type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -609,14 +609,14 @@ namespace etl
|
||||
size_type current_size; ///< The number of the used nodes.
|
||||
const size_type CAPACITY; ///< The maximum size of the map.
|
||||
Node* root_node; ///< The node that acts as the multimap root.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A templated base for all etl::multimap types.
|
||||
///\ingroup map
|
||||
//***************************************************************************
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare>
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> >
|
||||
class imultimap : public etl::multimap_base
|
||||
{
|
||||
public:
|
||||
@ -638,7 +638,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -649,7 +649,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
{
|
||||
return key_compare()(value1.first, value2.first);
|
||||
return compare(value1.first, value2.first);
|
||||
}
|
||||
};
|
||||
|
||||
@ -676,17 +676,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value.first, node2.value.first);
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value.first, key);
|
||||
return compare(node.value.first, key);
|
||||
}
|
||||
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value.first);
|
||||
return compare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -694,6 +694,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the multimap.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
@ -1356,7 +1358,7 @@ namespace etl
|
||||
{
|
||||
Data_Node& node = *p_node_pool->allocate<Data_Node>();
|
||||
::new (&node.value) const value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -1367,7 +1369,7 @@ namespace etl
|
||||
{
|
||||
node.value.~value_type();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -609,14 +609,14 @@ namespace etl
|
||||
size_type current_size; ///< The number of the used nodes.
|
||||
const size_type CAPACITY; ///< The maximum size of the set.
|
||||
Node* root_node; ///< The node that acts as the multiset root.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A templated base for all etl::multiset types.
|
||||
///\ingroup set
|
||||
//***************************************************************************
|
||||
template <typename T, typename TCompare>
|
||||
template <typename T, typename TCompare = std::less<T> >
|
||||
class imultiset : public etl::multiset_base
|
||||
{
|
||||
public:
|
||||
@ -636,7 +636,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -647,7 +647,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return value_compare()(value1, value2);
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -674,15 +674,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value, node2.value);
|
||||
return compare(node1.value, node2.value);
|
||||
}
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value, key);
|
||||
return compare(node.value, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value);
|
||||
return compare(key, node.value);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -690,6 +690,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the multiset.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
@ -1337,7 +1339,7 @@ namespace etl
|
||||
{
|
||||
Data_Node& node = *p_node_pool->allocate<Data_Node>();
|
||||
::new ((void*)&node.value) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -1348,7 +1350,7 @@ namespace etl
|
||||
{
|
||||
node.value.~value_type();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -133,8 +133,9 @@ namespace etl
|
||||
//*****************************************************************
|
||||
/// Remove a particular observer from the list.
|
||||
///\param observer A reference to the observer.
|
||||
///\return <b>true</b> if the observer was removed, <b>false</b> if not.
|
||||
//*****************************************************************
|
||||
void remove_observer(TObserver& observer)
|
||||
bool remove_observer(TObserver& observer)
|
||||
{
|
||||
// See if we have it in our list.
|
||||
typename Observer_List::iterator i_observer = std::find(observer_list.begin(),
|
||||
@ -146,6 +147,11 @@ namespace etl
|
||||
{
|
||||
// Erase it.
|
||||
observer_list.erase(i_observer);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,6 +185,12 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~observable()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// The list of observers.
|
||||
|
||||
@ -115,7 +115,7 @@ namespace etl
|
||||
/// \tparam TContainer to hold the T queue values
|
||||
/// \tparam TCompare to use in comparing T values
|
||||
//***************************************************************************
|
||||
template <typename T, typename TContainer, typename TCompare>
|
||||
template <typename T, typename TContainer, typename TCompare = std::less<T> >
|
||||
class ipriority_queue
|
||||
{
|
||||
public:
|
||||
@ -165,7 +165,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.push_back(value);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -182,7 +182,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -199,7 +199,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -216,7 +216,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2, value3);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -233,7 +233,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2, value3, value4);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -256,7 +256,7 @@ namespace etl
|
||||
|
||||
clear();
|
||||
container.assign(first, last);
|
||||
std::make_heap(container.begin(), container.end(), TCompare());
|
||||
std::make_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -266,7 +266,7 @@ namespace etl
|
||||
void pop()
|
||||
{
|
||||
// Move largest element to end
|
||||
std::pop_heap(container.begin(), container.end(), TCompare());
|
||||
std::pop_heap(container.begin(), container.end(), compare);
|
||||
// Actually remove largest element at end
|
||||
container.pop_back();
|
||||
}
|
||||
@ -319,7 +319,7 @@ namespace etl
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
size_type available() const
|
||||
{
|
||||
return container.max_size() - container.size();
|
||||
}
|
||||
@ -356,6 +356,8 @@ namespace etl
|
||||
|
||||
/// The container specified at instantiation of the priority_queue
|
||||
TContainer container;
|
||||
|
||||
TCompare compare;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -370,7 +372,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = SIZE;
|
||||
typedef typename TContainer::size_type size_type;
|
||||
|
||||
static const size_type MAX_SIZE = size_type(SIZE);
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
|
||||
@ -50,12 +50,12 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef T* value_type;
|
||||
typedef T*& reference;
|
||||
typedef const T* const & const_reference;
|
||||
typedef T** pointer;
|
||||
typedef const T* const * const_pointer;
|
||||
typedef T** iterator;
|
||||
typedef const T* const * const_iterator;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
@ -452,12 +452,12 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef const T* value_type;
|
||||
typedef const T*& reference;
|
||||
typedef const T* const & const_reference;
|
||||
typedef const T** pointer;
|
||||
typedef const T* const * const_pointer;
|
||||
typedef const T** iterator;
|
||||
typedef const T* const * const_iterator;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
|
||||
@ -61,12 +61,12 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef void* value_type;
|
||||
typedef void*& reference;
|
||||
typedef const void*& const_reference;
|
||||
typedef void** pointer;
|
||||
typedef const void** const_pointer;
|
||||
typedef void** iterator;
|
||||
typedef const void** const_iterator;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
@ -74,246 +74,41 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an iterator to the beginning of the vector.
|
||||
///\return An iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
iterator begin()
|
||||
{
|
||||
return p_buffer;
|
||||
}
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the beginning of the vector.
|
||||
///\return A const iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(p_buffer);
|
||||
}
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an iterator to the end of the vector.
|
||||
///\return An iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
iterator end()
|
||||
{
|
||||
return p_end;
|
||||
}
|
||||
const_iterator cbegin() const;
|
||||
const_iterator cend() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the end of the vector.
|
||||
///\return A const iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
const_iterator end() const
|
||||
{
|
||||
return const_iterator(p_end);
|
||||
}
|
||||
reverse_iterator rbegin();
|
||||
const_reverse_iterator rbegin() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the beginning of the vector.
|
||||
///\return A const iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return const_iterator(p_buffer);
|
||||
}
|
||||
reverse_iterator rend();
|
||||
const_reverse_iterator rend() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the end of the vector.
|
||||
///\return A const iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
const_iterator cend() const
|
||||
{
|
||||
return const_iterator(p_end);
|
||||
}
|
||||
const_reverse_iterator crbegin() const;
|
||||
const_reverse_iterator crend() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an reverse iterator to the reverse beginning of the vector.
|
||||
///\return Iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
reverse_iterator rbegin()
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
void resize(size_t new_size);
|
||||
void resize(size_t new_size, value_type value);
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the vector.
|
||||
///\return Const iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
const_reverse_iterator rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
reference operator [](size_t i);
|
||||
const_reference operator [](size_t i) const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reverse iterator to the end + 1 of the vector.
|
||||
///\return Reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
reverse_iterator rend()
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
reference at(size_t i);
|
||||
const_reference at(size_t i) const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the end + 1 of the vector.
|
||||
///\return Const reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
const_reverse_iterator rend() const
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the vector.
|
||||
///\return Const reverse iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
const_reverse_iterator crbegin() const
|
||||
{
|
||||
return const_reverse_iterator(cend());
|
||||
}
|
||||
reference back();
|
||||
const_reference back() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the end + 1 of the vector.
|
||||
///\return Const reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
const_reverse_iterator crend() const
|
||||
{
|
||||
return const_reverse_iterator(cbegin());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the vector.
|
||||
/// If asserts or exceptions are enabled and the new size is larger than the
|
||||
/// maximum then a vector_full is thrown.
|
||||
///\param new_size The new size.
|
||||
//*********************************************************************
|
||||
void resize(size_t new_size)
|
||||
{
|
||||
ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
p_end = p_buffer + new_size;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the vector.
|
||||
/// If asserts or exceptions are enabled and the new size is larger than the
|
||||
/// maximum then a vector_full is thrown.
|
||||
///\param new_size The new size.
|
||||
///\param value The value to fill new elements with. Default = default constructed value.
|
||||
//*********************************************************************
|
||||
void resize(size_t new_size, value_type value)
|
||||
{
|
||||
ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
pointer p_new_end = p_buffer + new_size;
|
||||
|
||||
// Size up if necessary.
|
||||
if (p_end < p_new_end)
|
||||
{
|
||||
std::fill(p_end, p_new_end, value);
|
||||
}
|
||||
|
||||
p_end = p_new_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the value at index 'i'
|
||||
///\param i The index.
|
||||
///\return A reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
reference operator [](size_t i)
|
||||
{
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the value at index 'i'
|
||||
///\param i The index.
|
||||
///\return A const reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
const_reference operator [](size_t i) const
|
||||
{
|
||||
return const_reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the value at index 'i'
|
||||
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
|
||||
///\param i The index.
|
||||
///\return A reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
reference at(size_t i)
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the value at index 'i'
|
||||
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
|
||||
///\param i The index.
|
||||
///\return A const reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
const_reference at(size_t i) const
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return const_reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the first element.
|
||||
///\return A reference to the first element.
|
||||
//*********************************************************************
|
||||
reference front()
|
||||
{
|
||||
return p_buffer[0];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
///\return A const reference to the first element.
|
||||
//*********************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return const_reference(p_buffer[0]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the last element.
|
||||
///\return A reference to the last element.
|
||||
//*********************************************************************
|
||||
reference back()
|
||||
{
|
||||
return *(p_end -1);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the last element.
|
||||
///\return A const reference to the last element.
|
||||
//*********************************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
return const_reference(*(p_end - 1));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a pointer to the beginning of the vector data.
|
||||
///\return A pointer to the beginning of the vector data.
|
||||
//*********************************************************************
|
||||
pointer data()
|
||||
{
|
||||
return p_buffer;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const pointer to the beginning of the vector data.
|
||||
///\return A const pointer to the beginning of the vector data.
|
||||
//*********************************************************************
|
||||
const_pointer data() const
|
||||
{
|
||||
return const_pointer(p_buffer);
|
||||
}
|
||||
pointer data();
|
||||
const_pointer data() const;
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the vector.
|
||||
@ -338,110 +133,17 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
|
||||
///\param n The number of elements to add.
|
||||
///\param value The value to insert for each element.
|
||||
//*********************************************************************
|
||||
void assign(size_t n, value_type value)
|
||||
{
|
||||
initialise();
|
||||
void assign(size_t n, value_type value);
|
||||
|
||||
ETL_ASSERT(n <= CAPACITY, ETL_ERROR(vector_full));
|
||||
void clear();
|
||||
|
||||
for (size_t current_size = 0; current_size < n; ++current_size)
|
||||
{
|
||||
*p_end++ = value;
|
||||
}
|
||||
}
|
||||
void push_back();
|
||||
void push_back(value_type value);
|
||||
|
||||
//*************************************************************************
|
||||
/// Clears the vector.
|
||||
//*************************************************************************
|
||||
void clear()
|
||||
{
|
||||
initialise();
|
||||
}
|
||||
void pop_back();
|
||||
|
||||
//*************************************************************************
|
||||
/// Increases the size of the vector by one, but does not initialise the new element.
|
||||
/// If asserts or exceptions are enabled, throws a vector_full if the vector is already full.
|
||||
//*************************************************************************
|
||||
void push_back()
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
#endif
|
||||
|
||||
++p_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value at the end of the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
void push_back(value_type value)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
#endif
|
||||
*p_end++ = value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes an element from the end of the vector.
|
||||
/// Does nothing if the vector is empty.
|
||||
//*************************************************************************
|
||||
void pop_back()
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() > 0, ETL_ERROR(vector_empty));
|
||||
#endif
|
||||
--p_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param position The position to insert before.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
iterator insert(iterator position, value_type value)
|
||||
{
|
||||
ETL_ASSERT(size() + 1 <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
if (position != end())
|
||||
{
|
||||
++p_end;
|
||||
std::copy_backward(position, end() - 1, end());
|
||||
*position = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_end++ = value;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts 'n' values to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
|
||||
///\param position The position to insert before.
|
||||
///\param n The number of elements to add.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
void insert(iterator position, size_t n, value_type value)
|
||||
{
|
||||
ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
std::copy_backward(position, p_end, p_end + n);
|
||||
std::fill_n(position, n, value);
|
||||
|
||||
p_end += n;
|
||||
}
|
||||
iterator insert(iterator position, value_type value);
|
||||
void insert(iterator position, size_t n, value_type value);
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a range of values to the vector.
|
||||
@ -463,117 +165,26 @@ namespace etl
|
||||
p_end += count;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param i_element Iterator to the element.
|
||||
///\return An iterator pointing to the element that followed the erased element.
|
||||
//*********************************************************************
|
||||
iterator erase(iterator i_element)
|
||||
{
|
||||
std::copy(i_element + 1, end(), i_element);
|
||||
--p_end;
|
||||
iterator erase(iterator i_element);
|
||||
iterator erase(iterator first, iterator last);
|
||||
|
||||
return i_element;
|
||||
}
|
||||
pvoidvector& operator = (const pvoidvector& rhs);
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// The range includes all the elements between first and last, including the
|
||||
/// element pointed by first, but not the one pointed by last.
|
||||
///\param first Iterator to the first element.
|
||||
///\param last Iterator to the last element.
|
||||
///\return An iterator pointing to the element that followed the erased element.
|
||||
//*********************************************************************
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
std::copy(last, end(), first);
|
||||
size_t n_delete = std::distance(first, last);
|
||||
size_type size() const;
|
||||
|
||||
// Just adjust the count.
|
||||
p_end -= n_delete;
|
||||
bool empty() const;
|
||||
|
||||
return first;
|
||||
}
|
||||
bool full() const;
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
pvoidvector& operator = (const pvoidvector& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
assign(rhs.cbegin(), rhs.cend());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current size of the vector.
|
||||
///\return The current size of the vector.
|
||||
//*************************************************************************
|
||||
size_type size() const
|
||||
{
|
||||
return size_t(p_end - p_buffer);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks the 'empty' state of the vector.
|
||||
///\return <b>true</b> if empty.
|
||||
//*************************************************************************
|
||||
bool empty() const
|
||||
{
|
||||
return (p_end == p_buffer);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks the 'full' state of the vector.
|
||||
///\return <b>true</b> if full.
|
||||
//*************************************************************************
|
||||
bool full() const
|
||||
{
|
||||
return size() == CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
{
|
||||
return max_size() - size();
|
||||
}
|
||||
size_t available() const;
|
||||
|
||||
protected:
|
||||
|
||||
//*********************************************************************
|
||||
/// Constructor.
|
||||
//*********************************************************************
|
||||
pvoidvector(void** p_buffer_, size_t MAX_SIZE)
|
||||
: vector_base(MAX_SIZE),
|
||||
p_buffer(p_buffer_),
|
||||
p_end(p_buffer_)
|
||||
{
|
||||
}
|
||||
pvoidvector(void** p_buffer_, size_t MAX_SIZE);
|
||||
|
||||
//*********************************************************************
|
||||
/// Initialise the vector.
|
||||
//*********************************************************************
|
||||
void initialise()
|
||||
{
|
||||
p_end = p_buffer;
|
||||
}
|
||||
void initialise();
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair(void** p_buffer_)
|
||||
{
|
||||
uintptr_t length = p_end - p_buffer;
|
||||
|
||||
p_buffer = p_buffer_;
|
||||
p_end = p_buffer_ + length;
|
||||
}
|
||||
void repair(void** p_buffer_);
|
||||
|
||||
void** p_buffer;
|
||||
void** p_end;
|
||||
|
||||
@ -162,7 +162,7 @@ namespace etl
|
||||
}
|
||||
|
||||
const size_type CAPACITY; ///<The maximum number of elements in the vector.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,8 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "type_traits.h"
|
||||
#include "parameter_type.h"
|
||||
#include "memory_model.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "13"
|
||||
@ -102,11 +104,13 @@ namespace etl
|
||||
/// The base class for all queues.
|
||||
///\ingroup queue
|
||||
//***************************************************************************
|
||||
template <const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_base
|
||||
{
|
||||
public:
|
||||
|
||||
typedef size_t size_type; ///< The type used for determining the size of queue.
|
||||
/// The type used for determining the size of queue.
|
||||
typedef typename etl::size_type_lookup<MEMORY_MODEL>::type size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the current number of items in the queue.
|
||||
@ -154,7 +158,7 @@ namespace etl
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
size_type available() const
|
||||
{
|
||||
return max_size() - size();
|
||||
}
|
||||
@ -190,7 +194,7 @@ namespace etl
|
||||
}
|
||||
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -203,7 +207,7 @@ namespace etl
|
||||
out = 0;
|
||||
}
|
||||
--current_size;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -214,14 +218,14 @@ namespace etl
|
||||
in = 0;
|
||||
out = 0;
|
||||
current_size = 0;
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
|
||||
size_type in; ///< Where to input new data.
|
||||
size_type out; ///< Where to get the oldest data.
|
||||
size_type in; ///< Where to input new data.
|
||||
size_type out; ///< Where to get the oldest data.
|
||||
size_type current_size; ///< The number of items in the queue.
|
||||
const size_type CAPACITY; ///< The maximum number of items in the queue.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes.
|
||||
|
||||
};
|
||||
|
||||
@ -236,25 +240,32 @@ namespace etl
|
||||
/// \warning This queue cannot be used for concurrent access from multiple threads.
|
||||
/// \tparam T The type of value that the queue holds.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class iqueue : public etl::queue_base
|
||||
template <typename T, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class iqueue : public etl::queue_base<MEMORY_MODEL>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef T* pointer; ///< A pointer to the type used in the queue.
|
||||
typedef const T* const_pointer; ///< A const pointer to the type used in the queue.
|
||||
typedef queue_base::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
private:
|
||||
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef typename etl::queue_base base_t;
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef typename etl::queue_base<MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef T* pointer; ///< A pointer to the type used in the queue.
|
||||
typedef const T* const_pointer; ///< A const pointer to the type used in the queue.
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
using base_t::in;
|
||||
using base_t::out;
|
||||
using base_t::CAPACITY;
|
||||
using base_t::current_size;
|
||||
using base_t::full;
|
||||
using base_t::empty;
|
||||
using base_t::add_in;
|
||||
using base_t::del_out;
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets a reference to the value at the front of the queue.<br>
|
||||
/// \return A reference to the value at the front of the queue.
|
||||
@ -302,7 +313,7 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(value);
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -319,7 +330,7 @@ namespace etl
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
|
||||
return p_buffer[next];
|
||||
}
|
||||
@ -336,7 +347,7 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(value1);
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -351,7 +362,7 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(value1, value2);
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -366,7 +377,7 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(value1, value2, value3);
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -381,7 +392,7 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(value1, value2, value3, value4);
|
||||
base_t::add_in();
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -398,7 +409,7 @@ namespace etl
|
||||
while (current_size > 0)
|
||||
{
|
||||
p_buffer[out].~T();
|
||||
base_t::del_out();
|
||||
del_out();
|
||||
}
|
||||
|
||||
in = 0;
|
||||
@ -417,7 +428,7 @@ namespace etl
|
||||
ETL_ASSERT(!empty(), ETL_ERROR(queue_empty));
|
||||
#endif
|
||||
p_buffer[out].~T();
|
||||
base_t::del_out();
|
||||
del_out();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -466,9 +477,9 @@ namespace etl
|
||||
{
|
||||
clear();
|
||||
|
||||
size_t index = other.out;
|
||||
size_type index = other.out;
|
||||
|
||||
for (size_t i = 0; i < other.size(); ++i)
|
||||
for (size_type i = 0; i < other.size(); ++i)
|
||||
{
|
||||
push(other.p_buffer[index]);
|
||||
index = (index == (CAPACITY - 1)) ? 0 : index + 1;
|
||||
@ -479,7 +490,7 @@ namespace etl
|
||||
/// The constructor that is called from derived classes.
|
||||
//*************************************************************************
|
||||
iqueue(T* p_buffer_, size_type max_size_)
|
||||
: queue_base(max_size_),
|
||||
: base_t(max_size_),
|
||||
p_buffer(p_buffer_)
|
||||
{
|
||||
}
|
||||
@ -511,21 +522,30 @@ namespace etl
|
||||
///\ingroup queue
|
||||
/// A fixed capacity queue.
|
||||
/// This queue does not support concurrent access by different threads.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables.
|
||||
//***************************************************************************
|
||||
template <typename T, const size_t SIZE>
|
||||
class queue : public etl::iqueue<T>
|
||||
template <typename T, const size_t SIZE, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue : public etl::iqueue<T, MEMORY_MODEL>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef etl::iqueue<T, MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = SIZE;
|
||||
typedef typename base_t::size_type size_type;
|
||||
|
||||
ETL_STATIC_ASSERT((SIZE <= etl::integral_limits<size_type>::max), "Size too large for memory model");
|
||||
|
||||
static const size_type MAX_SIZE = size_type(SIZE);
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
queue()
|
||||
: etl::iqueue<T>(reinterpret_cast<T*>(&buffer[0]), SIZE)
|
||||
: base_t(reinterpret_cast<T*>(&buffer[0]), SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -533,9 +553,9 @@ namespace etl
|
||||
/// Copy constructor
|
||||
//*************************************************************************
|
||||
queue(const queue& rhs)
|
||||
: etl::iqueue<T>(reinterpret_cast<T*>(&buffer[0]), SIZE)
|
||||
: base_t(reinterpret_cast<T*>(&buffer[0]), SIZE)
|
||||
{
|
||||
etl::iqueue<T>::clone(rhs);
|
||||
base_t::clone(rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -543,7 +563,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
~queue()
|
||||
{
|
||||
etl::iqueue<T>::clear();
|
||||
base_t::clear();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -553,7 +573,7 @@ namespace etl
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
etl::iqueue<T>::clone(rhs);
|
||||
base_t::clone(rhs);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
@ -38,20 +38,26 @@ SOFTWARE.
|
||||
#include "alignment.h"
|
||||
#include "parameter_type.h"
|
||||
#include "mutex.h"
|
||||
#include "memory_model.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "48"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_mpmc_mutex_base
|
||||
{
|
||||
public:
|
||||
|
||||
/// The type used for determining the size of queue.
|
||||
typedef typename etl::size_type_lookup<MEMORY_MODEL>::type size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t capacity() const
|
||||
size_type capacity() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
@ -59,14 +65,14 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
size_type max_size() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
queue_mpmc_mutex_base(size_t max_size_)
|
||||
queue_mpmc_mutex_base(size_type max_size_)
|
||||
: write_index(0),
|
||||
read_index(0),
|
||||
current_size(0),
|
||||
@ -77,7 +83,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Calculate the next index.
|
||||
//*************************************************************************
|
||||
static size_t get_next_index(size_t index, size_t maximum)
|
||||
static size_type get_next_index(size_type index, size_type maximum)
|
||||
{
|
||||
++index;
|
||||
|
||||
@ -89,10 +95,10 @@ namespace etl
|
||||
return index;
|
||||
}
|
||||
|
||||
size_t write_index; ///< Where to input new data.
|
||||
size_t read_index; ///< Where to get the oldest data.
|
||||
size_t current_size; ///< The current size of the queue.
|
||||
const size_t MAX_SIZE; ///< The maximum number of items in the queue.
|
||||
size_type write_index; ///< Where to input new data.
|
||||
size_type read_index; ///< Where to get the oldest data.
|
||||
size_type current_size; ///< The current size of the queue.
|
||||
const size_type MAX_SIZE; ///< The maximum number of items in the queue.
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
@ -121,19 +127,26 @@ namespace etl
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type of value that the queue_mpmc_mutex holds.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class iqueue_mpmc_mutex : public queue_mpmc_mutex_base
|
||||
template <typename T, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class iqueue_mpmc_mutex : public queue_mpmc_mutex_base<MEMORY_MODEL>
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef etl::queue_mpmc_mutex_base<MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef size_t size_type; ///< The type used for determining the size of the queue.
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
using base_t::write_index;
|
||||
using base_t::read_index;
|
||||
using base_t::current_size;
|
||||
using base_t::MAX_SIZE;
|
||||
using base_t::get_next_index;
|
||||
|
||||
//*************************************************************************
|
||||
/// Push a value to the queue.
|
||||
@ -199,7 +212,7 @@ namespace etl
|
||||
{
|
||||
access.lock();
|
||||
|
||||
size_t result = (current_size == 0);
|
||||
size_type result = (current_size == 0);
|
||||
|
||||
access.unlock();
|
||||
|
||||
@ -213,7 +226,7 @@ namespace etl
|
||||
{
|
||||
access.lock();
|
||||
|
||||
size_t result = (current_size == MAX_SIZE);
|
||||
size_type result = (current_size == MAX_SIZE);
|
||||
|
||||
access.unlock();
|
||||
|
||||
@ -223,11 +236,11 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items in the queue?
|
||||
//*************************************************************************
|
||||
size_t size() const
|
||||
size_type size() const
|
||||
{
|
||||
access.lock();
|
||||
|
||||
size_t result = current_size;
|
||||
size_type result = current_size;
|
||||
|
||||
access.unlock();
|
||||
|
||||
@ -237,11 +250,11 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How much free space available in the queue.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
size_type available() const
|
||||
{
|
||||
access.lock();
|
||||
|
||||
size_t result = MAX_SIZE - current_size;
|
||||
size_type result = MAX_SIZE - current_size;
|
||||
|
||||
access.unlock();
|
||||
|
||||
@ -254,7 +267,7 @@ namespace etl
|
||||
/// The constructor that is called from derived classes.
|
||||
//*************************************************************************
|
||||
iqueue_mpmc_mutex(T* p_buffer_, size_type max_size_)
|
||||
: queue_mpmc_mutex_base(max_size_),
|
||||
: base_t(max_size_),
|
||||
p_buffer(p_buffer_)
|
||||
{
|
||||
}
|
||||
@ -335,17 +348,24 @@ namespace etl
|
||||
///\ingroup queue_mpmc
|
||||
/// A fixed capacity mpmc queue.
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables.
|
||||
//***************************************************************************
|
||||
template <typename T, size_t SIZE>
|
||||
class queue_mpmc_mutex : public etl::iqueue_mpmc_mutex<T>
|
||||
template <typename T, size_t SIZE, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_mpmc_mutex : public etl::iqueue_mpmc_mutex<T, MEMORY_MODEL>
|
||||
{
|
||||
typedef etl::iqueue_mpmc_mutex<T> base_t;
|
||||
private:
|
||||
|
||||
typedef etl::iqueue_mpmc_mutex<T, MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = SIZE;
|
||||
typedef typename base_t::size_type size_type;
|
||||
|
||||
ETL_STATIC_ASSERT((SIZE <= etl::integral_limits<size_type>::max), "Size too large for memory model");
|
||||
|
||||
static const size_type MAX_SIZE = size_type(SIZE);
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
|
||||
@ -38,16 +38,22 @@ SOFTWARE.
|
||||
#include "alignment.h"
|
||||
#include "parameter_type.h"
|
||||
#include "atomic.h"
|
||||
#include "memory_model.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "47"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_spsc_atomic_base
|
||||
{
|
||||
public:
|
||||
|
||||
/// The type used for determining the size of queue.
|
||||
typedef typename etl::size_type_lookup<MEMORY_MODEL>::type size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// Is the queue empty?
|
||||
/// Accurate from the 'pop' thread.
|
||||
@ -65,7 +71,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool full() const
|
||||
{
|
||||
size_t next_index = get_next_index(write.load(etl::memory_order_acquire), RESERVED);
|
||||
size_type next_index = get_next_index(write.load(etl::memory_order_acquire), RESERVED);
|
||||
|
||||
return (next_index == read.load(etl::memory_order_acquire));
|
||||
}
|
||||
@ -74,12 +80,12 @@ namespace etl
|
||||
/// How many items in the queue?
|
||||
/// Due to concurrency, this is a guess.
|
||||
//*************************************************************************
|
||||
size_t size() const
|
||||
size_type size() const
|
||||
{
|
||||
size_t write_index = write.load(etl::memory_order_acquire);
|
||||
size_t read_index = read.load(etl::memory_order_acquire);
|
||||
size_type write_index = write.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
|
||||
size_t n;
|
||||
size_type n;
|
||||
|
||||
if (write_index >= read_index)
|
||||
{
|
||||
@ -97,7 +103,7 @@ namespace etl
|
||||
/// How much free space available in the queue.
|
||||
/// Due to concurrency, this is a guess.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
size_type available() const
|
||||
{
|
||||
return RESERVED - size() - 1;
|
||||
}
|
||||
@ -105,7 +111,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t capacity() const
|
||||
size_type capacity() const
|
||||
{
|
||||
return RESERVED - 1;
|
||||
}
|
||||
@ -113,14 +119,14 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
size_type max_size() const
|
||||
{
|
||||
return RESERVED - 1;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
queue_spsc_atomic_base(size_t reserved_)
|
||||
queue_spsc_atomic_base(size_type reserved_)
|
||||
: write(0),
|
||||
read(0),
|
||||
RESERVED(reserved_)
|
||||
@ -130,7 +136,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Calculate the next index.
|
||||
//*************************************************************************
|
||||
static size_t get_next_index(size_t index, size_t maximum)
|
||||
static size_type get_next_index(size_type index, size_type maximum)
|
||||
{
|
||||
++index;
|
||||
|
||||
@ -142,9 +148,9 @@ namespace etl
|
||||
return index;
|
||||
}
|
||||
|
||||
etl::atomic_size_t write; ///< Where to input new data.
|
||||
etl::atomic_size_t read; ///< Where to get the oldest data.
|
||||
const size_t RESERVED; ///< The maximum number of items in the queue.
|
||||
etl::atomic<size_type> write; ///< Where to input new data.
|
||||
etl::atomic<size_type> read; ///< Where to get the oldest data.
|
||||
const size_type RESERVED; ///< The maximum number of items in the queue.
|
||||
|
||||
private:
|
||||
|
||||
@ -163,7 +169,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
///\ingroup queue_spsc_atomic
|
||||
///\brief This is the base for all queue_spscs that contain a particular type.
|
||||
@ -175,27 +181,33 @@ namespace etl
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type of value that the queue_spsc_atomic holds.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class iqueue_spsc_atomic : public queue_spsc_atomic_base
|
||||
template <typename T, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class iqueue_spsc_atomic : public queue_spsc_atomic_base<MEMORY_MODEL>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef typename etl::parameter_type<T>::type parameter_t;
|
||||
typedef typename etl::queue_spsc_atomic_base<MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef size_t size_type; ///< The type used for determining the size of the queue.
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
using base_t::write;
|
||||
using base_t::read;
|
||||
using base_t::RESERVED;
|
||||
using base_t::get_next_index;
|
||||
|
||||
//*************************************************************************
|
||||
/// Push a value to the queue.
|
||||
//*************************************************************************
|
||||
bool push(parameter_t value)
|
||||
{
|
||||
size_t write_index = write.load(etl::memory_order_relaxed);
|
||||
size_t next_index = get_next_index(write_index, RESERVED);
|
||||
size_type write_index = write.load(etl::memory_order_relaxed);
|
||||
size_type next_index = get_next_index(write_index, RESERVED);
|
||||
|
||||
if (next_index != read.load(etl::memory_order_acquire))
|
||||
{
|
||||
@ -205,7 +217,7 @@ namespace etl
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Queue is full.
|
||||
return false;
|
||||
}
|
||||
@ -214,16 +226,16 @@ namespace etl
|
||||
/// Pop a value from the queue.
|
||||
//*************************************************************************
|
||||
bool pop(reference value)
|
||||
{
|
||||
size_t read_index = read.load(etl::memory_order_relaxed);
|
||||
|
||||
if (read_index == write.load(etl::memory_order_acquire))
|
||||
{
|
||||
size_type read_index = read.load(etl::memory_order_relaxed);
|
||||
|
||||
if (read_index == write.load(etl::memory_order_acquire))
|
||||
{
|
||||
// Queue is empty
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t next_index = get_next_index(read_index, RESERVED);
|
||||
size_type next_index = get_next_index(read_index, RESERVED);
|
||||
|
||||
value = p_buffer[read_index];
|
||||
p_buffer[read_index].~T();
|
||||
@ -238,7 +250,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool pop()
|
||||
{
|
||||
size_t read_index = read.load(etl::memory_order_relaxed);
|
||||
size_type read_index = read.load(etl::memory_order_relaxed);
|
||||
|
||||
if (read_index == write.load(etl::memory_order_acquire))
|
||||
{
|
||||
@ -246,7 +258,7 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t next_index = get_next_index(read_index, RESERVED);
|
||||
size_type next_index = get_next_index(read_index, RESERVED);
|
||||
|
||||
p_buffer[read_index].~T();
|
||||
|
||||
@ -274,7 +286,7 @@ namespace etl
|
||||
/// The constructor that is called from derived classes.
|
||||
//*************************************************************************
|
||||
iqueue_spsc_atomic(T* p_buffer_, size_type reserved_)
|
||||
: queue_spsc_atomic_base(reserved_),
|
||||
: base_t(reserved_),
|
||||
p_buffer(p_buffer_)
|
||||
{
|
||||
}
|
||||
@ -292,19 +304,30 @@ namespace etl
|
||||
///\ingroup queue_spsc
|
||||
/// A fixed capacity spsc queue.
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables.
|
||||
//***************************************************************************
|
||||
template <typename T, size_t SIZE>
|
||||
class queue_spsc_atomic : public iqueue_spsc_atomic<T>
|
||||
template <typename T, size_t SIZE, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_spsc_atomic : public iqueue_spsc_atomic<T, MEMORY_MODEL>
|
||||
{
|
||||
typedef etl::iqueue_spsc_atomic<T> base_t;
|
||||
private:
|
||||
|
||||
static const size_t RESERVED_SIZE = SIZE + 1;
|
||||
typedef typename etl::iqueue_spsc_atomic<T, MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = SIZE;
|
||||
typedef typename base_t::size_type size_type;
|
||||
|
||||
private:
|
||||
|
||||
static const size_type RESERVED_SIZE = size_type(SIZE + 1);
|
||||
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits<size_type>::max - 1)), "Size too large for memory model");
|
||||
|
||||
static const size_type MAX_SIZE = size_type(SIZE);
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
@ -329,4 +352,4 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -37,13 +37,15 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "alignment.h"
|
||||
#include "parameter_type.h"
|
||||
#include "memory_model.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "46"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <typename T>
|
||||
template <typename T, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_spsc_isr_base
|
||||
{
|
||||
protected:
|
||||
@ -52,10 +54,12 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
/// The type used for determining the size of queue.
|
||||
typedef typename etl::size_type_lookup<MEMORY_MODEL>::type size_type;
|
||||
|
||||
typedef T value_type; ///< The type stored in the queue.
|
||||
typedef T& reference; ///< A reference to the type used in the queue.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef size_t size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
//*************************************************************************
|
||||
/// Push a value to the queue from an ISR.
|
||||
@ -85,7 +89,7 @@ namespace etl
|
||||
/// How much free space available in the queue.
|
||||
/// Called from ISR.
|
||||
//*************************************************************************
|
||||
size_t available_from_isr() const
|
||||
size_type available_from_isr() const
|
||||
{
|
||||
return MAX_SIZE - current_size;
|
||||
}
|
||||
@ -123,7 +127,7 @@ namespace etl
|
||||
/// How many items in the queue?
|
||||
/// Called from ISR.
|
||||
//*************************************************************************
|
||||
size_t size_from_isr() const
|
||||
size_type size_from_isr() const
|
||||
{
|
||||
return current_size;
|
||||
}
|
||||
@ -131,7 +135,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t capacity() const
|
||||
size_type capacity() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
@ -139,7 +143,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items can the queue hold.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
size_type max_size() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
@ -219,7 +223,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Calculate the next index.
|
||||
//*************************************************************************
|
||||
static size_t get_next_index(size_t index, size_t maximum)
|
||||
static size_type get_next_index(size_type index, size_type maximum)
|
||||
{
|
||||
++index;
|
||||
|
||||
@ -266,19 +270,20 @@ namespace etl
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type of value that the queue_spsc_isr holds.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TAccess>
|
||||
class iqueue_spsc_isr : public queue_spsc_isr_base<T>
|
||||
template <typename T, typename TAccess, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class iqueue_spsc_isr : public queue_spsc_isr_base<T, MEMORY_MODEL>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename queue_spsc_isr_base<T>::parameter_t parameter_t;
|
||||
typedef queue_spsc_isr_base<T, MEMORY_MODEL> base_t;
|
||||
typedef typename base_t::parameter_t parameter_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename queue_spsc_isr_base<T>::value_type value_type; ///< The type stored in the queue.
|
||||
typedef typename queue_spsc_isr_base<T>::reference reference; ///< A reference to the type used in the queue.
|
||||
typedef typename queue_spsc_isr_base<T>::const_reference const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef typename queue_spsc_isr_base<T>::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
typedef typename base_t::value_type value_type; ///< The type stored in the queue.
|
||||
typedef typename base_t::reference reference; ///< A reference to the type used in the queue.
|
||||
typedef typename base_t::const_reference const_reference; ///< A const reference to the type used in the queue.
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue.
|
||||
|
||||
//*************************************************************************
|
||||
/// Push a value to the queue.
|
||||
@ -344,7 +349,7 @@ namespace etl
|
||||
{
|
||||
TAccess::lock();
|
||||
|
||||
size_t result = (this->current_size == 0);
|
||||
size_type result = (this->current_size == 0);
|
||||
|
||||
TAccess::unlock();
|
||||
|
||||
@ -358,7 +363,7 @@ namespace etl
|
||||
{
|
||||
TAccess::lock();
|
||||
|
||||
size_t result = (this->current_size == this->MAX_SIZE);
|
||||
size_type result = (this->current_size == this->MAX_SIZE);
|
||||
|
||||
TAccess::unlock();
|
||||
|
||||
@ -368,11 +373,11 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How many items in the queue?
|
||||
//*************************************************************************
|
||||
size_t size() const
|
||||
size_type size() const
|
||||
{
|
||||
TAccess::lock();
|
||||
|
||||
size_t result = this->current_size;
|
||||
size_type result = this->current_size;
|
||||
|
||||
TAccess::unlock();
|
||||
|
||||
@ -382,11 +387,11 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// How much free space available in the queue.
|
||||
//*************************************************************************
|
||||
size_t available() const
|
||||
size_type available() const
|
||||
{
|
||||
TAccess::lock();
|
||||
|
||||
size_t result = this->MAX_SIZE - this->current_size;
|
||||
size_type result = this->MAX_SIZE - this->current_size;
|
||||
|
||||
TAccess::unlock();
|
||||
|
||||
@ -399,7 +404,7 @@ namespace etl
|
||||
/// The constructor that is called from derived classes.
|
||||
//*************************************************************************
|
||||
iqueue_spsc_isr(T* p_buffer_, size_type max_size_)
|
||||
: queue_spsc_isr_base<T>(p_buffer_, max_size_)
|
||||
: base_t(p_buffer_, max_size_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -416,18 +421,25 @@ namespace etl
|
||||
///\ingroup queue_spsc
|
||||
/// A fixed capacity spsc queue.
|
||||
/// This queue supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam TAccess The type that will lock and unlock interrupts.
|
||||
/// \tparam T The type this queue should support.
|
||||
/// \tparam SIZE The maximum capacity of the queue.
|
||||
/// \tparam TAccess The type that will lock and unlock interrupts.
|
||||
/// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables.
|
||||
//***************************************************************************
|
||||
template <typename T, size_t SIZE, typename TAccess>
|
||||
class queue_spsc_isr : public etl::iqueue_spsc_isr<T, TAccess>
|
||||
template <typename T, size_t SIZE, typename TAccess, const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class queue_spsc_isr : public etl::iqueue_spsc_isr<T, TAccess, MEMORY_MODEL>
|
||||
{
|
||||
typedef etl::iqueue_spsc_isr<T, TAccess> base_t;
|
||||
private:
|
||||
|
||||
typedef etl::iqueue_spsc_isr<T, TAccess, MEMORY_MODEL> base_t;
|
||||
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = SIZE;
|
||||
typedef typename base_t::size_type size_type;
|
||||
|
||||
ETL_STATIC_ASSERT((SIZE <= etl::integral_limits<size_type>::max), "Size too large for memory model");
|
||||
|
||||
static const size_type MAX_SIZE = size_type(SIZE);
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
|
||||
@ -329,19 +329,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
/// How to compare elements and keys.
|
||||
//*********************************************************************
|
||||
class compare
|
||||
class Compare
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -690,7 +692,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(key_parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, compare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -700,7 +702,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, compare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -710,7 +712,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(key_parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -720,7 +722,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -730,9 +732,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare());
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -742,9 +744,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare());
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -835,7 +837,7 @@ namespace etl
|
||||
result.first = i_element;
|
||||
|
||||
// Existing element?
|
||||
if (value.first != i_element->first)
|
||||
if (TKeyCompare()(value.first, i_element->first) || TKeyCompare()(i_element->first, value.first))
|
||||
{
|
||||
// A new one.
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_map_full));
|
||||
@ -855,6 +857,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
Compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -304,19 +304,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
/// How to compare elements and keys.
|
||||
//*********************************************************************
|
||||
class compare
|
||||
class Compare
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -612,7 +614,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(key_parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, compare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -622,7 +624,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, compare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -632,7 +634,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(key_parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -642,7 +644,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -652,9 +654,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare());
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -664,9 +666,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare());
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -768,6 +770,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
Compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -460,9 +460,9 @@ namespace etl
|
||||
{
|
||||
std::pair<iterator, bool> result(end(), false);
|
||||
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full));
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, compare);
|
||||
|
||||
if (i_element == end())
|
||||
{
|
||||
@ -566,7 +566,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -590,7 +590,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -626,7 +626,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -636,7 +636,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -646,7 +646,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -656,7 +656,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -666,7 +666,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(parameter_t key)
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -676,7 +676,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -783,6 +783,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -546,7 +546,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -570,7 +570,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -604,7 +604,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -614,7 +614,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -624,7 +624,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -634,7 +634,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -644,7 +644,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(parameter_t key)
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -654,7 +654,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -745,7 +745,7 @@ namespace etl
|
||||
result.first = i_element;
|
||||
|
||||
// Existing element?
|
||||
if (value != *i_element)
|
||||
if (compare(value, *i_element) || compare(*i_element, value))
|
||||
{
|
||||
// A new one.
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_set_full));
|
||||
@ -765,6 +765,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -446,7 +446,7 @@ namespace etl
|
||||
size_type current_size; ///< The number of the used nodes.
|
||||
const size_type CAPACITY; ///< The maximum size of the set.
|
||||
Node* root_node; ///< The node that acts as the set root.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
};
|
||||
|
||||
@ -454,7 +454,7 @@ namespace etl
|
||||
/// A templated base for all etl::set types.
|
||||
///\ingroup set
|
||||
//***************************************************************************
|
||||
template <typename T, typename TCompare>
|
||||
template <typename T, typename TCompare = std::less<T> >
|
||||
class iset : public etl::set_base
|
||||
{
|
||||
public:
|
||||
@ -474,7 +474,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -485,7 +485,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return value_compare()(value1, value2);
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -512,17 +512,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value, node2.value);
|
||||
return compare(node1.value, node2.value);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value, key);
|
||||
return compare(node.value, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
|
||||
{
|
||||
return key_compare()(key, node.value);
|
||||
return compare(key, node.value);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -530,6 +530,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the set.
|
||||
etl::ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
@ -1185,7 +1187,7 @@ namespace etl
|
||||
{
|
||||
Data_Node& node = *p_node_pool->allocate<Data_Node>();
|
||||
::new ((void*)&node.value) value_type(value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -1196,7 +1198,7 @@ namespace etl
|
||||
{
|
||||
node.value.~value_type();
|
||||
p_node_pool->release(&node);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -180,7 +180,7 @@ namespace etl
|
||||
void add_in()
|
||||
{
|
||||
top_index = current_size++;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -190,7 +190,7 @@ namespace etl
|
||||
{
|
||||
--top_index;
|
||||
--current_size;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -200,13 +200,13 @@ namespace etl
|
||||
{
|
||||
top_index = 0;
|
||||
current_size = 0;
|
||||
ETL_RESET_DEBUG_COUNT;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
|
||||
size_type top_index; ///< The index of the top of the stack.
|
||||
size_type current_size; ///< The number of items in the stack.
|
||||
const size_type CAPACITY; ///< The maximum number of items in the stack.
|
||||
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
|
||||
ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -34,6 +34,7 @@ SOFTWARE.
|
||||
#include "../../platform.h"
|
||||
#include "../../type_traits.h"
|
||||
#include "../../char_traits.h"
|
||||
#include "../../integral_limits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -40,4 +40,4 @@ SOFTWARE.
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -659,7 +659,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key_value_pair) value_type(key, T());
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
pbucket->insert_after(pbucket->before_begin(), node);
|
||||
|
||||
@ -781,15 +781,13 @@ namespace etl
|
||||
bucket_t* pbucket = pbuckets + index;
|
||||
bucket_t& bucket = *pbucket;
|
||||
|
||||
size_t s = pbuckets->size();
|
||||
|
||||
// The first one in the bucket?
|
||||
if (bucket.empty())
|
||||
{
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key_value_pair) value_type(key_value_pair);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Just add the pointer to the bucket;
|
||||
bucket.insert_after(bucket.before_begin(), node);
|
||||
@ -823,7 +821,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key_value_pair) value_type(key_value_pair);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Add the node to the end of the bucket;
|
||||
bucket.insert_after(inode_previous, node);
|
||||
@ -843,7 +841,7 @@ namespace etl
|
||||
///\param position The position to insert at.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
iterator insert(const_iterator position, const value_type& key_value_pair)
|
||||
iterator insert(const_iterator, const value_type& key_value_pair)
|
||||
{
|
||||
return insert(key_value_pair).first;
|
||||
}
|
||||
@ -893,7 +891,7 @@ namespace etl
|
||||
icurrent->key_value_pair.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
n = 1;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -922,7 +920,7 @@ namespace etl
|
||||
bucket.erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key_value_pair.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
return inext;
|
||||
}
|
||||
@ -957,7 +955,7 @@ namespace etl
|
||||
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key_value_pair.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
icurrent = inext;
|
||||
|
||||
@ -1225,7 +1223,7 @@ namespace etl
|
||||
{
|
||||
// Destroy the value contents.
|
||||
it->key_value_pair.~value_type();
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
++it;
|
||||
}
|
||||
@ -1283,7 +1281,7 @@ namespace etl
|
||||
key_equal key_equal_function;
|
||||
|
||||
/// For library debugging purposes only.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -678,7 +678,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key_value_pair) value_type(key_value_pair);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Just add the pointer to the bucket;
|
||||
bucket.insert_after(bucket.before_begin(), node);
|
||||
@ -708,7 +708,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key_value_pair) value_type(key_value_pair);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Add the node to the end of the bucket;
|
||||
bucket.insert_after(inode_previous, node);
|
||||
@ -726,7 +726,7 @@ namespace etl
|
||||
///\param position The position to insert at.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
iterator insert(const_iterator position, const value_type& key_value_pair)
|
||||
iterator insert(const_iterator, const value_type& key_value_pair)
|
||||
{
|
||||
return insert(key_value_pair);
|
||||
}
|
||||
@ -771,7 +771,7 @@ namespace etl
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
++n;
|
||||
icurrent = iprevious;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -807,7 +807,7 @@ namespace etl
|
||||
bucket.erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key_value_pair.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
return inext;
|
||||
}
|
||||
@ -842,7 +842,7 @@ namespace etl
|
||||
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key_value_pair.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
icurrent = inext;
|
||||
|
||||
@ -1137,7 +1137,7 @@ namespace etl
|
||||
// Destroy the value contents.
|
||||
it->key_value_pair.~value_type();
|
||||
++it;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Now it's safe to clear the bucket.
|
||||
@ -1193,7 +1193,7 @@ namespace etl
|
||||
key_equal key_equal_function;
|
||||
|
||||
/// For library debugging purposes only.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -670,7 +670,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key) value_type(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Just add the pointer to the bucket;
|
||||
bucket.insert_after(bucket.before_begin(), node);
|
||||
@ -701,7 +701,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key) value_type(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Add the node to the end of the bucket;
|
||||
bucket.insert_after(inode_previous, node);
|
||||
@ -765,7 +765,7 @@ namespace etl
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
++n;
|
||||
icurrent = iprevious;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -801,7 +801,7 @@ namespace etl
|
||||
bucket.erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
return inext;
|
||||
}
|
||||
@ -836,7 +836,7 @@ namespace etl
|
||||
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
icurrent = inext;
|
||||
|
||||
@ -1131,7 +1131,7 @@ namespace etl
|
||||
// Destroy the value contents.
|
||||
it->key.~value_type();
|
||||
++it;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Now it's safe to clear the bucket.
|
||||
@ -1187,7 +1187,7 @@ namespace etl
|
||||
key_equal key_equal_function;
|
||||
|
||||
/// For library debugging purposes only.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -671,7 +671,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key) value_type(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Just add the pointer to the bucket;
|
||||
bucket.insert_after(bucket.before_begin(), node);
|
||||
@ -705,7 +705,7 @@ namespace etl
|
||||
// Get a new node.
|
||||
node_t& node = *pnodepool->allocate<node_t>();
|
||||
::new (&node.key) value_type(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
// Add the node to the end of the bucket;
|
||||
bucket.insert_after(inode_previous, node);
|
||||
@ -725,7 +725,7 @@ namespace etl
|
||||
///\param position The position to insert at.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
iterator insert(const_iterator position, const value_type& key)
|
||||
iterator insert(const_iterator, const value_type& key)
|
||||
{
|
||||
return insert(key).first;
|
||||
}
|
||||
@ -775,7 +775,7 @@ namespace etl
|
||||
icurrent->key.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
n = 1;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -804,7 +804,7 @@ namespace etl
|
||||
bucket.erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
return inext;
|
||||
}
|
||||
@ -839,7 +839,7 @@ namespace etl
|
||||
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
|
||||
icurrent->key.~value_type(); // Destroy the value.
|
||||
pnodepool->release(&*icurrent); // Release it back to the pool.
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
|
||||
icurrent = inext;
|
||||
|
||||
@ -1108,7 +1108,7 @@ namespace etl
|
||||
// Destroy the value contents.
|
||||
it->key.~value_type();
|
||||
++it;
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Now it's safe to clear the bucket.
|
||||
@ -1164,7 +1164,7 @@ namespace etl
|
||||
key_equal key_equal_function;
|
||||
|
||||
/// For library debugging purposes only.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
ETL_DECLARE_DEBUG_COUNT
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
|
||||
@ -874,18 +874,18 @@ namespace etl
|
||||
/// Calls the supplied reader instance.
|
||||
/// The 'read' function appropriate to the current type is called with the stored value.
|
||||
//***************************************************************************
|
||||
void call(reader& reader)
|
||||
void call(reader& r)
|
||||
{
|
||||
switch (type_id)
|
||||
{
|
||||
case 0: reader.read(static_cast<T1&>(data)); break;
|
||||
case 1: reader.read(static_cast<T2&>(data)); break;
|
||||
case 2: reader.read(static_cast<T3&>(data)); break;
|
||||
case 3: reader.read(static_cast<T4&>(data)); break;
|
||||
case 4: reader.read(static_cast<T5&>(data)); break;
|
||||
case 5: reader.read(static_cast<T6&>(data)); break;
|
||||
case 6: reader.read(static_cast<T7&>(data)); break;
|
||||
case 7: reader.read(static_cast<T8&>(data)); break;
|
||||
case 0: r.read(static_cast<T1&>(data)); break;
|
||||
case 1: r.read(static_cast<T2&>(data)); break;
|
||||
case 2: r.read(static_cast<T3&>(data)); break;
|
||||
case 3: r.read(static_cast<T4&>(data)); break;
|
||||
case 4: r.read(static_cast<T5&>(data)); break;
|
||||
case 5: r.read(static_cast<T6&>(data)); break;
|
||||
case 6: r.read(static_cast<T7&>(data)); break;
|
||||
case 7: r.read(static_cast<T8&>(data)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ SOFTWARE.
|
||||
#include "alignment.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_lookup.h"
|
||||
#include <pool.h>
|
||||
#include "pool.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "40"
|
||||
|
||||
@ -234,12 +234,12 @@ namespace etl
|
||||
if (current_size < new_size)
|
||||
{
|
||||
etl::uninitialized_fill_n(p_end, delta, value);
|
||||
ETL_ADD_DEBUG_COUNT(delta);
|
||||
ETL_ADD_DEBUG_COUNT(delta)
|
||||
}
|
||||
else
|
||||
{
|
||||
etl::destroy_n(p_end - delta, delta);
|
||||
ETL_SUBTRACT_DEBUG_COUNT(delta);
|
||||
ETL_SUBTRACT_DEBUG_COUNT(delta)
|
||||
}
|
||||
|
||||
p_end = p_buffer + new_size;
|
||||
@ -370,7 +370,7 @@ namespace etl
|
||||
initialise();
|
||||
|
||||
p_end = etl::uninitialized_copy(first, last, p_buffer);
|
||||
ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last)));
|
||||
ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last)))
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -386,7 +386,7 @@ namespace etl
|
||||
initialise();
|
||||
|
||||
p_end = etl::uninitialized_fill_n(p_buffer, n, value);
|
||||
ETL_ADD_DEBUG_COUNT(uint32_t(n));
|
||||
ETL_ADD_DEBUG_COUNT(uint32_t(n))
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -436,7 +436,7 @@ namespace etl
|
||||
#endif
|
||||
::new (p_end) T(value1);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -452,7 +452,7 @@ namespace etl
|
||||
#endif
|
||||
::new (p_end) T(value1, value2);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -468,7 +468,7 @@ namespace etl
|
||||
#endif
|
||||
::new (p_end) T(value1, value2, value3);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -484,7 +484,7 @@ namespace etl
|
||||
#endif
|
||||
::new (p_end) T(value1, value2, value3, value4);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -536,7 +536,7 @@ namespace etl
|
||||
if (position == end())
|
||||
{
|
||||
p = p_end++;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -564,7 +564,7 @@ namespace etl
|
||||
if (position == end())
|
||||
{
|
||||
p = p_end++;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -592,7 +592,7 @@ namespace etl
|
||||
if (position == end())
|
||||
{
|
||||
p = p_end++;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -620,7 +620,7 @@ namespace etl
|
||||
if (position == end())
|
||||
{
|
||||
p = p_end++;
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -673,14 +673,14 @@ namespace etl
|
||||
|
||||
// Construct old.
|
||||
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n)
|
||||
|
||||
// Copy old.
|
||||
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
|
||||
|
||||
// Construct new.
|
||||
etl::uninitialized_fill_n(p_end, construct_new_n, value);
|
||||
ETL_ADD_DEBUG_COUNT(construct_new_n);
|
||||
ETL_ADD_DEBUG_COUNT(construct_new_n)
|
||||
|
||||
// Copy new.
|
||||
std::fill_n(p_buffer + insert_begin, copy_new_n, value);
|
||||
@ -730,14 +730,14 @@ namespace etl
|
||||
|
||||
// Construct old.
|
||||
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n)
|
||||
|
||||
// Copy old.
|
||||
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
|
||||
|
||||
// Construct new.
|
||||
etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end);
|
||||
ETL_ADD_DEBUG_COUNT(construct_new_n);
|
||||
ETL_ADD_DEBUG_COUNT(construct_new_n)
|
||||
|
||||
// Copy new.
|
||||
etl::copy_n(first, copy_new_n, p_buffer + insert_begin);
|
||||
@ -779,7 +779,7 @@ namespace etl
|
||||
|
||||
// Destroy the elements left over at the end.
|
||||
etl::destroy(p_end - n_delete, p_end);
|
||||
ETL_SUBTRACT_DEBUG_COUNT(n_delete);
|
||||
ETL_SUBTRACT_DEBUG_COUNT(n_delete)
|
||||
p_end -= n_delete;
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ namespace etl
|
||||
void initialise()
|
||||
{
|
||||
etl::destroy(p_buffer, p_end);
|
||||
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end)));
|
||||
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end)))
|
||||
|
||||
p_end = p_buffer;
|
||||
}
|
||||
@ -886,7 +886,7 @@ namespace etl
|
||||
inline void create_back()
|
||||
{
|
||||
etl::create_value_at(p_end);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
++p_end;
|
||||
}
|
||||
@ -897,7 +897,7 @@ namespace etl
|
||||
inline void create_back(parameter_t value)
|
||||
{
|
||||
etl::create_copy_at(p_end, value);
|
||||
ETL_INCREMENT_DEBUG_COUNT;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
++p_end;
|
||||
}
|
||||
@ -910,7 +910,7 @@ namespace etl
|
||||
--p_end;
|
||||
|
||||
etl::destroy_at(p_end);
|
||||
ETL_DECREMENT_DEBUG_COUNT;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
// Disable copy construction.
|
||||
|
||||
@ -37,10 +37,14 @@ SOFTWARE.
|
||||
/// Definitions of the ETL version
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION "11.12.0"
|
||||
#define ETL_VERSION "11.15.1"
|
||||
#define ETL_VERSION_W L"11.15.1"
|
||||
#define ETL_VERSION_U16 u"11.15.1"
|
||||
#define ETL_VERSION_U32 U"11.15.1"
|
||||
#define ETL_VERSION_MAJOR 11
|
||||
#define ETL_VERSION_MINOR 12
|
||||
#define ETL_VERSION_MINOR 15
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ name=Embedded Template Library
|
||||
version=10.21.2
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
sentence=A C++ template library tailored for embedded systems.
|
||||
paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/ or https://github.com/mike-matera/ArduinoSTL.git for Arduino.
|
||||
category=Other
|
||||
|
||||
@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include "binary.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/binary.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -30,8 +30,8 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/static_assert.h"
|
||||
|
||||
ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
|
||||
|
||||
|
||||
@ -28,9 +28,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include "error_handler.h"
|
||||
#include "nullptr.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/error_handler.h"
|
||||
#include "etl/nullptr.h"
|
||||
|
||||
//*****************************************************************************
|
||||
/// The error function callback pointer.
|
||||
|
||||
@ -30,8 +30,8 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/static_assert.h"
|
||||
|
||||
ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
|
||||
|
||||
|
||||
@ -31,6 +31,462 @@ SOFTWARE.
|
||||
#include "../../include/etl/platform.h"
|
||||
#include "../../include/etl/private/pvoidvector.h"
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an iterator to the beginning of the vector.
|
||||
///\return An iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::iterator etl::pvoidvector::begin()
|
||||
{
|
||||
return p_buffer;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the beginning of the vector.
|
||||
///\return A const iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_iterator etl::pvoidvector::begin() const
|
||||
{
|
||||
return const_iterator(p_buffer);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an iterator to the end of the vector.
|
||||
///\return An iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::iterator etl::pvoidvector::end()
|
||||
{
|
||||
return p_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the end of the vector.
|
||||
///\return A const iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_iterator etl::pvoidvector::end() const
|
||||
{
|
||||
return const_iterator(p_end);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the beginning of the vector.
|
||||
///\return A const iterator to the beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_iterator etl::pvoidvector::cbegin() const
|
||||
{
|
||||
return const_iterator(p_buffer);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const_iterator to the end of the vector.
|
||||
///\return A const iterator to the end of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_iterator etl::pvoidvector::cend() const
|
||||
{
|
||||
return const_iterator(p_end);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns an reverse iterator to the reverse beginning of the vector.
|
||||
///\return Iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reverse_iterator etl::pvoidvector::rbegin()
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the vector.
|
||||
///\return Const iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reverse_iterator etl::pvoidvector::rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reverse iterator to the end + 1 of the vector.
|
||||
///\return Reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reverse_iterator etl::pvoidvector::rend()
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the end + 1 of the vector.
|
||||
///\return Const reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reverse_iterator etl::pvoidvector::rend() const
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the vector.
|
||||
///\return Const reverse iterator to the reverse beginning of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reverse_iterator etl::pvoidvector::crbegin() const
|
||||
{
|
||||
return const_reverse_iterator(cend());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reverse iterator to the end + 1 of the vector.
|
||||
///\return Const reverse iterator to the end + 1 of the vector.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reverse_iterator etl::pvoidvector::crend() const
|
||||
{
|
||||
return const_reverse_iterator(cbegin());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the vector.
|
||||
/// If asserts or exceptions are enabled and the new size is larger than the
|
||||
/// maximum then a vector_full is thrown.
|
||||
///\param new_size The new size.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::resize(size_t new_size)
|
||||
{
|
||||
ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
p_end = p_buffer + new_size;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the vector.
|
||||
/// If asserts or exceptions are enabled and the new size is larger than the
|
||||
/// maximum then a vector_full is thrown.
|
||||
///\param new_size The new size.
|
||||
///\param value The value to fill new elements with. Default = default constructed value.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::resize(size_t new_size, etl::pvoidvector::value_type value)
|
||||
{
|
||||
ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
pointer p_new_end = p_buffer + new_size;
|
||||
|
||||
// Size up if necessary.
|
||||
if (p_end < p_new_end)
|
||||
{
|
||||
std::fill(p_end, p_new_end, value);
|
||||
}
|
||||
|
||||
p_end = p_new_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the value at index 'i'
|
||||
///\param i The index.
|
||||
///\return A reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reference etl::pvoidvector::operator [](size_t i)
|
||||
{
|
||||
return reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the value at index 'i'
|
||||
///\param i The index.
|
||||
///\return A const reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reference etl::pvoidvector::operator [](size_t i) const
|
||||
{
|
||||
return const_reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the value at index 'i'
|
||||
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
|
||||
///\param i The index.
|
||||
///\return A reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reference etl::pvoidvector::at(size_t i)
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the value at index 'i'
|
||||
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
|
||||
///\param i The index.
|
||||
///\return A const reference to the value at index 'i'
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reference etl::pvoidvector::at(size_t i) const
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return const_reference(p_buffer[i]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the first element.
|
||||
///\return A reference to the first element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reference etl::pvoidvector::front()
|
||||
{
|
||||
return reference(p_buffer[0]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
///\return A const reference to the first element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reference etl::pvoidvector::front() const
|
||||
{
|
||||
return const_reference(p_buffer[0]);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a reference to the last element.
|
||||
///\return A reference to the last element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::reference etl::pvoidvector::back()
|
||||
{
|
||||
return reference(*(p_end - 1));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const reference to the last element.
|
||||
///\return A const reference to the last element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_reference etl::pvoidvector::back() const
|
||||
{
|
||||
return const_reference(*(p_end - 1));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a pointer to the beginning of the vector data.
|
||||
///\return A pointer to the beginning of the vector data.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::pointer etl::pvoidvector::data()
|
||||
{
|
||||
return pointer(p_buffer);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const pointer to the beginning of the vector data.
|
||||
///\return A const pointer to the beginning of the vector data.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::const_pointer etl::pvoidvector::data() const
|
||||
{
|
||||
return const_pointer(p_buffer);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
|
||||
///\param n The number of elements to add.
|
||||
///\param value The value to insert for each element.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::assign(size_t n, etl::pvoidvector::value_type value)
|
||||
{
|
||||
initialise();
|
||||
|
||||
ETL_ASSERT(n <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
for (size_t current_size = 0; current_size < n; ++current_size)
|
||||
{
|
||||
*p_end++ = value;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Clears the vector.
|
||||
//*************************************************************************
|
||||
void etl::pvoidvector::clear()
|
||||
{
|
||||
initialise();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Increases the size of the vector by one, but does not initialise the new element.
|
||||
/// If asserts or exceptions are enabled, throws a vector_full if the vector is already full.
|
||||
//*************************************************************************
|
||||
void etl::pvoidvector::push_back()
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
#endif
|
||||
|
||||
++p_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value at the end of the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::push_back(etl::pvoidvector::value_type value)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
#endif
|
||||
*p_end++ = value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes an element from the end of the vector.
|
||||
/// Does nothing if the vector is empty.
|
||||
//*************************************************************************
|
||||
void etl::pvoidvector::pop_back()
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() > 0, ETL_ERROR(vector_empty));
|
||||
#endif
|
||||
--p_end;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param position The position to insert before.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::iterator etl::pvoidvector::insert(etl::pvoidvector::iterator position, etl::pvoidvector::value_type value)
|
||||
{
|
||||
ETL_ASSERT(size() + 1 <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
if (position != end())
|
||||
{
|
||||
++p_end;
|
||||
std::copy_backward(position, end() - 1, end());
|
||||
*position = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_end++ = value;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts 'n' values to the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
|
||||
///\param position The position to insert before.
|
||||
///\param n The number of elements to add.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::insert(etl::pvoidvector::iterator position, size_t n, etl::pvoidvector::value_type value)
|
||||
{
|
||||
ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
std::copy_backward(position, p_end, p_end + n);
|
||||
std::fill_n(position, n, value);
|
||||
|
||||
p_end += n;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param i_element Iterator to the element.
|
||||
///\return An iterator pointing to the element that followed the erased element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::iterator etl::pvoidvector::erase(etl::pvoidvector::iterator i_element)
|
||||
{
|
||||
std::copy(i_element + 1, end(), i_element);
|
||||
--p_end;
|
||||
|
||||
return i_element;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// The range includes all the elements between first and last, including the
|
||||
/// element pointed by first, but not the one pointed by last.
|
||||
///\param first Iterator to the first element.
|
||||
///\param last Iterator to the last element.
|
||||
///\return An iterator pointing to the element that followed the erased element.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::iterator etl::pvoidvector::erase(etl::pvoidvector::iterator first, etl::pvoidvector::iterator last)
|
||||
{
|
||||
std::copy(last, end(), first);
|
||||
size_t n_delete = std::distance(first, last);
|
||||
|
||||
// Just adjust the count.
|
||||
p_end -= n_delete;
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
etl::pvoidvector& etl::pvoidvector::operator = (const etl::pvoidvector& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
assign(rhs.cbegin(), rhs.cend());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current size of the vector.
|
||||
///\return The current size of the vector.
|
||||
//*************************************************************************
|
||||
etl::pvoidvector::size_type etl::pvoidvector::size() const
|
||||
{
|
||||
return size_t(p_end - p_buffer);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks the 'empty' state of the vector.
|
||||
///\return <b>true</b> if empty.
|
||||
//*************************************************************************
|
||||
bool etl::pvoidvector::empty() const
|
||||
{
|
||||
return (p_end == p_buffer);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks the 'full' state of the vector.
|
||||
///\return <b>true</b> if full.
|
||||
//*************************************************************************
|
||||
bool etl::pvoidvector::full() const
|
||||
{
|
||||
return size() == CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
//*************************************************************************
|
||||
size_t etl::pvoidvector::available() const
|
||||
{
|
||||
return max_size() - size();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Constructor.
|
||||
//*********************************************************************
|
||||
etl::pvoidvector::pvoidvector(void** p_buffer_, size_t MAX_SIZE)
|
||||
: vector_base(MAX_SIZE),
|
||||
p_buffer(p_buffer_),
|
||||
p_end(p_buffer_)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Initialise the vector.
|
||||
//*********************************************************************
|
||||
void etl::pvoidvector::initialise()
|
||||
{
|
||||
p_end = p_buffer;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void etl::pvoidvector::repair(void** p_buffer_)
|
||||
{
|
||||
uintptr_t length = p_end - p_buffer;
|
||||
|
||||
p_buffer = p_buffer_;
|
||||
p_end = p_buffer_ + length;
|
||||
}
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include "random.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/random.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -1,3 +1,57 @@
|
||||
===============================================================================
|
||||
11.15.1
|
||||
io_port_test Fixed unaligned access error.
|
||||
debug_count Removed typed += & -= operators and replaced with templates.
|
||||
|
||||
===============================================================================
|
||||
11.15.0
|
||||
Added 'memory model' selection for queues to allow more efficient implementations.
|
||||
|
||||
Maximum queue sizes:
|
||||
MEMORY_MODEL_SMALL 255 (254 for queue_spsc_atomic)
|
||||
MEMORY_MODEL_MEDIUM 65535
|
||||
MEMORY_MODEL_LARGE 2147483647
|
||||
MEMORY_MODEL_HUGE 9223372036854775807
|
||||
|
||||
Fixed syntax errors highlighted by GCC v8
|
||||
|
||||
===============================================================================
|
||||
11.14.2
|
||||
Removed reference_flat_set & reference_flat_map reliance on equality.
|
||||
|
||||
===============================================================================
|
||||
11.14.1
|
||||
Removed flat_set & flat_map reliance on equality.
|
||||
|
||||
===============================================================================
|
||||
11.14.0
|
||||
Added tests for limited support for self insert for strings.
|
||||
Added 'wipe_on_destruct' template class for secure wiping of objects on destruction.
|
||||
Updated unique_ptr API.
|
||||
|
||||
===============================================================================
|
||||
11.13.2
|
||||
Protected destructor for some FSM classes.
|
||||
Observer's remove_observer returns bool.
|
||||
|
||||
===============================================================================
|
||||
11.13.1
|
||||
Fixed vector of pointer typedefs
|
||||
|
||||
===============================================================================
|
||||
11.13.0
|
||||
Added specialisation for vector<const T*>
|
||||
|
||||
===============================================================================
|
||||
11.12.2
|
||||
Remove SFINAE from array_view.
|
||||
Added default etl::less compare type appropriate map and set classes.
|
||||
Moved non-template code in pvoidvector to cpp file.
|
||||
|
||||
===============================================================================
|
||||
11.12.1
|
||||
Made atomic load const for non STL vesions
|
||||
|
||||
===============================================================================
|
||||
11.12.0
|
||||
Renamed STATIC_ASSERT to ETL_STATIC_ASSERT
|
||||
|
||||
@ -61,18 +61,18 @@
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wshadow" />
|
||||
<Add option="-Wundef" />
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-Wunused-parameter" />
|
||||
<Add option="-Wstrict-aliasing" />
|
||||
<Add option="-Wshadow" />
|
||||
<Add option="-Wundef" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-fexceptions" />
|
||||
<Add directory="../../../unittest-cpp/UnitTest++/" />
|
||||
<Add directory="../../src" />
|
||||
<Add directory="../" />
|
||||
<Add directory="../../src/c" />
|
||||
<Add directory="../../include/etl" />
|
||||
<Add directory="../../include" />
|
||||
</Compiler>
|
||||
<Unit filename="../../../unittest-cpp/UnitTest++/AssertException.cpp" />
|
||||
<Unit filename="../../../unittest-cpp/UnitTest++/AssertException.h" />
|
||||
@ -406,9 +406,13 @@
|
||||
<Unit filename="../test_pool.cpp" />
|
||||
<Unit filename="../test_priority_queue.cpp" />
|
||||
<Unit filename="../test_queue.cpp" />
|
||||
<Unit filename="../test_queue_memory_model_small.cpp" />
|
||||
<Unit filename="../test_queue_mpmc_mutex.cpp" />
|
||||
<Unit filename="../test_queue_mpmc_mutex_small.cpp" />
|
||||
<Unit filename="../test_queue_spsc_atomic.cpp" />
|
||||
<Unit filename="../test_queue_spsc_atomic_small.cpp" />
|
||||
<Unit filename="../test_queue_spsc_isr.cpp" />
|
||||
<Unit filename="../test_queue_spsc_isr_small.cpp" />
|
||||
<Unit filename="../test_random.cpp" />
|
||||
<Unit filename="../test_reference_flat_map.cpp" />
|
||||
<Unit filename="../test_reference_flat_multimap.cpp" />
|
||||
|
||||
@ -31,7 +31,7 @@ SOFTWARE.
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "instance_count.h"
|
||||
#include "etl/instance_count.h"
|
||||
|
||||
//*****************************************************************************
|
||||
// Default constructor.
|
||||
|
||||
@ -77,9 +77,9 @@ SOFTWARE.
|
||||
//#define ETL_NO_STL
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "profiles/msvc_x86.h"
|
||||
#include "etl/profiles/msvc_x86.h"
|
||||
#else
|
||||
#include "profiles/gcc_windows_x86.h"
|
||||
#include "etl/profiles/gcc_windows_x86.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
// compile and run any of them on any platform, but your performance with the
|
||||
// non-native version will be less than optimal.
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
#ifdef ETL_COMPILER_GCC
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
// Microsoft Visual Studio
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
#if defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER < 1600)
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "container.h"
|
||||
#include "etl/algorithm.h"
|
||||
#include "etl/container.h"
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "alignment.h"
|
||||
#include "type_traits.h"
|
||||
#include "etl/alignment.h"
|
||||
#include "etl/type_traits.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
@ -28,13 +28,13 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "array.h"
|
||||
#include "etl/array.h"
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include "integral_limits.h"
|
||||
#include "etl/integral_limits.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "array_view.h"
|
||||
#include "array.h"
|
||||
#include "etl/array_view.h"
|
||||
#include "etl/array.h"
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
@ -28,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "array_wrapper.h"
|
||||
#include "etl/array_wrapper.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "atomic/atomic_std.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/atomic/atomic_std.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "atomic/atomic_std.h"
|
||||
#include "etl/platform.h"
|
||||
#include "etl/atomic/atomic_std.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
||||
@ -31,10 +31,10 @@ SOFTWARE.
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
#include "binary.h"
|
||||
#include "bitset.h"
|
||||
#include "fnv_1.h"
|
||||
#include "integral_limits.h"
|
||||
#include "etl/binary.h"
|
||||
#include "etl/bitset.h"
|
||||
#include "etl/fnv_1.h"
|
||||
#include "etl/integral_limits.h"
|
||||
|
||||
// Count bits the easy way.
|
||||
template <typename T>
|
||||
|
||||
@ -32,7 +32,7 @@ SOFTWARE.
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
|
||||
#include "bitset.h"
|
||||
#include "etl/bitset.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -31,14 +31,14 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
|
||||
#include "bloom_filter.h"
|
||||
#include "etl/bloom_filter.h"
|
||||
|
||||
#include "fnv_1.h"
|
||||
#include "crc16.h"
|
||||
#include "crc16_ccitt.h"
|
||||
#include "crc32.h"
|
||||
#include "etl/fnv_1.h"
|
||||
#include "etl/crc16.h"
|
||||
#include "etl/crc16_ccitt.h"
|
||||
#include "etl/crc32.h"
|
||||
|
||||
#include "char_traits.h"
|
||||
#include "etl/char_traits.h"
|
||||
|
||||
struct hash1_t
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "checksum.h"
|
||||
#include "etl/checksum.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include "ExtraCheckMacros.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "etl/platform.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
@ -29,8 +29,8 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include "ExtraCheckMacros.h"
|
||||
|
||||
#include "callback_timer.h"
|
||||
#include "function.h"
|
||||
#include "etl/callback_timer.h"
|
||||
#include "etl/function.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
@ -33,7 +33,7 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "checksum.h"
|
||||
#include "etl/checksum.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "compare.h"
|
||||
#include "etl/compare.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "constant.h"
|
||||
#include "integral_limits.h"
|
||||
#include "etl/constant.h"
|
||||
#include "etl/integral_limits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <type_traits>
|
||||
|
||||
@ -28,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "container.h"
|
||||
#include "etl/container.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
@ -33,12 +33,12 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "crc8_ccitt.h"
|
||||
#include "crc16.h"
|
||||
#include "crc16_ccitt.h"
|
||||
#include "crc16_kermit.h"
|
||||
#include "crc32.h"
|
||||
#include "crc64_ecma.h"
|
||||
#include "etl/crc8_ccitt.h"
|
||||
#include "etl/crc16.h"
|
||||
#include "etl/crc16_ccitt.h"
|
||||
#include "etl/crc16_kermit.h"
|
||||
#include "etl/crc32.h"
|
||||
#include "etl/crc64_ecma.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "cyclic_value.h"
|
||||
#include "etl/cyclic_value.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++.h"
|
||||
|
||||
#include "debounce.h"
|
||||
#include "etl/debounce.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include "ExtraCheckMacros.h"
|
||||
|
||||
#include "deque.h"
|
||||
#include "etl/deque.h"
|
||||
|
||||
#include "data.h"
|
||||
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "alignment.h"
|
||||
#include "array.h"
|
||||
#include "bitset.h"
|
||||
#include "container.h"
|
||||
#include "crc8_ccitt.h"
|
||||
#include "crc16.h"
|
||||
#include "crc16_ccitt.h"
|
||||
#include "crc16_kermit.h"
|
||||
#include "crc32.h"
|
||||
#include "crc64_ecma.h"
|
||||
#include "cyclic_value.h"
|
||||
#include "deque.h"
|
||||
#include "io_port.h"
|
||||
#include "vector.h"
|
||||
#include "variant.h"
|
||||
#include "list.h"
|
||||
#include "map.h"
|
||||
#include "integral_limits.h"
|
||||
#include "constant.h"
|
||||
#include "etl/algorithm.h"
|
||||
#include "etl/alignment.h"
|
||||
#include "etl/array.h"
|
||||
#include "etl/bitset.h"
|
||||
#include "etl/container.h"
|
||||
#include "etl/crc8_ccitt.h"
|
||||
#include "etl/crc16.h"
|
||||
#include "etl/crc16_ccitt.h"
|
||||
#include "etl/crc16_kermit.h"
|
||||
#include "etl/crc32.h"
|
||||
#include "etl/crc64_ecma.h"
|
||||
#include "etl/cyclic_value.h"
|
||||
#include "etl/deque.h"
|
||||
#include "etl/io_port.h"
|
||||
#include "etl/vector.h"
|
||||
#include "etl/variant.h"
|
||||
#include "etl/list.h"
|
||||
#include "etl/map.h"
|
||||
#include "etl/integral_limits.h"
|
||||
#include "etl/constant.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if !defined(ETL_COMPILER_IAR) & !defined(ETL_COMPILER_TI)
|
||||
#include "stm32f4xx.h"
|
||||
#include "etl/stm32f4xx.h"
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include <string>
|
||||
|
||||
#include "endianness.h"
|
||||
#include "etl/endianness.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include <string>
|
||||
|
||||
#include "enum_type.h"
|
||||
#include "etl/enum_type.h"
|
||||
|
||||
struct enum_test
|
||||
{
|
||||
|
||||
@ -33,8 +33,8 @@ SOFTWARE.
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "etl/error_handler.h"
|
||||
#include "etl/exception.h"
|
||||
|
||||
bool error_received;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include <string>
|
||||
|
||||
#include "exception.h"
|
||||
#include "etl/exception.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include "UnitTest++.h"
|
||||
#include "ExtraCheckMacros.h"
|
||||
|
||||
#include "factory.h"
|
||||
#include "etl/factory.h"
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#include "fixed_iterator.h"
|
||||
#include "etl/fixed_iterator.h"
|
||||
|
||||
template <typename TIterator>
|
||||
std::ostream& operator << (std::ostream& os, const etl::fixed_iterator<TIterator>& fi)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user