JuliaLang/julia — pull request #2548 by kmsquire (2013-03-12 06:42:47+00:00)
Title: added AbstractHashDict above Dict

This generalizes most Dict functions to work on an abstract hash type.

Rationale: I needed an OrderedDict class for a project, and found no way to create one by wrapping Dict that was in any way efficient. The only implementation that did not have severe performance issues was to copy almost all of Dict and modify it directly to keep track of the order of the keys. The result was the near duplication of most functions. See
https://github.com/kmsquire/OrderedCollections.jl.

I'm not sure if any other Dict subclass will ever need this, and I don't know if an OrderedDict needs to be in base (it probably belongs in a Collections or OrderedCollections package). So I'm just putting this out there to get some feedback.

If it goes in, I have a version of OrderedDict which will use it (and reduce in size greatly). If not, I'll publish the version which copies most of `type Dict`.

If nothing else, this patch does show the potential utility of abstract classes with fields, as most of the functions for the abstract class depend on the existence of most of the fields of Dict (and which were copied in OrderedDict).