Map/Set.prototype.size is O(n)

Oriol _ oriol-bugzilla at hotmail.com
Wed Mar 29 15:31:58 UTC 2017


Not only `size`. All `get`, `set`, `has`, etc. algorithms in the spec are O(n).

But as explained in http://www.ecma-international.org/ecma-262/7.0/index.html#sec-map-objects,

> Map object must be implemented using either hash tables or other mechanisms that, on average,
> provide access times that are sublinear on the number of elements in the collection.
> The data structures used in this Map objects specification is only intended to describe the required
> observable semantics of Map objects. It is not intended to be a viable implementation model.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170329/3878495b/attachment.html>


More information about the es-discuss mailing list