> Quick thing - I know Array is implemented in C rather than in Ruby. > This is probably true for Hash as well. There's two points here: > first, if you were patching Array directly, you could rewrite > [] and it would still drop to the C implementation (if I > understand correctly). Second, the C versions of course will > be faster. I doubt that simply rewriting [] (and []=) would suffice, as Hash and my SortedHash have entirely different internal data structures, upon which the rest of the methods would seem to depend. Note I'm almost certain that the C-based Hash is going to destroy my SortedHash in performance, even for small collections for which a binary search is likely to be faster than hash access. This was more of a learning ruby exercise than anything practical. > > 1. I'm storing entries as struct objects, the class definition for > > which is stored in a class constant. Good or bad practice? > I note that > > I get a constant redefinition warning when I reload the > class. I could > > easily enough use a two element array, but thought a struct > would be > > more efficient and be more clear. > > I didn't spot this in the code, but I'm in a pre-RailsConf > packing frenzy. Off the top of my head I'd say don't do it - > you should be able to get that information from the stored > object itself. Just because you pop it in a hash doesn't mean > its identity dissolves. Er, I'm just talking about a data structure in which to put the key and value objects. I'm curious about the merits of [key, value] v.s. ENTRY.new(key, value) (v.s., I dunno, putting the Entry struct in a class variable or a class instance variable). > > 4. Should I be checking block_given? in delete_if, et. al.? > Should I > > be explicitly declaring a &blk argument? > > I hate to admit it but I have no idea what you're even > asking. I did pp Hash.methods.sort and got neither of those. > Are they in Enumerable? > I totally missed that. Hash.methods.sort wouldn't list 'em as they're not class methods, they're instance methods. pp {}.methods.sort would list 'em. In any case, I was going by the documentation here: http://dev.rubycentral.com/ref/ref_c_hash.html - donald