[SR-735] SetAlgebraType: Make isStrictSupersetOf
and isStrictSubsetOf
Overridable
#43350
Labels
isStrictSupersetOf
and isStrictSubsetOf
Overridable
#43350
Attachment: Download
Additional Detail from JIRA
md5: f1ad7fc6ea03210e72e4cd979653ba18
Issue Description:
At present, the `SetAlgebraType` defines `isStrictSupersetOf` and `isStrictSubsetOf` extension methods, but these are not overridable.
In many cases it is possible to do a better job of checking for strict-subset/strict-superset status than the default implementations here:
...in particular, note that the default implementations for `isSubsetOf` and `isSupersetOf` are here:
...(aside: why does `isSupersetOf` call `isSubsetOf`, but it's the other way around for `isStrictSupersetOf` (it gets called-by `isStrictSubsetOf`)?).
If you expand it out, this means that the default implementation of `isStrictSupersetOf` is equivalent to:
...which is very easy to beat in many cases (e.g. in any case for which the `==` and `!=` operations are not O(1)); put differently, it's easy to "fuse" the "subset" and the "strict" parts of these checks into a single iteration.
I've attached a file containing a sketch of one concrete type for which you can easily improve on the default implementation of `isStrictSuperset` and `isStrictSuperset`.
The text was updated successfully, but these errors were encountered: