15,798,508 members
5.00/5 (1 vote)
See more:
Hi!

How could I represent multiple subsets of a set of real numbers?

The problem is that,I want to remove some parts of real numbers in range : [0,2*pi) for example,after removal I will have s.th like this:
Result set = [0,0.1] U [.2,2.65] U [2.66,2.86] U ... U [3.0,3.1]

in fact the result set,consists of several non-overlapping subsets(we don't know the exact count of these subsets.may be they are up to 200).

how could I implement "union" and "subtraction" and "overlapping" operations?
Posted
Sergey Alexandrovich Kryukov 1-Oct-12 18:01pm
I must say, you ask pretty interesting questions so far. I voted 5 for this one.
In the first question, you made another mistake which I explained in my answer, with a fix.
--SA

## Solution 1

You can use `HashSet<t></t>`[^] to represent sets.

You're right, this won't work for a continuous set. Seems you may have to brew your own `Range<T>` class.

/ravi

v2
CyrusT 1-Oct-12 16:58pm
HashSet is used for discrete sets only! :(
I want to represent continuous sets!
Sergey Alexandrovich Kryukov 1-Oct-12 17:48pm
You both are not quite right. The situation is more delicate.

First of all, nothing in a computer presents a continuous set. The whole computer is the finite-state machine, like it or not. You should also understand, that there are no real numbers (a set of those would be a continuous set) -- you have only the model approximating that, such as the set of all double of float numbers.

Now, the real problem is how to build a model of real number or other "potentially continues" objects to make some help from the computer. This is the completely different, quite correct problem, but only if strictly formulated.

In other words, the solution of OP's is most likely quite solvable. He only need to provide complete and strict description of required operations. Listing of those set-theory primitives is not enough. I would need to know how the set is used. I assume the use is realistic, and in this case I can almost guarantee the solution. I would recommend to start with explanation of the ultimate purpose.

--SA
Ravi Bhavnani 1-Oct-12 17:51pm
> You should also understand, that there are no real numbers
Quite correct. Any usage of Range<decimal> would be an approximation.

> I would recommend to start with explanation of the ultimate purpose.
+5

/ravi
Sergey Alexandrovich Kryukov 1-Oct-12 18:04pm
Absolutely. Thank you very much.
--SA
Sergey Alexandrovich Kryukov 1-Oct-12 18:04pm
I did not down-vote this answer even in its original version, because it is not completely wrong (and it was not completely wrong before); the question just needs some more detail and it all needs some analysis based on that.
And the use of the Range is a good idea. The set could be represented by the set of instances of, say, Range<double>.
Depending on expected use of the set class, even the modified use of HashSet could be appropriate. Let's learn about the prospective usage of it.
--SA