As part of the instaparse library, I created a wrapper around Clojure's vectors that keeps the hashcode updated as the vector is modified. In scenarios where you take a vector and then hash, then modify, then hash, then modify, then hash, etc., this strategy of "incremental hashing" is essential to performance. Otherwise, Clojure traverses every element in the modified vector to compute the new hash.
I have documented this new datatype. It's very simple to use, simply call ivec instead of vec to create it and use it as you'd use a vector (with some obvious exceptions, for example, you can't add something unhashable, like an infinite sequence, to the vector, since it hashes the items as they are added). https://github.com/Engelberg/instaparse/blob/master/docs/IncrementalVectors.md Code is here: https://github.com/Engelberg/instaparse/blob/master/src/instaparse/incremental_vector.clj Feel free to use it in your own projects. Thanks to Christophe Grand who provided guidance on some of the subtleties of simulating vectors. For example, I had a lot of confusion about equal vs equiv which he helped to clear up. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.