Marxon13 / M13OrderedDictionary

A NSDictionary with ordered objects and keys
263 stars 29 forks source link

replicate behavior of NSMutableDictionary's removeObjectForKey: #20

Closed jpmhouston closed 9 years ago

jpmhouston commented 9 years ago

This is a fix for #19. These sanity checks are to replicate behavior of NSMutableDictionary methods removeObjectForKey: and removeObjectForKeys: which are documented to raise no exception for keys that do not exist.

This pull request also changes the behavior of these related methods to follow the same spirit: removeLastEntry removeEntryWithObject: removeEntryWithKey: removeEntryWithObject:pairedWithKey: removeEntry: removeEntryWithObject:inRange: removeEntryWithKey:inRange: removeEntryWithObject:pairedWithKey:inRange: removeEntry:inRange: removeEntryWithObjectIdenticalTo: removeEntryWithObjectIdenticalTo:inRange: removeEntriesWithObjectsInArray: removeEntriesWithKeysInArray:

Of these, I would regard only the changes to removeLastEntry and the inRange methods to be debatable as to whether they should always silently return vs generate a range error, though in case of the inRange methods, when the range is out of bounds and not when the entry is not present. In all of those cases, I'll argue that its extra code that needs to be written to generate these exceptions rather than removing the code that this pull request adds.

This pull request does not change the behavior of removeEntryAtIndex: or removeEntriesAtIndices:, these still raise an range exception like the NSMutableArray method removeObjectAtIndex: does.