Skip to content

Commit 6f207a4

Browse files
committed
Add a const version of List::find
1 parent e47fb8b commit 6f207a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/templates/list.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,19 @@ class List {
415415
/**
416416
* find an element in the list,
417417
*/
418+
template <typename T_v>
419+
const Element *find(const T_v &p_val) const {
420+
const Element *it = front();
421+
while (it) {
422+
if (it->value == p_val) {
423+
return it;
424+
}
425+
it = it->next();
426+
}
427+
428+
return nullptr;
429+
}
430+
418431
template <typename T_v>
419432
Element *find(const T_v &p_val) {
420433
Element *it = front();

0 commit comments

Comments
 (0)