Hi, Duncan. unionWith result is differs from set union, since it produces single set always while set operations may produce two sets. E.g.: For ranges [1, 5) and [10,15) unionWith produces [1,15), while set union should just keep these sets without changing, probably with indication that sets are not intersected. Implementation of set union is simple though. The "symmetric difference" implementation is little bit more complex. For two sets [1,15) and [7,12) symmetric difference is pair of ranges: [1,7) and [12,15) I propose to implement these methods in ConstantRange (I can do it). -Stepan.
Hi Stepan,> unionWith result is differs from set union, since it produces single set always > while set operations may produce two sets.this is true, but that's inevitable if the result is to be a single ConstantRange. You can of course define methods that returns a pair of ConstantRanges and does what you want. But why do you need these methods anyway? A "switch" is just going to be a (probably ordered) list of disjoint ranges. Where do set operations come in? Ciao, Duncan.> > E.g.: > For ranges > [1, 5) and [10,15) > unionWith produces [1,15), while set union should just keep these sets without > changing, probably with indication that sets are not intersected. Implementation > of set union is simple though. > > The "symmetric difference" implementation is little bit more complex. > For two sets > [1,15) and [7,12) > symmetric difference is pair of ranges: > [1,7) and [12,15) > > I propose to implement these methods in ConstantRange (I can do it). > > -Stepan. > > > > >
Well... each case is represented as pair<BB, vector<Range> >. Right? We need "union" for optimal case building. And we need support "difference" if we decided that some ranges or numbers in case will never used (in some optimization passes it happens sometimes). -Stepan 26.04.2012, 15:18, "Duncan Sands" <baldrick at free.fr>:> Hi Stepan, > >> unionWith result is differs from set union, since it produces single set always >> while set operations may produce two sets. > > this is true, but that's inevitable if the result is to be a single > ConstantRange. You can of course define methods that returns a pair > of ConstantRanges and does what you want. But why do you need these > methods anyway? A "switch" is just going to be a (probably ordered) > list of disjoint ranges. Where do set operations come in? > > Ciao, Duncan. > >> E.g.: >> For ranges >> [1, 5) and [10,15) >> unionWith produces [1,15), while set union should just keep these sets without >> changing, probably with indication that sets are not intersected. Implementation >> of set union is simple though. >> >> The "symmetric difference" implementation is little bit more complex. >> For two sets >> [1,15) and [7,12) >> symmetric difference is pair of ranges: >> [1,7) and [12,15) >> >> I propose to implement these methods in ConstantRange (I can do it). >> >> -Stepan.