On Wednesday, 24 October 2012 at 20:37:08 UTC, H. S. Teoh wrote:
On Wed, Oct 24, 2012 at 10:16:27PM +0200, Mehrdad wrote: [...]struct Set(T) { int[T] dict; hash_t toHash() const { typeof(return) r = 0; foreach (item; this.dict.keys) { ??? // what should be here? } return r; } }Try this: hash_t toHash() const { hash_t h = 0; foreach (item; this.dict.keys) { // We use a commutative operation here (+) so // that the order of keys don't matter. h += hashOf(&item, item.sizeof); } return h; } T
Wouldn't that do a bitwise comparison?
