When I started this blog (2004) it was to document Gentoo linux experiences and *nix adventures. Then it turned into posts regarding software development challenges and other findings. These days I mostly tweet (rollinsruss) and my posts are infrequent.
Wednesday, July 11, 2007
Ruby: constant time for include?
Sure would be nice if the Ruby docs (including this book) would provide more details to the implementation of the Set class. According to this, Set implements its backing collection with a Hash, which would essentially mean that it's synonymous (to some degree) with Java's HashSet. Thus providing a constant time lookup when Set#include? is invoked. Just for grins I benchmarked this in irb with a million Fixnums and was pleased with the 15 microsecond lookups. I looked at the source of both and found a fair amount of similarity.
No comments:
Post a Comment