[all packages] [package net.sf.pizzacompiler.lang] [class hierarchy] [index]

public final class net.sf.pizzacompiler.lang.ListBuffer<A>

(source file: /home/enno/source/tmp/pizza/main/src/net/sf/pizzacompiler/lang/ListBuffer.pizza)
java.lang.Object
   |
   +----net.sf.pizzacompiler.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

Constuctor Index

O ListBuffer()
Constructs an empty List buffer.

Methods

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

Constructors

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

Methods

O length
public int length();
Returns the length (element count) of the buffer.

O 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

O 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

O 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

O 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.

O 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.

O 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.

O 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.

O elements

public Enumeration<A> elements();
Returns an enumeration of all elements.

O toList

public List<A> toList();
Converts to a List representing the data in the buffer.

O toString

public String toString();
Returns a string representation of this buffer.

Overrides:
toString in class Object


[all packages] [package net.sf.pizzacompiler.lang] [class hierarchy] [index]
net.sf.pizzacompiler.lang.ListBuffer.html