On 08/17/2012 05:35 PM, Rasmus Schultz wrote:
> Most other languages have more than one collection-type... since PHP has
> only the single, hybrid array-type which acts both as a hash and as an
> array, something like this ought to be available.
> 
> I don't know why everyone is so eager to jump up and argue against
> something this simple, basic and useful. The fact that this is missing
> is an oversight - just look at the number of solutions people come up
> with. For what?
> 
> I want to remove and object from a list. Not an exotic and crazy
> requirement, is it? It just isn't the sort of thing that should require
> any substantial thinking or typing.
> 
> And it doesn't help make codebases more legible when people come up with
> 25 different ways to do it.

The problem is that it is a rather unusual thing to do. I don't mean
removing an element, that is very common, but you are implying that you
know you don't have duplicates and you want a fast way to remove an
element by value in that case. To me that means you built your array
badly. If the values are unique then they should be the keys, or at
least a representation of the value should be the key such that you
don't need to scan the entire hash for the element when you need to
access it. And removal is just like any other access.

-Rasmus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to