Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EEF82CE33 for ; Wed, 6 Jun 2012 02:04:08 +0000 (UTC) Received: (qmail 78727 invoked by uid 500); 6 Jun 2012 02:04:08 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 78671 invoked by uid 500); 6 Jun 2012 02:04:08 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 78662 invoked by uid 99); 6 Jun 2012 02:04:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2012 02:04:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2012 02:04:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2E9F2238899C for ; Wed, 6 Jun 2012 02:03:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1346705 - /commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java Date: Wed, 06 Jun 2012 02:03:47 -0000 To: commits@commons.apache.org From: dblevins@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120606020347.2E9F2238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dblevins Date: Wed Jun 6 02:03:46 2012 New Revision: 1346705 URL: http://svn.apache.org/viewvc?rev=1346705&view=rev Log: Some history on why this list implementation exists Modified: commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java Modified: commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java?rev=1346705&r1=1346704&r2=1346705&view=diff ============================================================================== --- commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java (original) +++ commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/util/SingleLinkedList.java Wed Jun 6 02:03:46 2012 @@ -23,6 +23,36 @@ import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; +/** + * Arraylist was initially used to hold class metadata, this proved wasteful + * + * This metadata is typically list of parameters, list of interfaces, + * list of methods, list of constructors, list of fields, and of course + * list of annotations. + * + * ArrayList defaults to 10 entries. A basic ClassInfo would therefore + * take a minimum of 50 x 64 bits of just array addressing for even an + * empty object with no fields, methods, constructors, interfaces or + * annotations. + * + * Every added field or method would incur another 10 x 64 bits of array + * space. Each method would incur another 10 x 64 bits for the params list + * and 10 x 64 bits for the annotations list for each param. + * + * Using a linked list cuts that down to fractions of the addressing space. + * The built-in VM LinkedList is a doubly linked list. + * + * Using a singly linked list cuts that address space down to half of + * that required for a doubly linked list. + * + * This works out fine as the code in question only adds elements in an + * unordered fashion and all iteration is forward only. + * + * So while this list implementation is not complete, it saves + * significantly on memory by cutting down on unused address space. + * + * @param + */ public class SingleLinkedList implements List { private Entry entry; @@ -90,6 +120,14 @@ public class SingleLinkedList impleme return true; } + public boolean addAll(Collection c) { + for (E e : c) { + add(e); + } + + return true; + } + public boolean remove(Object o) { throw new UnsupportedOperationException("remove"); } @@ -98,10 +136,6 @@ public class SingleLinkedList impleme throw new UnsupportedOperationException("containsAll"); } - public boolean addAll(Collection c) { - throw new UnsupportedOperationException("addAll"); - } - public boolean addAll(int index, Collection c) { throw new UnsupportedOperationException("addAll"); }