Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Delete" vs. "Remove"

Tags:

c++

arrays

I'm implementing a method in my container class that removes/deletes one value from the array. For example:

// | 532 | 422 | 134 | 762 |
// |  0  |  1  |  2  |  3  |

MyObject.Remove(1); // Or MyObject.Delete(1);

// | 532 | 134 | 762 |
// |  0  |  1  |  2  |

Which word is more commonly-used for this type of thing?

like image 795
Maxpm Avatar asked Mar 31 '26 18:03

Maxpm


1 Answers

The standard library containers use "erase". "Delete" might be confused with deleting a memory allocation. The standard library algorithms with "remove" in the name don't actually change the size of the container (see http://en.wikipedia.org/wiki/Erase-remove_idiom).

like image 82
Fred Larson Avatar answered Apr 02 '26 12:04

Fred Larson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!