From harmony-dev-return-11374-apmail-incubator-harmony-dev-archive=incubator.apache.org@incubator.apache.org Thu Aug 03 10:45:14 2006 Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 19323 invoked from network); 3 Aug 2006 10:45:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Aug 2006 10:45:13 -0000 Received: (qmail 76277 invoked by uid 500); 3 Aug 2006 10:45:10 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 76227 invoked by uid 500); 3 Aug 2006 10:45:10 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 76216 invoked by uid 99); 3 Aug 2006 10:45:10 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Aug 2006 03:45:10 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.154 is neither permitted nor denied by domain of smallsmallorgan@gmail.com) Received: from [202.81.18.154] (HELO ausmtp05.au.ibm.com) (202.81.18.154) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Aug 2006 03:45:09 -0700 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp05.au.ibm.com (8.13.6/8.13.6) with ESMTP id k73AlQfM4088054 for ; Thu, 3 Aug 2006 20:47:26 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.250.243]) by sd0208e0.au.ibm.com (8.13.6/8.13.6/NCO v8.1) with ESMTP id k73AlLmV012976 for ; Thu, 3 Aug 2006 20:47:43 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k73AfkY0007025 for ; Thu, 3 Aug 2006 20:41:47 +1000 Received: from d23m0011.cn.ibm.com ([9.181.32.74]) by d23av02.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k73Afhs5005479 for ; Thu, 3 Aug 2006 20:41:44 +1000 Received: from [127.0.0.1] ([9.181.106.176]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006080318425880-29603 ; Thu, 3 Aug 2006 18:42:58 +0800 Message-ID: <44D1D319.4060209@gmail.com> Date: Thu, 03 Aug 2006 18:42:33 +0800 From: Spark Shen User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib][luni] Enhance the functionalities provided by BitSet References: <44D14ED6.307@gmail.com> <44D19A68.4070808@gmail.com> <44D1A585.3080800@gmail.com> <26c14c2a0608030308of242010mbec7f790a655feac@mail.gmail.com> In-Reply-To: <26c14c2a0608030308of242010mbec7f790a655feac@mail.gmail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 03/08/2006 18:42:58, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 03/08/2006 18:43:44, Serialize complete at 03/08/2006 18:43:44 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-2022-JP X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Oleg Khaschansky 写道: > Hi all! > > I'd like to add to this discussion that, IMHO, implementation of the > EnumSet > based on the BitSet class, probably, would be relatively slow. I can not fully agree with you here. IIRC, BitSet already uses long array to store bits instead of Byte[] in our implementation. Every bit in any long of the long array corresponds to a enum type element. IMHO, this is the most effcient way to store bits. The only down side of using BitSet is that there are extra method invokations. > I'd suggest > to handle extra case when the number of elements in the enum is <= 64 > and it > is possible to represent the set with one long value. For this case > all the > EnumSet API could be implemented using fast bitwise operations. Since the long array storage, no matter the number of elements in an enum type, fast bitwise operations can be applied. Do you mean to do extra optimization when number of elements in enum type is less than 64. Under this condition, may be we can use one long type instead of a long array. But will this kind of optimization bring any bonus is unknown right now. Correct me if I am wrong. Best regards > > Thank you. > -- > Oleg Khaschansky, > Intel MPD > > On 8/3/06, Spark Shen wrote: >> >> Richard Liang 写道: >> > >> > >> > Spark Shen wrote: >> >> Hi All: >> >> >> >> IMHO, EnumSet provides a set view of enum types. According to its >> >> spec, "Enum sets are represented internally as bit vectors". >> >> To avoid to re-invent the wheel, it could be more reasonable to >> >> utilize java.util.BitSet class to support the implementation of >> EnumSet. >> >> >> > Agree :-) >> > >> >> While current API methods provided by BitSet is not enough, I need to >> >> extend the function provided by BitSet. There are 2 options: >> >> 1. Implement these extension methods in BitSet directly as package >> >> private methods >> >> 2. Construct a package private utility class in >> >> org.apache.harmony.luni.util package, and implement extensions in >> >> this implementation class. >> >> >> >> I prefer the first option, since there is not many classes need these >> >> extension. If no objections, I will adopt the first schema. >> >> >> > IMHO, it depends on the relationship between the extended functions >> > and the whole class. Would you please provide more detail information? >> > Thanks a lot. >> 1. It can be simply detected that on RI, EnumSet.noneOf() or >> EnumSet.allOf() method will return a concrete EnumSet. This concrete >> EnumSet provides its own iterator. >> All these iterator related methods are not implemented in BitSet right >> now. >> >> 2. To support the implementation of EnumSet, more utility methods used >> to set/unset bits may need to be added. >> >> All these requirements are EnumSet specific, do they need to be >> implemented in a separate class. >> >> Best regards >> > >> > Richard. >> >> Best regards. >> >> >> > >> >> >> -- >> Spark Shen >> China Software Development Lab, IBM >> >> >> >> --------------------------------------------------------------------- >> Terms of use : http://incubator.apache.org/harmony/mailing.html >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org >> >> > -- Spark Shen China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org