From: Robert Klemme Date: 2008-11-19T07:06:24+09:00 Subject: Re: Subclassing Hash to enforce value uniqueness ala key uniqueness. On 18.11.2008 09:37, Sebastian Hungerecker wrote: > Adam Gardner wrote: >> The second problem is efficiency: It seems to me that this could >> probably be done much more efficiently, especially if implemented in C. > > Every time you add a value you iterate over all the other values to check > whether the value is already there. This makes adding an element O(n). Having > adding to a datastructure be an O(n) operation is usually a bad idea. Here's > how I'd probably do it (untested): good example Right, my main point would be: why subclass? You inherit a lot of methods that you need to watch out for. Rather, as Basti showed, implement a new class with all the necessary methods. Kind regards robert PS: Sorry for the nicknaming. :-)