Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Enumset.contains Date: Sat, 10 Nov 2012 00:30:28 +0100 Lines: 35 Message-ID: References: <6btq9811qn454a7s9u4dka81qn6k6e2n56@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net N9OY2NkOjNO/jHD3fj+y7g9MrV05FH1BF2VeNVRUx8NTUWqMRiQj+T/BwXSQ+mbtQ= Cancel-Lock: sha1:YcXD27IpLEnLKlqBNvpd4pZ2WIQ= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 In-Reply-To: <6btq9811qn454a7s9u4dka81qn6k6e2n56@4ax.com> Xref: csiph.com comp.lang.java.programmer:19682 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