[all packages]
[package pizza.lang]
[class hierarchy]
[index]
public final class pizza.lang.ListBuffer<A>
(source file: pizza/lang/ListBuffer.pizza)
java.lang.Object
|
+----pizza.lang.ListBuffer<A>
The pure class interface.
public final class ListBuffer<A>
implements java.io.Serializable
-
This Class is a growable buffer for lists. It's modelled after class
java.lang.StringBuffer. It is mainly used to create Lists.
Note that the method toList() does not create a copy of the
internal buffer. Instead the buffer is marked as shared. Any
further changes to the buffer will cause a copy to be made.
- Parameters:
- A - the type of elements to store in the ListBuffer
- See also:
- List

ListBuffer()
-
Constructs an empty List buffer.

append(A)
- Appends a new element to the end and returns the buffer.
If the buffer was shared a copy of
elements()
- Returns an enumeration of all elements.
getAt(int)
-
Returns an element of the buffer.
insert(int, A)
-
Inserts an element into this buffer.
length()
-
Returns the length (element count) of the buffer.
prepend(A)
-
Prepends an element to the beginning of this buffer.
remove(int)
- Removes first `n' elements in this buffer.
setAt(int, A)
-
Updates an element in the buffer.
setLength(int)
- Truncates buffer to a maximum of `n' elements.
toList()
-
Converts to a List representing the data in the buffer.
toString()
-
Returns a string representation of this buffer.

ListBuffer
public ListBuffer();
-
Constructs an empty List buffer.

length
public int length();
-
Returns the length (element count) of the buffer.
setLength
public synchronized void setLength(int n);
- Truncates buffer to a maximum of `n' elements.
- Parameters:
- n - the new count of elements in the buffer
- Throws:
- IndexOutOfBoundsException -if n < 0
-
remove
public synchronized void remove(int n);
- Removes first `n' elements in this buffer.
- Parameters:
- n - the number of elements to be removed
- Throws:
- IndexOutOfBoundsException -if n < 0
-
append
public synchronized ListBuffer<A> append(A elem);
- Appends a new element to the end and returns the buffer.
If the buffer was shared a copy of this buffer is returned.
- Parameters:
- elem - the element to be appended
- Returns:
- the buffer with elem as last element
prepend
public synchronized ListBuffer<A> prepend(A elem);
-
Prepends an element to the beginning of this buffer.
- Parameters:
- elem - the element to be appended
- Returns:
- the ListBuffer itself, NOT a new one.
insert
public synchronized ListBuffer<A> insert(int offset,
A elem);
-
Inserts an element into this buffer.
- Parameters:
- offset - the offset at which to insert, 0 <= offset <= length
- elem - the element to insert
- Returns:
- the ListBuffer itself, NOT a new one.
- Throws:
- IndexOutOfBoundsException -If the offset is invalid.
-
getAt
public A getAt(int offset);
-
Returns an element of the buffer.
- Parameters:
- offset - the offset of the element to return
- Throws:
- IndexOutOfBoundsException -If the offset is invalid.
-
setAt
public synchronized ListBuffer<A> setAt(int offset,
A elem);
-
Updates an element in the buffer.
- Parameters:
- offset - the offset at which to update
- elem - the new element
- Returns:
- the ListBuffer itself, NOT a new one.
- Throws:
- IndexOutOfBoundsException -If the offset is invalid.
-
elements
public Enumeration<A> elements();
- Returns an enumeration of all elements.
toList
public List<A> toList();
-
Converts to a List representing the data in the buffer.
toString
public String toString();
-
Returns a string representation of this buffer.
- Overrides:
- toString in class Object
[all packages]
[package pizza.lang]
[class hierarchy]
[index]
pizza.lang.ListBuffer.html