APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.util

public Class ListBuffer<A>

extends AbstractQueue<A>
Class Inheritance
Imports
java.util.AbstractQueue, .Collection, .Iterator, .NoSuchElementException

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

This is NOT part of any supported API. 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

Modifier and TypeField and Description
private int
count

The number of element in this buffer.

private List<A>
elems

The list of elements of this buffer.

private List<A>
last

A pointer pointing to the last element of 'elems' containing data, or null if the list is empty.

private boolean
shared

Has a list been created from this buffer yet?

Constructor Summary

AccessConstructor and Description
public
ListBuffer()

Create a new initially empty list buffer.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(A a)

Overrides java.util.AbstractQueue.add.

Implements java.util.Queue.add, java.util.Collection.add.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

public boolean
addAll(Collection<? extends A> c)

Overrides java.util.AbstractQueue.addAll.

Implements java.util.Collection.addAll.

Adds all of the elements in the specified collection to this queue.

public ListBuffer<A>
append(A x)

Append an element to buffer.

public ListBuffer<A>
appendArray(A[] xs)

Append all elements in an array to buffer.

public ListBuffer<A>
appendList(List<A> xs)

Append all elements in a list to buffer.

public ListBuffer<A>
appendList(ListBuffer<A> xs)

Append all elements in a list to buffer.

public final void
clear()

Overrides java.util.AbstractQueue.clear.

Implements java.util.Collection.clear.

Removes all of the elements from this queue.

public boolean
contains(Object x)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Does the list contain the specified element?

public boolean
containsAll(Collection<?> c)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Collection.containsAll.

Returns true if this collection contains all of the elements in the specified collection.

private void
copy()

Copy list and sets last.

public A
first()

The first element in this buffer.

public boolean
public Iterator<A>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

An enumeration of all elements in this buffer.

public A
last()

public int
length()

Return the number of elements in this buffer.

public A
next()

Return first element in this buffer and remove

public boolean
nonEmpty()

Is buffer not empty?

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

public boolean
offer(A a)

Implements java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.

public A
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

public A
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

public ListBuffer<A>
prepend(A x)

Prepend an element to buffer.

public boolean
remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation).

public boolean
removeAll(Collection<?> c)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

public boolean
retainAll(Collection<?> c)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation).

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Returns the number of elements in this collection.

public <T> T[]
toArray(T[] vec)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Convert buffer to an array

public Object[]
toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.

public List<A>
toList()

Convert buffer to a list of all its elements.

Inherited from java.util.AbstractQueue:
elementremove

Field Detail

countback to summary
private int count

The number of element in this buffer.

elemsback to summary
private List<A> elems

The list of elements of this buffer.

lastback to summary
private List<A> last

A pointer pointing to the last element of 'elems' containing data, or null if the list is empty.

sharedback to summary
private boolean shared

Has a list been created from this buffer yet?

Constructor Detail

ListBufferback to summary
public ListBuffer()

Create a new initially empty list buffer.

Method Detail

addback to summary
public boolean add(A a)

Overrides java.util.AbstractQueue.add.

Implements java.util.Queue.add, java.util.Collection.add.

Doc from java.util.AbstractQueue.add.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

This implementation returns true if offer succeeds, else throws an IllegalStateException.

addAllback to summary
public boolean addAll(Collection<? extends A> c)

Overrides java.util.AbstractQueue.addAll.

Implements java.util.Collection.addAll.

Doc from java.util.AbstractQueue.addAll.

Adds all of the elements in the specified collection to this queue. Attempts to addAll of a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

This implementation iterates over the specified collection, and adds each element returned by the iterator to this queue, in turn. A runtime exception encountered while trying to add an element (including, in particular, a null element) may result in only some of the elements having been successfully added when the associated exception is thrown.

appendback to summary
public ListBuffer<A> append(A x)

Append an element to buffer.

appendArrayback to summary
public ListBuffer<A> appendArray(A[] xs)

Append all elements in an array to buffer.

appendListback to summary
public ListBuffer<A> appendList(List<A> xs)

Append all elements in a list to buffer.

appendListback to summary
public ListBuffer<A> appendList(ListBuffer<A> xs)

Append all elements in a list to buffer.

clearback to summary
public final void clear()

Overrides java.util.AbstractQueue.clear.

Implements java.util.Collection.clear.

Doc from java.util.AbstractQueue.clear.

Removes all of the elements from this queue. The queue will be empty after this call returns.

This implementation repeatedly invokes poll until it returns null.

containsback to summary
public boolean contains(Object x)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Does the list contain the specified element?

containsAllback to summary
public boolean containsAll(Collection<?> c)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Collection.containsAll.

Doc from java.util.Collection.containsAll.

Returns true if this collection contains all of the elements in the specified collection.

copyback to summary
private void copy()

Copy list and sets last.

firstback to summary
public A first()

The first element in this buffer.

isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Is buffer empty?

iteratorback to summary
public Iterator<A> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

An enumeration of all elements in this buffer.

lastback to summary
public A last()
lengthback to summary
public int length()

Return the number of elements in this buffer.

nextback to summary
public A next()

Return first element in this buffer and remove

nonEmptyback to summary
public boolean nonEmpty()

Is buffer not empty?

ofback to summary
public static <T> ListBuffer<T> of(T x)
offerback to summary
public boolean offer(A a)

Implements java.util.Queue.offer.

Doc from java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add, which can fail to insert an element only by throwing an exception.

peekback to summary
public A peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

pollback to summary
public A poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

prependback to summary
public ListBuffer<A> prepend(A x)

Prepend an element to buffer.

removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Collection.remove.

Doc from java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

removeAllback to summary
public boolean removeAll(Collection<?> c)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.Collection.removeAll.

Doc from java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

retainAllback to summary
public boolean retainAll(Collection<?> c)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.Collection.retainAll.

Doc from java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

toArrayback to summary
public <T> T[] toArray(T[] vec)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Convert buffer to an array

toArrayback to summary
public Object[] toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's runtime component type is Object.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

toListback to summary
public List<A> toList()

Convert buffer to a list of all its elements.