Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 64775 invoked from network); 10 Dec 2006 15:50:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Dec 2006 15:50:45 -0000 Received: (qmail 68966 invoked by uid 500); 10 Dec 2006 15:50:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 68743 invoked by uid 500); 10 Dec 2006 15:50:52 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 68733 invoked by uid 99); 10 Dec 2006 15:50:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Dec 2006 07:50:52 -0800 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [192.18.1.36] (HELO gmp-ea-fw-1.sun.com) (192.18.1.36) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Dec 2006 07:50:40 -0800 Received: from d1-emea-09.sun.com (d1-emea-09.sun.com [192.18.2.119]) by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id kBAFoH9Z029968 for ; Sun, 10 Dec 2006 15:50:19 GMT Received: from conversion-daemon.d1-emea-09.sun.com by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0JA200701EG6C700@d1-emea-09.sun.com> (original mail from Dyre.Tjeldvoll@Sun.COM) for derby-dev@db.apache.org; Sun, 10 Dec 2006 15:50:17 +0000 (GMT) Received: from khepri29.sun.com ([129.159.112.241]) by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0JA200DFOENS8H00@d1-emea-09.sun.com> for derby-dev@db.apache.org; Sun, 10 Dec 2006 15:50:17 +0000 (GMT) Date: Sun, 10 Dec 2006 16:50:16 +0100 From: Dyre.Tjeldvoll@Sun.COM Subject: Some questions about FormatableBitSet Sender: Dyre.Tjeldvoll@Sun.COM To: Derby Development Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org There are a couple of things in the implementation of this class that I just don't understand: - The doc for the method grow() says: "ASSUMPTIONS: that all extra bits in the last byte are zero". But in other methods (or() and()...) great care is taken mask out the bits of the last byte that isn't part of the bitset. But if it is an invariant of the class that these unused bits are zero, it should be possible to do most operations byte by byte with no special handling of the last byte, right? - in or() (but not in and() or xor()) an explicit test is done on whether the argument of type FormatableBitSet is "instanceof FormatableBitSet". Will it not always be? It could have been a subclass I suppose, but since FormatableBitSet is final that becomes a bit hypothetical. - A minor nit: This class appears to do a lot of division and remainder calculations with powers of 2 (frequently 8). Is it not generally preferably to do this with shifts and bitwise ANDs? - The algorithm for finding the number of bits set seems a bit simple (iterating over all bits, and counting those for which isSet() returns true). A simple google search will give a number of ways of calculating the number of bits in a byte quickly. Is there a reason not to use such an algorithm and iterate over the bytes, rather than the bits? -- dt