On Wed, May 28, 2003 at 01:49:53AM +0900, Robert Klemme wrote: > Well, yes. But all these actions don't introduce a new class invariant. > Note, that methods sort and sort! must be invoked explicitely. Under the > hood it remains a "sequence of things" and it is not a "sorted sequence of > things". This is a major difference although it might not look that way > on first glance. If you consider, how all modifying methods must change > you'll might easier see the impact of this difference. Having all methods > of this kind check a flag is commonly considered bad practice. I'd favour > an extra type, i.e. sub class or proxy that delegates. And presumably if you *insert* into a SortedArray then it needs to put the item in the correct place. So syntax such as a[3] = "hello" really doesn't make any sense. However, a << "hello" would put the entry in the correct place. (That's unless you maintain this flag saying "the array is currently sorted" which is a bit of a nightmare IMO, for lots of reasons) So a SortedArray would have considerably different semantics to a normal Array anyway. Its implementation would probably be different too - perhaps a heap or a b-tree. Regards, Brian.