aboutsummaryrefslogtreecommitdiff
path: root/EASTL/include/EASTL/slist.h
diff options
context:
space:
mode:
Diffstat (limited to 'EASTL/include/EASTL/slist.h')
-rw-r--r--EASTL/include/EASTL/slist.h40
1 files changed, 28 insertions, 12 deletions
diff --git a/EASTL/include/EASTL/slist.h b/EASTL/include/EASTL/slist.h
index 1dbb44f..dc3c447 100644
--- a/EASTL/include/EASTL/slist.h
+++ b/EASTL/include/EASTL/slist.h
@@ -353,10 +353,10 @@ namespace eastl
void clear() EA_NOEXCEPT;
void reset_lose_memory() EA_NOEXCEPT; // This is a unilateral reset to an initially empty state. No destructors are called, no deallocation occurs.
- void remove(const value_type& value);
+ size_type remove(const value_type& value);
template <typename Predicate>
- void remove_if(Predicate predicate);
+ size_type remove_if(Predicate predicate);
void reverse() EA_NOEXCEPT;
@@ -1249,32 +1249,42 @@ namespace eastl
template <typename T, typename Allocator>
- void slist<T, Allocator>::remove(const value_type& value)
+ typename slist<T, Allocator>::size_type slist<T, Allocator>::remove(const value_type& value)
{
base_node_type* pNode = &internalNode();
+ size_type numErased = 0;
while(pNode && pNode->mpNext)
{
- if(static_cast<node_type*>(pNode->mpNext)->mValue == value)
+ if (static_cast<node_type*>(pNode->mpNext)->mValue == value)
+ {
DoEraseAfter((SListNodeBase*)pNode); // This will take care of modifying pNode->mpNext.
+ ++numErased;
+ }
else
pNode = pNode->mpNext;
}
+ return numErased;
}
template <typename T, typename Allocator>
template <typename Predicate>
- void slist<T, Allocator>::remove_if(Predicate predicate)
+ inline typename slist<T, Allocator>::size_type slist<T, Allocator>::remove_if(Predicate predicate)
{
base_node_type* pNode = &internalNode();
+ size_type numErased = 0;
while(pNode && pNode->mpNext)
{
- if(predicate(static_cast<node_type*>(pNode->mpNext)->mValue))
+ if (predicate(static_cast<node_type*>(pNode->mpNext)->mValue))
+ {
DoEraseAfter((SListNodeBase*)pNode); // This will take care of modifying pNode->mpNext.
+ ++numErased;
+ }
else
pNode = pNode->mpNext;
}
+ return numErased;
}
@@ -1811,7 +1821,13 @@ namespace eastl
#endif
}
-
+#if defined(EA_COMPILER_HAS_THREE_WAY_COMPARISON)
+ template <typename T, typename Allocator>
+ inline synth_three_way_result<T> operator<=>(const slist<T, Allocator>& a, const slist<T, Allocator>& b)
+ {
+ return eastl::lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end(), synth_three_way{});
+ }
+#else
template <typename T, typename Allocator>
inline bool operator<(const slist<T, Allocator>& a, const slist<T, Allocator>& b)
{
@@ -1845,7 +1861,7 @@ namespace eastl
{
return !(a < b);
}
-
+#endif
template <typename T, typename Allocator>
inline void swap(slist<T, Allocator>& a, slist<T, Allocator>& b)
@@ -1858,17 +1874,17 @@ namespace eastl
///
/// https://en.cppreference.com/w/cpp/container/forward_list/erase2
template <class T, class Allocator, class U>
- void erase(slist<T, Allocator>& c, const U& value)
+ typename slist<T, Allocator>::size_type erase(slist<T, Allocator>& c, const U& value)
{
// Erases all elements that compare equal to value from the container.
- c.remove_if([&](auto& elem) { return elem == value; });
+ return c.remove(value);
}
template <class T, class Allocator, class Predicate>
- void erase_if(slist<T, Allocator>& c, Predicate predicate)
+ typename slist<T, Allocator>::size_type erase_if(slist<T, Allocator>& c, Predicate predicate)
{
// Erases all elements that satisfy the predicate pred from the container.
- c.remove_if(predicate);
+ return c.remove_if(predicate);
}