Closed StoneCypher closed 5 years ago
It's not obvious to me that it would be a good thing to add all of these. For example, most people can use arrays instead of linked lists and have that be quite performant, since engines have put a huge amount of work into optimizing arrays. And then they don't have to think all the time about which to use. Can you say more about why it makes sense for each of these to be built in?
Can you say more about why it makes sense for each of these to be built in?
I'm 100% on board with this. Every hobby project I write I end up implementing several extra container classes; Counter
and DefaultMap
(defaultdict
in Python) in particular are common ones for me.
Stacks can be done trivially and efficiently with arrays, but queues, dequeues, and pqueues are all relatively bad with plain arrays; good implementations exist but are non-trivial to write. (If you're doing a significant amount of .insert()
or .splice()
to insert/delete from the front of an array, you're gonna be paying for it...).
The DOM is reinventing multimaps in several places (URLSearchParams
, CSSStylePropertyMap
, etc), and having a canonical version in JS would be great. At minimum, the usage of them in core platform APIs suggests that they'd be useful to expose for author usage as well.
Maybe add a constructor for iterable array-like instances? Maybe called List
?
@Mouvedia see https://github.com/keithamus/proposal-array-last for "negative arrays"
Actually I am interested in negative indexes; a method wouldn't fit the bill.
@Mouvedia let's discuss that on that proposal's repo then :-)
@ljharb sadly, I know already that it's impossible using unproxied Array
, that's why I am asking here :)
cf keithamus/proposal-array-last#1
I like negative array index calls, but they're a pretty separate issue than this. I'd like them to not bury this in the discussion please 😄
Let's follow up on feature idea brainstorming in #16.
I really wish you'd stop closing my tickets, dan
We are container-poor. This is problematic. Please give us the remaining basic containers.
They should be easily pulled from the host implementation's c++ stl
We need
queue
,deque
,pqueue
, and some or anothertree
.Arguably you can skip lists on homebrew implementations but standardization is useful. Anyone arguing for homebrew implementations of trees as nested containers is missing the point.
It would be nice to have
linked
anddoubly linked list
. These actually can be reasonably implemented as homebrew, but native ones would be ridic faster, and having a shared api would be niceIt would be really nice to have bimap. Greenspun's rule is about lisp. It should be about bimap. Most people don't know bimap (where values are also keys) exists, and yet have buggily implemented it a thousand times.
Consequentially we'll also want multibimap, which is what everyone needs and doesn't realize and doesn't end up implementing
It would be nice to have
multiset
andmultimap
. It is reasonable to fake these with aset-of-arrays
and so on, so, this isn't critical. It would be a performace benefit at large, though, and probably a defect reduction.It would be interesting to have
trie
, but this is probably overboard. This is properly userland-implementable. The only reason or interest here would be to have a shared/unified API, but for trie it's not entirely clear that's actually needed or warranted.