EMMA Coverage Report (generated Thu Dec 06 15:24:05 GMT 2007)
[all classes][com.sun.tools.javac.util]

COVERAGE SUMMARY FOR SOURCE FILE [ListBuffer.java]

nameclass, %method, %block, %line, %
ListBuffer.java50%  (1/2)42%  (13/31)43%  (126/294)48%  (32.6/68)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListBuffer$10%   (0/1)0%   (0/4)0%   (0/46)0%   (0/9)
ListBuffer$1 (ListBuffer): void 0%   (0/1)0%   (0/11)0%   (0/2)
hasNext (): boolean 0%   (0/1)0%   (0/10)0%   (0/1)
next (): Object 0%   (0/1)0%   (0/21)0%   (0/5)
remove (): void 0%   (0/1)0%   (0/4)0%   (0/1)
     
class ListBuffer100% (1/1)48%  (13/27)51%  (126/248)54%  (32.6/60)
add (Object): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
addAll (Collection): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
appendArray (Object []): ListBuffer 0%   (0/1)0%   (0/16)0%   (0/3)
appendList (ListBuffer): ListBuffer 0%   (0/1)0%   (0/5)0%   (0/1)
contains (Object): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
containsAll (Collection): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
copy (): void 0%   (0/1)0%   (0/41)0%   (0/10)
first (): Object 0%   (0/1)0%   (0/4)0%   (0/1)
iterator (): Iterator 0%   (0/1)0%   (0/5)0%   (0/1)
prepend (Object): ListBuffer 0%   (0/1)0%   (0/14)0%   (0/3)
remove (Object): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
removeAll (Collection): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
retainAll (Collection): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
toArray (): Object [] 0%   (0/1)0%   (0/6)0%   (0/1)
append (Object): ListBuffer 100% (1/1)94%  (29/31)93%  (5.6/6)
ListBuffer (): void 100% (1/1)100% (5/5)100% (3/3)
appendList (List): ListBuffer 100% (1/1)100% (14/14)100% (4/4)
clear (): void 100% (1/1)100% (18/18)100% (5/5)
isEmpty (): boolean 100% (1/1)100% (7/7)100% (1/1)
lb (): ListBuffer 100% (1/1)100% (4/4)100% (1/1)
length (): int 100% (1/1)100% (3/3)100% (1/1)
next (): Object 100% (1/1)100% (8/8)100% (3/3)
nonEmpty (): boolean 100% (1/1)100% (7/7)100% (1/1)
remove (): void 100% (1/1)100% (17/17)100% (4/4)
size (): int 100% (1/1)100% (3/3)100% (1/1)
toArray (Object []): Object [] 100% (1/1)100% (5/5)100% (1/1)
toList (): List 100% (1/1)100% (6/6)100% (2/2)

