Maxpm
Maxpm

Reputation: 25551

"Delete" vs. "Remove"

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?

Upvotes: 3

Views: 700

Answers (1)

Fred Larson
Fred Larson

Reputation: 62063

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).

Upvotes: 5

Related Questions