- From: Tab Atkins Jr. <notifications@github.com>
- Date: Wed, 23 Nov 2022 08:53:10 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/335/1325379924@github.com>
Just to look for some more precedent: * [C++'s std::multimap has an erase() method](https://en.cppreference.com/w/cpp/container/multimap/erase) which can either wipe all the values for a given key, or remove a *single* k/v pair at a particular position, so it counts as precedent * We already saw the Java precedent, which offers "erase all" and "erase one" under different names * [Scala has the ability to remove a key/value pair](https://www.scala-lang.org/api/2.13.6/scala/collection/mutable/MultiMap.html), but this impl, at least, can't have repeated pairs since the values are stored in a Set. * [VertX, a java library](https://vertx.io/docs/apidocs/io/vertx/core/MultiMap.html) only has "erase all". (It uses MultiMap specifically for handling http headers, which is interestingly close to our use-case.) * [Apache's MultiValuedMap](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/MultiValuedMap.html) has both. (It's not clear from the docs if its "remove one" will kill all matching k/v or just a single one.) This is just me looking at the first two pages of Google results, so I think it's fairly well established that "remove one k/v pair" is a reasonable part of a multimap API. Re: whether it removes a single matching k/v pair or all matching pairs, I can see arguments either way, but I lean towards just removing one. (Specifically the first or last.) Most of the time it won't matter because you won't have dupes anyway, but sometimes you have dupes quite purposely and we can't reasonably guess whether someone wants to remove all of them or just one. If we went with "remove all" then the people wanting "remove one" behavior would have to do essentially the same workarounds as shown in this thread, while if we went with "remove one" then people wanting to remove all would have a much easier "remove in a while loop" workaround. (Ugh, the lack of a 2-arg has() method means they'd have to do `while(params.getAll(key).contains(value)) params.delete(key, value);`, but that's something we can solve later, and it's still easier than pulling the values out, removing one, and putting them back.) -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/url/issues/335#issuecomment-1325379924 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/url/issues/335/1325379924@github.com>
Received on Wednesday, 23 November 2022 16:53:22 UTC