1/*
2 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 
26package com.sun.tools.javac.util;
27 
28import java.util.Collection;
29import java.util.Iterator;
30import java.util.NoSuchElementException;
31 
32/** A class for constructing lists by appending elements. Modelled after
33 *  java.lang.StringBuffer.
34 *
35 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
36 *  you write code that depends on this, you do so at your own risk.
37 *  This code and its internal interfaces are subject to change or
38 *  deletion without notice.</b>
39 */
40public class ListBuffer<A> implements Collection<A> {
41 
42    public static <T> ListBuffer<T> lb() {
43        return new ListBuffer<T>();
44    }
45 
46    /** The list of elements of this buffer.
47     */
48    public List<A> elems;
49 
50    /** A pointer pointing to the last, sentinel element of `elems'.
51     */
52    public List<A> last;
53 
54    /** The number of element in this buffer.
55     */
56    public int count;
57 
58    /** Has a list been created from this buffer yet?
59     */
60    public boolean shared;
61 
62    /** Create a new initially empty list buffer.
63     */
64    public ListBuffer() {
65        clear();
66    }
67 
68    public final void clear() {
69        this.elems = new List<A>(null,null);
70        this.last = this.elems;
71        count = 0;
72        shared = false;
73    }
74 
75    /** Return the number of elements in this buffer.
76     */
77    public int length() {
78        return count;
79    }
80    public int size() {
81        return count;
82    }
83 
84    /** Is buffer empty?
85     */
86    public boolean isEmpty() {
87        return count == 0;
88    }
89 
90    /** Is buffer not empty?
91     */
92    public boolean nonEmpty() {
93        return count != 0;
94    }
95 
96    /** Copy list and sets last.
97     */
98    private void copy() {
99        List<A> p = elems = new List<A>(elems.head, elems.tail);
100        while (true) {
101            List<A> tail = p.tail;
102            if (tail == null) break;
103            tail = new List<A>(tail.head, tail.tail);
104            p.setTail(tail);
105            p = tail;
106        }
107        last = p;
108        shared = false;
109    }
110 
111    /** Prepend an element to buffer.
112     */
113    public ListBuffer<A> prepend(A x) {
114        elems = elems.prepend(x);
115        count++;
116        return this;
117    }
118 
119    /** Append an element to buffer.
120     */
121    public ListBuffer<A> append(A x) {
122        if (shared) copy();
123        last.head = x;
124        last.setTail(new List<A>(null,null));
125        last = last.tail;
126        count++;
127        return this;
128    }
129 
130    /** Append all elements in a list to buffer.
131     */
132    public ListBuffer<A> appendList(List<A> xs) {
133        while (xs.nonEmpty()) {
134            append(xs.head);
135            xs = xs.tail;
136        }
137        return this;
138    }
139 
140    /** Append all elements in a list to buffer.
141     */
142    public ListBuffer<A> appendList(ListBuffer<A> xs) {
143        return appendList(xs.toList());
144    }
145 
146    /** Append all elements in an array to buffer.
147     */
148    public ListBuffer<A> appendArray(A[] xs) {
149        for (int i = 0; i < xs.length; i++) {
150            append(xs[i]);
151        }
152        return this;
153    }
154 
155    /** Convert buffer to a list of all its elements.
156     */
157    public List<A> toList() {
158        shared = true;
159        return elems;
160    }
161 
162    /** Does the list contain the specified element?
163     */
164    public boolean contains(Object x) {
165        return elems.contains(x);
166    }
167 
168    /** Convert buffer to an array
169     */
170    public <T> T[] toArray(T[] vec) {
171        return elems.toArray(vec);
172    }
173    public Object[] toArray() {
174        return toArray(new Object[size()]);
175    }
176 
177    /** The first element in this buffer.
178     */
179    public A first() {
180        return elems.head;
181    }
182 
183    /** Remove the first element in this buffer.
184     */
185    public void remove() {
186        if (elems != last) {
187            elems = elems.tail;
188            count--;
189        }
190    }
191 
192    /** Return first element in this buffer and remove
193     */
194    public A next() {
195        A x = elems.head;
196        remove();
197        return x;
198    }
199 
200    /** An enumeration of all elements in this buffer.
201     */
202    public Iterator<A> iterator() {
203        return new Iterator<A>() {
204            List<A> elems = ListBuffer.this.elems;
205            public boolean hasNext() {
206                return elems != last;
207            }
208            public A next() {
209                if (elems == last)
210                    throw new NoSuchElementException();
211                A elem = elems.head;
212                elems = elems.tail;
213                return elem;
214            }
215            public void remove() {
216                throw new UnsupportedOperationException();
217            }
218        };
219    }
220 
221    public boolean add(A a) {
222        throw new UnsupportedOperationException();
223    }
224    public boolean remove(Object o) {
225        throw new UnsupportedOperationException();
226    }
227    public boolean containsAll(Collection<?> c) {
228        throw new UnsupportedOperationException();
229    }
230    public boolean addAll(Collection<? extends A> c) {
231        throw new UnsupportedOperationException();
232    }
233    public boolean removeAll(Collection<?> c) {
234        throw new UnsupportedOperationException();
235    }
236    public boolean retainAll(Collection<?> c) {
237        throw new UnsupportedOperationException();
238    }
239}

[all classes][com.sun.tools.javac.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov