Commit 0d8eed32 authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent db31bdad
...@@ -43,39 +43,30 @@ class NasListT1 ...@@ -43,39 +43,30 @@ class NasListT1
public: public:
void add(const T &item) void add(const T &item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
remove(item); remove(item);
makeSlotForNewItem(); makeSlotForNewItem();
m_data[m_size] = item; m_data[m_size] = item;
m_size++; m_size++;
touch();
} }
void add(T &&item) void add(T &&item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
remove(item); remove(item);
makeSlotForNewItem(); makeSlotForNewItem();
m_data[m_size] = std::move(item); m_data[m_size] = std::move(item);
m_size++; m_size++;
}
bool contains(const T &item)
{
autoClearIfNecessary();
for (size_t i = 0; i < m_size; i++) touch();
if (m_data[i] == item)
return true;
return false;
} }
void remove(const T &item) void remove(const T &item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
size_t index = ~0u; size_t index = ~0u;
...@@ -92,6 +83,16 @@ class NasListT1 ...@@ -92,6 +83,16 @@ class NasListT1
removeAt(index); removeAt(index);
} }
bool contains(const T &item)
{
autoClearIfNecessary();
for (size_t i = 0; i < m_size; i++)
if (m_data[i] == item)
return true;
return false;
}
template <typename Functor> template <typename Functor>
void forEach(Functor &&fun) void forEach(Functor &&fun)
{ {
...@@ -104,24 +105,24 @@ class NasListT1 ...@@ -104,24 +105,24 @@ class NasListT1
template <typename Functor> template <typename Functor>
void mutateForEach(Functor &&fun) void mutateForEach(Functor &&fun)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
for (size_t i = 0; i < m_size; i++) for (size_t i = 0; i < m_size; i++)
fun(m_data[i]); fun(m_data[i]);
touch();
} }
void clear() void clear()
{ {
touch();
int64_t currentTime = ::utils::CurrentTimeMillis(); int64_t currentTime = ::utils::CurrentTimeMillis();
if (currentTime - m_lastAutoCleared >= m_autoClearingPeriod) if (currentTime - m_lastAutoCleared >= m_autoClearingPeriod)
m_lastAutoCleared = currentTime; m_lastAutoCleared = currentTime;
m_data.clear(); m_data.clear();
m_size = 0; m_size = 0;
touch();
} }
[[nodiscard]] size_t size() const [[nodiscard]] size_t size() const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment