Ben Laurie
2009-Feb-12 04:14 UTC
[LLVMdev] Some enhancements to ImmutableSet and FoldingSet
On Wed, Feb 11, 2009 at 8:24 PM, Ted Kremenek <kremenek at apple.com> wrote:> Actually, neither of these methods are needed for ImmutableSet. > ImmutableSet already has an 'isEmpty()' method and I have never really seen > a case where "size()" needs to be explicitly calculated. If you need size() > itself, however, this seems like a perfectly valid addition.I need to check for size() == 1 (in order to test whether a range set has a single possible value).
Ted Kremenek
2009-Feb-12 04:47 UTC
[LLVMdev] Some enhancements to ImmutableSet and FoldingSet
On Feb 11, 2009, at 8:14 PM, Ben Laurie wrote:> On Wed, Feb 11, 2009 at 8:24 PM, Ted Kremenek <kremenek at apple.com> > wrote: >> Actually, neither of these methods are needed for ImmutableSet. >> ImmutableSet already has an 'isEmpty()' method and I have never >> really seen >> a case where "size()" needs to be explicitly calculated. If you >> need size() >> itself, however, this seems like a perfectly valid addition. > > I need to check for size() == 1 (in order to test whether a range set > has a single possible value).Ah. If that is the case, we can implement a 'isSingleton()' method with constant time performance (i.e., check if we have a root, and check that the root has no children). Would that work?
Ben Laurie
2009-Feb-12 04:53 UTC
[LLVMdev] Some enhancements to ImmutableSet and FoldingSet
On Thu, Feb 12, 2009 at 4:47 AM, Ted Kremenek <kremenek at apple.com> wrote:> On Feb 11, 2009, at 8:14 PM, Ben Laurie wrote: > >> On Wed, Feb 11, 2009 at 8:24 PM, Ted Kremenek <kremenek at apple.com> wrote: >>> >>> Actually, neither of these methods are needed for ImmutableSet. >>> ImmutableSet already has an 'isEmpty()' method and I have never really >>> seen >>> a case where "size()" needs to be explicitly calculated. If you need >>> size() >>> itself, however, this seems like a perfectly valid addition. >> >> I need to check for size() == 1 (in order to test whether a range set >> has a single possible value). > > Ah. If that is the case, we can implement a 'isSingleton()' method with > constant time performance (i.e., check if we have a root, and check that the > root has no children). Would that work?Sure would!
Apparently Analagous Threads
- [LLVMdev] Some enhancements to ImmutableSet and FoldingSet
- [LLVMdev] Some enhancements to ImmutableSet and FoldingSet
- [LLVMdev] Some enhancements to ImmutableSet and FoldingSet
- [LLVMdev] Some enhancements to ImmutableSet and FoldingSet
- [LLVMdev] Some enhancements to ImmutableSet and FoldingSet