Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19682

Re: Enumset.contains

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Enumset.contains
Date 2012-11-10 00:30 +0100
Message-ID <ag5i0kF13jmU1@mid.individual.net> (permalink)
References <6btq9811qn454a7s9u4dka81qn6k6e2n56@4ax.com>

Show all headers | View raw


On 11/09/2012 10:40 PM, Roedy Green wrote:
> You might think

No.

> EnumSet.contains( subset ) would mean containsAnyOf or containsAllOf
> but it is meaningless.
>
> There is an EnumSet.containsAll but no EnumSet.containsAnyOf
>
> It seems odd Set and EnumSet don't directly support the usual things
> mathematicians do with sets,
> union
> intersection
retainAll()

> isSubsetOf
containsAll()

> isSuperSetOf
containsAll()

> The operations would be so fast internally if Oracle used the binary
> logic ops to handle bit strings, rather than flat-footed processing an
> element at a time.
>
> What think you?

You can use clone() and retainAll() and check return type, or use 
addAll() and check whether size < oldSize + other.size(), or write a 
loop in a few lines...

Cheers

	robert

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Enumset.contains Roedy Green <see_website@mindprod.com.invalid> - 2012-11-09 13:40 -0800
  Re: Enumset.contains Lew <lewbloch@gmail.com> - 2012-11-09 15:07 -0800
    Re: Enumset.contains Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-11-09 23:50 +0000
  Re: Enumset.contains Robert Klemme <shortcutter@googlemail.com> - 2012-11-10 00:30 +0100
    Re: Enumset.contains Roedy Green <see_website@mindprod.com.invalid> - 2012-11-10 16:56 -0800
      Re: Enumset.contains markspace <-@.> - 2012-11-10 17:10 -0800
      Re: Enumset.contains Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-11-10 20:38 -0600

csiph-web