Package com.strobel.collections
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 TypeFieldDescriptionint
The number of element in this buffer.The list of elements of this buffer.A pointer pointing to the last, sentinel element of `elements'.boolean
Has a list been created from this buffer yet? -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(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 void
clear()
boolean
Does the list contain the specified element?boolean
containsAll
(Collection<?> c) private void
copy()
Copy list and sets last.first()
The first element in this buffer.boolean
isEmpty()
Is buffer empty?iterator()
An enumeration of all elements in this buffer.static <T> ListBuffer
<T> lb()
int
length()
Return the number of elements in this buffer.next()
Return first element in this buffer and removeboolean
nonEmpty()
Is buffer not empty?static <T> ListBuffer
<T> of
(T x) boolean
peek()
poll()
Prepend an element to buffer.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
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 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, 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:
clear
in interfaceCollection<A>
- Overrides:
clear
in classAbstractQueue<A>
-
length
public int length()Return the number of elements in this buffer. -
size
public int size()- Specified by:
size
in interfaceCollection<A>
- Specified by:
size
in classAbstractCollection<A>
-
isEmpty
public boolean isEmpty()Is buffer empty?- Specified by:
isEmpty
in interfaceCollection<A>
- Overrides:
isEmpty
in 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:
contains
in interfaceCollection<A>
- Overrides:
contains
in classAbstractCollection<A>
-
toArray
Convert buffer to an array- Specified by:
toArray
in interfaceCollection<A>
- Overrides:
toArray
in classAbstractCollection<A>
-
toArray
- Specified by:
toArray
in interfaceCollection<A>
- Overrides:
toArray
in classAbstractCollection<A>
-
first
The first element in this buffer. -
next
Return first element in this buffer and remove -
iterator
An enumeration of all elements in this buffer.- Specified by:
iterator
in interfaceCollection<A>
- Specified by:
iterator
in interfaceIterable<A>
- Specified by:
iterator
in classAbstractCollection<A>
-
add
- Specified by:
add
in interfaceCollection<A>
- Specified by:
add
in interfaceQueue<A>
- Overrides:
add
in classAbstractQueue<A>
-
remove
- Specified by:
remove
in interfaceCollection<A>
- Overrides:
remove
in classAbstractCollection<A>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<A>
- Overrides:
containsAll
in classAbstractCollection<A>
-
addAll
- Specified by:
addAll
in interfaceCollection<A>
- Overrides:
addAll
in classAbstractQueue<A>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<A>
- Overrides:
removeAll
in classAbstractCollection<A>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<A>
- Overrides:
retainAll
in classAbstractCollection<A>
-
offer
-
poll
-
peek
-