Skip to content

Commit a733502

Browse files
rolandreichweinbmwJohn Wellbelove
authored andcommitted
Intrusive forward list add remove by pointer (#1026)
* Add intrusive_forward_list::remove() element by pointer * Add test
1 parent 9c22c6c commit a733502

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

include/etl/intrusive_forward_list.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,29 @@ namespace etl
10111011
}
10121012
}
10131013

1014+
//*************************************************************************
1015+
// Removes the element specified by pointer.
1016+
//*************************************************************************
1017+
void remove(const_pointer element)
1018+
{
1019+
iterator i_item = begin();
1020+
iterator i_last_item = before_begin();
1021+
1022+
while (i_item != end())
1023+
{
1024+
if (&i_item == element)
1025+
{
1026+
i_item = erase_after(i_last_item);
1027+
return;
1028+
}
1029+
else
1030+
{
1031+
++i_item;
1032+
++i_last_item;
1033+
}
1034+
}
1035+
}
1036+
10141037
//*************************************************************************
10151038
/// Removes according to a predicate.
10161039
//*************************************************************************

0 commit comments

Comments
 (0)