com.sun.tools.javac.util
Class ListBuffer<A>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<A>
          extended by com.sun.tools.javac.util.ListBuffer<A>
All Implemented Interfaces:
java.lang.Iterable<A>, java.util.Collection<A>, java.util.Queue<A>
Direct Known Subclasses:
Apt

public class ListBuffer<A>
extends java.util.AbstractQueue<A>

A class for constructing lists by appending elements. Modelled after java.lang.StringBuffer.

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Field Summary
 int count
          The number of element in this buffer.
 List<A> elems
          The list of elements of this buffer.
 List<A> last
          A pointer pointing to the last, sentinel element of `elems'.
 boolean shared
          Has a list been created from this buffer yet?
 
Constructor Summary
ListBuffer()
          Create a new initially empty list buffer.
 
Method Summary
 boolean add(A a)
           
 boolean addAll(java.util.Collection<? extends A> c)
           
 ListBuffer<A> append(A x)
          Append an element to buffer.
 ListBuffer<A> appendArray(A[] xs)
          Append all elements in an array to buffer.
 ListBuffer<A> appendList(List<A> xs)
          Append all elements in a list to buffer.
 ListBuffer<A> appendList(ListBuffer<A> xs)
          Append all elements in a list to buffer.
 void clear()
           
 boolean contains(java.lang.Object x)
          Does the list contain the specified element?
 boolean containsAll(java.util.Collection<?> c)
           
private  void copy()
          Copy list and sets last.
 A first()
          The first element in this buffer.
 boolean isEmpty()
          Is buffer empty?
 java.util.Iterator<A> iterator()
          An enumeration of all elements in this buffer.
static
<T> ListBuffer<T>
lb()
           
 int length()
          Return the number of elements in this buffer.
 A next()
          Return first element in this buffer and remove
 boolean nonEmpty()
          Is buffer not empty?
static
<T> ListBuffer<T>
of(T x)
           
 boolean offer(A a)
           
 A peek()
           
 A poll()
           
 ListBuffer<A> prepend(A x)
          Prepend an element to buffer.
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] vec)
          Convert buffer to an array
 List<A> toList()
          Convert buffer to a list of all its elements.
 
Methods inherited from class java.util.AbstractQueue
element, remove
 
Methods inherited from class java.util.AbstractCollection
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

elems

public List<A> elems
The list of elements of this buffer.


last

public List<A> last
A pointer pointing to the last, sentinel element of `elems'.


count

public int count
The number of element in this buffer.


shared

public boolean shared
Has a list been created from this buffer yet?

Constructor Detail

ListBuffer

public ListBuffer()
Create a new initially empty list buffer.

Method Detail

lb

public static <T> ListBuffer<T> lb()

of

public static <T> ListBuffer<T> of(T x)

clear

public final void clear()
Specified by:
clear in interface java.util.Collection<A>
Overrides:
clear in class java.util.AbstractQueue<A>

length

public int length()
Return the number of elements in this buffer.


size

public int size()
Specified by:
size in interface java.util.Collection<A>
Specified by:
size in class java.util.AbstractCollection<A>

isEmpty

public boolean isEmpty()
Is buffer empty?

Specified by:
isEmpty in interface java.util.Collection<A>
Overrides:
isEmpty in class java.util.AbstractCollection<A>

nonEmpty

public boolean nonEmpty()
Is buffer not empty?


copy

private void copy()
Copy list and sets last.


prepend

public ListBuffer<A> prepend(A x)
Prepend an element to buffer.


append

public ListBuffer<A> append(A x)
Append an element to buffer.


appendList

public ListBuffer<A> appendList(List<A> xs)
Append all elements in a list to buffer.


appendList

public ListBuffer<A> appendList(ListBuffer<A> xs)
Append all elements in a list to buffer.


appendArray

public ListBuffer<A> appendArray(A[] xs)
Append all elements in an array to buffer.


toList

public List<A> toList()
Convert buffer to a list of all its elements.


contains

public boolean contains(java.lang.Object x)
Does the list contain the specified element?

Specified by:
contains in interface java.util.Collection<A>
Overrides:
contains in class java.util.AbstractCollection<A>

toArray

public <T> T[] toArray(T[] vec)
Convert buffer to an array

Specified by:
toArray in interface java.util.Collection<A>
Overrides:
toArray in class java.util.AbstractCollection<A>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<A>
Overrides:
toArray in class java.util.AbstractCollection<A>

first

public A first()
The first element in this buffer.


next

public A next()
Return first element in this buffer and remove


iterator

public java.util.Iterator<A> iterator()
An enumeration of all elements in this buffer.

Specified by:
iterator in interface java.lang.Iterable<A>
Specified by:
iterator in interface java.util.Collection<A>
Specified by:
iterator in class java.util.AbstractCollection<A>

add

public boolean add(A a)
Specified by:
add in interface java.util.Collection<A>
Overrides:
add in class java.util.AbstractQueue<A>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<A>
Overrides:
remove in class java.util.AbstractCollection<A>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<A>
Overrides:
containsAll in class java.util.AbstractCollection<A>

addAll

public boolean addAll(java.util.Collection<? extends A> c)
Specified by:
addAll in interface java.util.Collection<A>
Overrides:
addAll in class java.util.AbstractQueue<A>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<A>
Overrides:
removeAll in class java.util.AbstractCollection<A>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<A>
Overrides:
retainAll in class java.util.AbstractCollection<A>

offer

public boolean offer(A a)

poll

public A poll()

peek

public A peek()