growableArray.hpp remove_if_existing
Baesken, Matthias
matthias.baesken at sap.com
Thu Jul 20 08:56:21 UTC 2023
Hello, I noticed that the method remove_if_existing from growableArray.hpp
GrowableArrayView :
bool remove_if_existing(const E& elem) {
// Returns TRUE if elem is removed.
for (int i = 0; i < _len; i++) {
if (_data[i] == elem) {
remove_at(i);
return true;
}
}
return false;
}
Just removes the first element it finds and afterwards returns.
I found this a bit surprising - should the method better be named remove_first_if_existing to clarify that it removed no more than one element ?
Or is there a rule that no more than 1 element in the growableArray can match the ‘==’ ?
Best regards, Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20230720/c09a25ec/attachment-0001.htm>
More information about the hotspot-dev
mailing list