Class ListBuffer<A>
java.lang.Object
java.util.AbstractCollection<A>
java.util.AbstractQueue<A>
com.strobel.collections.ListBuffer<A>
- All Implemented Interfaces:
Iterable<A>, Collection<A>, Queue<A>
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
FieldsModifier and TypeFieldDescriptionintThe number of element in this buffer.The list of elements of this buffer.A pointer pointing to the last, sentinel element of `elements'.booleanHas a list been created from this buffer yet? -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends A> c) Append an element to buffer.appendArray(A[] xs) Append all elements in an array to buffer.appendList(ImmutableList<A> xs) Append all elements in a list to buffer.appendList(ListBuffer<A> xs) Append all elements in a list to buffer.final voidclear()booleanDoes the list contain the specified element?booleancontainsAll(Collection<?> c) private voidcopy()Copy list and sets last.first()The first element in this buffer.booleanisEmpty()Is buffer empty?iterator()An enumeration of all elements in this buffer.static <T> ListBuffer<T> lb()intlength()Return the number of elements in this buffer.next()Return first element in this buffer and removebooleannonEmpty()Is buffer not empty?static <T> ListBuffer<T> of(T x) booleanpeek()poll()Prepend an element to buffer.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] vec) Convert buffer to an arraytoList()Convert buffer to a list of all its elements.Methods inherited from class AbstractQueue
element, removeMethods inherited from class AbstractCollection
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
elements
The list of elements of this buffer. -
last
A pointer pointing to the last, sentinel element of `elements'. -
count
public int countThe number of element in this buffer.
-
-
Constructor Details
-
ListBuffer
public ListBuffer()Create a new initially empty list buffer.
-
-
Method Details
-
lb
-
of
-
clear
public final void clear()- Specified by:
clearin interfaceCollection<A>- Overrides:
clearin classAbstractQueue<A>
-
length
public int length()Return the number of elements in this buffer. -
size
public int size()- Specified by:
sizein interfaceCollection<A>- Specified by:
sizein classAbstractCollection<A>
-
isEmpty
public boolean isEmpty()Is buffer empty?- Specified by:
isEmptyin interfaceCollection<A>- Overrides:
isEmptyin classAbstractCollection<A>
-
nonEmpty
public boolean nonEmpty()Is buffer not empty? -
copy
private void copy()Copy list and sets last. -
prepend
Prepend an element to buffer. -
append
Append an element to buffer. -
appendList
Append all elements in a list to buffer. -
appendList
Append all elements in a list to buffer. -
appendArray
Append all elements in an array to buffer. -
toList
Convert buffer to a list of all its elements. -
contains
Does the list contain the specified element?- Specified by:
containsin interfaceCollection<A>- Overrides:
containsin classAbstractCollection<A>
-
toArray
Convert buffer to an array- Specified by:
toArrayin interfaceCollection<A>- Overrides:
toArrayin classAbstractCollection<A>
-
toArray
- Specified by:
toArrayin interfaceCollection<A>- Overrides:
toArrayin classAbstractCollection<A>
-
first
The first element in this buffer. -
next
Return first element in this buffer and remove -
iterator
-
add
- Specified by:
addin interfaceCollection<A>- Specified by:
addin interfaceQueue<A>- Overrides:
addin classAbstractQueue<A>
-
remove
- Specified by:
removein interfaceCollection<A>- Overrides:
removein classAbstractCollection<A>
-
containsAll
- Specified by:
containsAllin interfaceCollection<A>- Overrides:
containsAllin classAbstractCollection<A>
-
addAll
- Specified by:
addAllin interfaceCollection<A>- Overrides:
addAllin classAbstractQueue<A>
-
removeAll
- Specified by:
removeAllin interfaceCollection<A>- Overrides:
removeAllin classAbstractCollection<A>
-
retainAll
- Specified by:
retainAllin interfaceCollection<A>- Overrides:
retainAllin classAbstractCollection<A>
-
offer
-
poll
-
peek
-