Difference between revisions of "Datatypes R2 Issue 83"
Line 2: | Line 2: | ||
== Introduction == | == Introduction == | ||
+ | |||
+ | Much angst and arguments about our stance on what a SET is. People know discrete enumerated sets, but they don't think that an interval is also a set, yet, interval of real numbers cannot be enumerated. | ||
== Issue == | == Issue == | ||
− | == | + | While implementing HL7 abstract data types in Java SIG, we find a use for distinguishing two kinds of sets, |
+ | * Discrete Set (DSET<T>) is a SET<T> | ||
+ | * Continuous Set (QSET<T specializes QTY>) is a SET<T> | ||
+ | |||
+ | Here would be SET (I'm copying from Java SIG code) | ||
+ | |||
+ | SET<T specializes ANY> specializes ANY { | ||
+ | BL contains(T element); | ||
+ | BL isEmpty(); | ||
+ | BL nonEmpty(); | ||
+ | BL contains(SET<T> subset); | ||
+ | INT cardinality(); | ||
+ | SET<T> union(SET<T> otherset); | ||
+ | SET<T> except(T element); | ||
+ | SET<T> except(SET<T> otherset); | ||
+ | SET<T> intersection(SET<T> otherset); | ||
+ | T any(); // this is another proposal | ||
+ | } | ||
+ | |||
+ | Here is DSET in Java only right now: | ||
+ | |||
+ | public interface DSET<T extends ANY> extends SET<T>, Iterable<T> { | ||
+ | /** An iterator over this set. This is guaranteed to be an iterator of discrete T values. */ | ||
+ | Iterator<T> iterator(); | ||
+ | } | ||
+ | |||
+ | You see, that iterator does not exist in QSET. Not sure yet how to do this for HL7 abstract. | ||
+ | |||
+ | Now QSET: | ||
+ | |||
+ | QSET<T specializes QTY> specializes SET<T> { | ||
+ | QSET<T> union(QSET<T> otherset); | ||
+ | QSET<T> except(T element); | ||
+ | QSET<T> except(QSET<T> otherset); | ||
+ | QSET<T> intersection(QSET<T> otherset); | ||
+ | IVL<T> hull(); | ||
+ | IVL<T> nextTo(T element); | ||
+ | IVL<T> nextAfter(T element); | ||
+ | QSET<T> periodicHull(QSET<T> otherset); | ||
+ | BL interleaves(QSET<T> otherset); | ||
+ | }; | ||
+ | |||
+ | Now with this we can assert: | ||
+ | * IVL<T> specializes QSET<T> | ||
+ | * PIVL<T> specializes QSET<T> | ||
+ | * EIVL<T specializes TS> specializes QSET<T> | ||
+ | |||
+ | And we still assert '''GTS == QSET<TS>''' (and nothing else. | ||
== Discussion == | == Discussion == | ||
+ | |||
+ | This distinction is not changing any semantics, it only helps clarifying that there are some things you can do with a DSET that you can't do with a QSET. A DSET can be implemented as a plain old naive so called "collection". But a QSET needs more. For QSET we'll have to make another proposal. | ||
== Links == | == Links == | ||
Back to [[Data Types R2 issues]] | Back to [[Data Types R2 issues]] |
Revision as of 16:12, 3 May 2007
Contents
Data Types Issue 83: Discrete and Continuous SET (DSET, QSET)
Introduction
Much angst and arguments about our stance on what a SET is. People know discrete enumerated sets, but they don't think that an interval is also a set, yet, interval of real numbers cannot be enumerated.
Issue
While implementing HL7 abstract data types in Java SIG, we find a use for distinguishing two kinds of sets,
- Discrete Set (DSET<T>) is a SET<T>
- Continuous Set (QSET<T specializes QTY>) is a SET<T>
Here would be SET (I'm copying from Java SIG code)
SET<T specializes ANY> specializes ANY { BL contains(T element); BL isEmpty(); BL nonEmpty(); BL contains(SET<T> subset); INT cardinality(); SET<T> union(SET<T> otherset); SET<T> except(T element); SET<T> except(SET<T> otherset); SET<T> intersection(SET<T> otherset); T any(); // this is another proposal }
Here is DSET in Java only right now:
public interface DSET<T extends ANY> extends SET<T>, Iterable<T> { /** An iterator over this set. This is guaranteed to be an iterator of discrete T values. */ Iterator<T> iterator(); }
You see, that iterator does not exist in QSET. Not sure yet how to do this for HL7 abstract.
Now QSET:
QSET<T specializes QTY> specializes SET<T> { QSET<T> union(QSET<T> otherset); QSET<T> except(T element); QSET<T> except(QSET<T> otherset); QSET<T> intersection(QSET<T> otherset); IVL<T> hull(); IVL<T> nextTo(T element); IVL<T> nextAfter(T element); QSET<T> periodicHull(QSET<T> otherset); BL interleaves(QSET<T> otherset); };
Now with this we can assert:
- IVL<T> specializes QSET<T>
- PIVL<T> specializes QSET<T>
- EIVL<T specializes TS> specializes QSET<T>
And we still assert GTS == QSET<TS> (and nothing else.
Discussion
This distinction is not changing any semantics, it only helps clarifying that there are some things you can do with a DSET that you can't do with a QSET. A DSET can be implemented as a plain old naive so called "collection". But a QSET needs more. For QSET we'll have to make another proposal.
Links
Back to Data Types R2 issues