|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.toy.lang.TWordBuffer
public class TWordBuffer
TWordBuffer is essentially a vector for TWords. The main need for a TWordBuffer is that java.util.Vector allows null values to be added, whereas the Visual X-TOY really needs a vector class which does not permit null values. This class is thread-safe.
Constructor Summary | |
---|---|
TWordBuffer()
Constructs a new buffer with an initial capacity of 50. |
|
TWordBuffer(int capacity)
Constructs a new buffer with the given initial capacity. |
Method Summary | |
---|---|
void |
add(TWord word)
Adds the specified TWord to the end of the buffer. |
void |
add(TWord[] array)
Adds the contents of one TWordBuffer to the end of this buffer. |
void |
add(TWord[] array,
int offset,
int length)
Adds the contents of one TWordBuffer to the end of this buffer. |
void |
add(TWordBuffer buffer)
Adds the contents of one TWordBuffer to the end of this buffer. |
void |
clear()
Sets the size of the buffer to 0. |
Object |
clone()
Returns a clone of this TWordBuffer (the array objects will be reallocated and copied. |
boolean |
equals(Object obj)
Returns wheter or not two buffers contain the same data. |
int |
getSize()
Returns the number of lines we have so far. |
TWord |
getWord(int index)
Returns the TWord at the given index. |
TWord |
pop()
Returns the TWord at the beginning of the buffer after removing it from the buffer. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TWordBuffer()
public TWordBuffer(int capacity)
Method Detail |
---|
public Object clone()
clone
in class Object
public void clear()
public void add(TWordBuffer buffer)
word
- The TWordBuffer whose contents are to be added. A NullPointerException will be
thrown if this is null.public void add(TWord[] array)
array
- The array of TWords to add to this buffer. A NullPointerException will be
thrown if this is null.public void add(TWord[] array, int offset, int length)
array
- The array of TWords to add to this buffer. A NullPointerException will be
thrown if this is null.offset
- The offset at which to begin copying. An invalid value will result in an
ArrayIndexOutOfBoundsException.length
- The number of words to copy. An invalid value will result in an
ArrayIndexOutOfBoundsException.public void add(TWord word)
word
- The TWord to be added. A NullPointerException will be thrown if this is null.public TWord pop()
return
- The TWord which was at the beginning of the buffer.public TWord getWord(int index)
index
- The index of the desired word.
public int getSize()
public boolean equals(Object obj)
equals
in class Object
obj
- The Object to compare this buffer to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |