mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Change List::remote(const T&) to return a bool
It now indicates whether the removal took place or not, depending on whether a matching element was found in the list.
This commit is contained in:
parent
7ccf3c0a69
commit
ee95fd2801
1 changed files with 10 additions and 5 deletions
15
src/List.h
15
src/List.h
|
@ -273,13 +273,18 @@ public:
|
|||
entries[num_entries++] = a;
|
||||
}
|
||||
|
||||
T remove(const T& a) // delete entry from list
|
||||
bool remove(const T& a) // delete entry from list
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < num_entries && a != entries[i]; ++i )
|
||||
;
|
||||
for ( int i = 0; i < num_entries; ++i )
|
||||
{
|
||||
if ( a == entries[i] )
|
||||
{
|
||||
remove_nth(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return remove_nth(i);
|
||||
return false;
|
||||
}
|
||||
|
||||
T remove_nth(int n) // delete nth entry from list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue