All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.objectspace.jgl.adapters.CharBuffer

java.lang.Object
   |
   +----COM.objectspace.jgl.adapters.CharBuffer

public class CharBuffer
extends Object
implements Sequence
A CharBuffer is a sequence that is very similar to a regular CharArray, except that it can expand to accomodate new elements.

The implementation store elements in a contiguous linear memory space so that index-based access is very quick. When an CharBuffer's originally allocated memory space is exceeded, its elements are copied into a new memory space that is large enough to accomodate everything.

If an insertion causes reallocation, all iterators and references are invalidated; otherwise, only the iterators and references after the insertion point are invalidated.

A remove invalidates all of the iterators and references after the point of the remove.

See Also:
CharArray, CharIterator

Constructor Index

 o CharBuffer()
Construct myself to be an empty CharBuffer.
 o CharBuffer(char[])
Construct myself to use a specified array as my initial storage.
 o CharBuffer(CharBuffer)
Construct myself to be a copy of an existing CharBuffer.
 o CharBuffer(int)
Construct myself to contain a specified number of null elements.
 o CharBuffer(int, char)
Construct myself to contain a specified number of elements set to a particular object.

Method Index

 o add(char)
Add a char after my last element.
 o add(Object)
Add an object after my last element.
 o at(int)
Return the element at the specified index.
 o back()
Return my last element.
 o begin()
Return an iterator positioned at my first item.
 o capacity()
Return the number of elements that I contain without allocating more internal storage.
 o charAt(int)
Return the char at the specified index.
 o clear()
Remove all of my elements.
 o clone()
Return a shallow copy of myself.
 o contains(char)
Return true if I contain a particular char.
 o contains(Object)
Return true if I contain a particular object using .equals()
 o copy(CharBuffer)
Become a shallow copy of an existing CharBuffer.
 o copyTo(char[])
Copy my elements into the specified array.
 o count(char)
Return the number of objects that equal a particular value.
 o count(int, int, char)
Return the number of objects within a particular range of indices that match a particular char.
 o count(int, int, Object)
Return the number of objects within a particular range of indices that match a particular value.
 o count(Object)
Return the number of objects that match a particular value.
 o elements()
Return an Enumeration of my components.
 o end()
Return an iterator positioned immediately after my last item.
 o ensureCapacity(int)
Pre-allocate enough space to hold a specified number of elements.
 o equals(char[])
Return true if I contain the same items in the same order as a native array of chars.
 o equals(CharArray)
Return true if I contain the same items in the same order as a CharArray.
 o equals(CharBuffer)
Return true if I contain the same items in the same order as another CharBuffer.
 o equals(Object)
Return true if I'm equal to another object.
 o finish()
Return an iterator positioned immediately after my last item.
 o front()
Return my first element.
 o get()
Retrieve the underlying primitive array.
 o hashCode()
Return my hash code for support of hashing containers
 o indexOf(char)
Return the index of the first char that matches a particular value, or -1 if the value is not found.
 o indexOf(int, int, char)
Return the index of the first char within a range of indices that match a particular value, or -1 if the char is not found.
 o indexOf(int, int, Object)
Return the index of the first object within a range of indices that match a particular object, or -1 if the object is not found.
 o indexOf(Object)
Return the index of the first object that matches a particular value, or -1 if the object is not found.
 o insert(CharIterator, char)
Insert a value at a particular position and return an iterator positioned at the new element.
 o insert(CharIterator, ForwardIterator, ForwardIterator)
Insert a sequence of objects at a particular location.
 o insert(CharIterator, int, char)
Insert multiple values at a particular position.
 o insert(CharIterator, int, Object)
Insert multiple objects at a particular position.
 o insert(CharIterator, Object)
Insert an object at a particular position and return an iterator positioned at the new element.
 o insert(int, char)
Insert a value at a particular index.
 o insert(int, ForwardIterator, ForwardIterator)
Insert a sequence of objects at a particular index.
 o insert(int, int, char)
Insert multiple objects at a particular index.
 o insert(int, int, Object)
Insert multiple objects at a particular index.
 o insert(int, Object)
Insert an object at a particular index.
 o isEmpty()
Return true if I contain no objects.
 o maxSize()
Return the maximum number of entries that I can contain.
 o popBack()
Remove and return my last element.
 o popFront()
Remove and return my first element.
 o pushBack(char)
Add a char after my last element.
 o pushBack(Object)
Add an object after my last element.
 o pushFront(char)
Insert a value in front of my first element.
 o pushFront(Object)
Insert an object in front of my first element.
 o put(int, char)
Set the char at the specified index to a particular value.
 o put(int, Object)
Set the element at the specified index to a particular object.
 o remove(Enumeration)
Remove the element at a particular position.
 o remove(Enumeration, Enumeration)
Remove the elements in the specified range.
 o remove(int)
Remove the element at a particular index.
 o remove(int, int)
Remove the elements within a range of indices.
 o remove(int, int, Object)
Remove all elements within a range of indices that match a particular object and return the number of objects that were removed.
 o remove(Object)
Remove all elements that match a particular object and return the number of objects that were removed.
 o remove(Object, int)
Remove at most a given number of elements that match a particular object and return the number of objects that were removed.
 o replace(char, char)
Replace all chars that match a particular object with a new value and return the number of objects that were replaced.
 o replace(int, int, char, char)
Replace all values within a range of indices that match a particular char with a new value and return the number of objects that were replaced.
 o replace(int, int, Object, Object)
Replace all elements within a range of indices that match a particular object with a new value and return the number of objects that were replaced.
 o replace(Object, Object)
Replace all elements that match a particular object with a new value and return the number of objects that were replaced.
 o setSize(int)
Sets the size of the CharBuffer.
 o size()
Return the number of entries that I contain.
 o start()
Return an iterator positioned at my first item.
 o swap(CharBuffer)
Swap my contents with another CharBuffer.
 o toString()
Return a string that describes me.
 o trimToSize()
If my storage space is currently larger than my total number of elements, reallocate the elements into a storage space that is exactly the right size.

Constructors

 o CharBuffer
 public CharBuffer()
Construct myself to be an empty CharBuffer.

 o CharBuffer
 public CharBuffer(int size)
Construct myself to contain a specified number of null elements.

Parameters:
size - The number of elements to contain.
Throws: IllegalArgumentException
If size is negative.
 o CharBuffer
 public CharBuffer(int size,
                   char object)
Construct myself to contain a specified number of elements set to a particular object.

Parameters:
size - The number of elements to contain.
object - The initial value of each element.
Throws: IllegalArgumentException
If size is negative.
 o CharBuffer
 public CharBuffer(char array[])
Construct myself to use a specified array as my initial storage.

Parameters:
The - array to use as initial storage.
 o CharBuffer
 public CharBuffer(CharBuffer array)
Construct myself to be a copy of an existing CharBuffer.

Parameters:
array - The CharBuffer to copy.

Methods

 o clone
 public synchronized Object clone()
Return a shallow copy of myself.

Overrides:
clone in class Object
 o equals
 public boolean equals(Object object)
Return true if I'm equal to another object.

Parameters:
object - The object to compare myself against.
Overrides:
equals in class Object
 o equals
 public boolean equals(CharBuffer buffer)
Return true if I contain the same items in the same order as another CharBuffer.

Parameters:
array - The CharBuffer to compare myself against.
 o equals
 public synchronized boolean equals(CharArray array)
Return true if I contain the same items in the same order as a CharArray.

Parameters:
array - The CharArray to compare myself against.
 o equals
 public boolean equals(char array[])
Return true if I contain the same items in the same order as a native array of chars.

Parameters:
array - The array to compare myself against.
 o toString
 public synchronized String toString()
Return a string that describes me.

Overrides:
toString in class Object
 o copy
 public synchronized void copy(CharBuffer buffer)
Become a shallow copy of an existing CharBuffer.

Parameters:
array - The CharBuffer that I shall become a shallow copy of.
 o copyTo
 public synchronized void copyTo(char array[])
Copy my elements into the specified array. The number of items that are copied is equal to the smaller of my length and the size of the specified array.

Parameters:
array - The array that I shall copy my elements into.
 o get
 public synchronized char[] get()
Retrieve the underlying primitive array.

 o hashCode
 public synchronized int hashCode()
Return my hash code for support of hashing containers

Overrides:
hashCode in class Object
 o isEmpty
 public boolean isEmpty()
Return true if I contain no objects.

 o back
 public Object back()
Return my last element.

 o front
 public Object front()
Return my first element.

 o size
 public int size()
Return the number of entries that I contain.

 o capacity
 public int capacity()
Return the number of elements that I contain without allocating more internal storage.

 o maxSize
 public int maxSize()
Return the maximum number of entries that I can contain.

 o at
 public Object at(int index)
Return the element at the specified index.

Parameters:
index - The index.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o charAt
 public synchronized char charAt(int index)
Return the char at the specified index.

Parameters:
index - The index.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o put
 public synchronized void put(int index,
                              Object object)
Set the element at the specified index to a particular object.

Parameters:
index - The index.
object - The object.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o put
 public synchronized void put(int index,
                              char object)
Set the char at the specified index to a particular value.

Parameters:
index - The index.
object - The value.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o clear
 public synchronized void clear()
Remove all of my elements.

 o remove
 public Object remove(Enumeration pos)
Remove the element at a particular position.

Parameters:
pos - An enumeration positioned at the element to remove.
Throws: IllegalArgumentException
is the Enumeration isn't an CharIterator for this CharBuffer object.
 o remove
 public synchronized Object remove(int index)
Remove the element at a particular index.

Parameters:
index - The index of the element to remove.
Returns:
The object removed.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o remove
 public int remove(Enumeration first,
                   Enumeration last)
Remove the elements in the specified range.

Parameters:
first - An Enumeration positioned at the first element to remove.
last - An Enumeration positioned immediately after the last element to remove.
Returns:
The number of elements removed.
Throws: IllegalArgumentException
is the Enumeration isn't an CharIterator for this CharBuffer object.
 o remove
 public synchronized int remove(int first,
                                int last)
Remove the elements within a range of indices.

Parameters:
first - The index of the first element to remove.
last - The index of the last element to remove.
Returns:
The number of elements removed.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o popBack
 public synchronized Object popBack()
Remove and return my last element.

Throws: InvalidOperationException
If the CharBuffer is empty.
 o add
 public synchronized Object add(Object object)
Add an object after my last element. Returns null. This function is a synonym for pushBack().

Parameters:
object - The object to add.
 o add
 public synchronized void add(char object)
Add a char after my last element. Returns null. This function is a synonym for pushBack().

Parameters:
object - The object to add.
 o pushBack
 public void pushBack(Object object)
Add an object after my last element.

Parameters:
The - object to add.
 o pushBack
 public void pushBack(char object)
Add a char after my last element.

Parameters:
The - object to add.
 o insert
 public CharIterator insert(CharIterator pos,
                            Object object)
Insert an object at a particular position and return an iterator positioned at the new element.

Parameters:
pos - An iterator positioned at the element that the object will be inserted immediately before.
object - The object to insert.
 o insert
 public CharIterator insert(CharIterator pos,
                            char object)
Insert a value at a particular position and return an iterator positioned at the new element.

Parameters:
pos - An iterator positioned at the element that the object will be inserted immediately before.
object - The object to insert.
 o insert
 public void insert(int index,
                    Object object)
Insert an object at a particular index.

Parameters:
index - The index of the element that the object will be inserted immediately before.
object - The object to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o insert
 public synchronized void insert(int index,
                                 char object)
Insert a value at a particular index.

Parameters:
index - The index of the element that the object will be inserted immediately before.
object - The value to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
 o insert
 public void insert(CharIterator pos,
                    int n,
                    Object object)
Insert multiple objects at a particular position.

Parameters:
pos - An iterator positioned at the element before which the elements will be inserted.
n - The number of objects to insert.
object - The object to insert.
 o insert
 public void insert(CharIterator pos,
                    int n,
                    char object)
Insert multiple values at a particular position.

Parameters:
pos - An iterator positioned at the element before which the elements will be inserted.
n - The number of values to insert.
object - The value to insert.
 o insert
 public void insert(int index,
                    int n,
                    Object object)
Insert multiple objects at a particular index.

Parameters:
index - The index of the element immediately before the values will be inserted.
object - The object to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
Throws: IllegalArgumentException
If the number of values is negative.
 o insert
 public synchronized void insert(int index,
                                 int n,
                                 char object)
Insert multiple objects at a particular index.

Parameters:
index - The index of the element immediately before the values will be inserted.
object - The value to insert.
Throws: IndexOutOfBoundsException
If the index is invalid.
Throws: IllegalArgumentException
If the number of values is negative.
 o insert
 public void insert(CharIterator pos,
                    ForwardIterator first,
                    ForwardIterator last)
Insert a sequence of objects at a particular location.

Parameters:
pos - The location of the element that the objects will be inserted immediately before.
first - An iterator positioned at the first element to insert.
last - An iterator positioned immediately after the last element to insert.
 o insert
 public synchronized void insert(int index,
                                 ForwardIterator first,
                                 ForwardIterator last)
Insert a sequence of objects at a particular index.

Parameters:
index - The index of the element that the objects will be inserted immediately before.
first - An iterator positioned at the first element to insert.
last - An iterator positioned immediately after the last element to insert.
 o swap
 public synchronized void swap(CharBuffer array)
Swap my contents with another CharBuffer.

Parameters:
array - The CharBuffer that I will swap my contents with.
 o elements
 public Enumeration elements()
Return an Enumeration of my components.

 o start
 public ForwardIterator start()
Return an iterator positioned at my first item.

 o finish
 public ForwardIterator finish()
Return an iterator positioned immediately after my last item.

 o begin
 public synchronized CharIterator begin()
Return an iterator positioned at my first item.

 o end
 public synchronized CharIterator end()
Return an iterator positioned immediately after my last item.

 o trimToSize
 public synchronized void trimToSize()
If my storage space is currently larger than my total number of elements, reallocate the elements into a storage space that is exactly the right size.

 o ensureCapacity
 public synchronized void ensureCapacity(int n)
Pre-allocate enough space to hold a specified number of elements. This operation does not change the value returned by size().

Parameters:
n - The amount of space to pre-allocate.
Throws: IllegalArgumentException
If the specified size is negative.
 o popFront
 public synchronized Object popFront()
Remove and return my first element.

Throws: InvalidOperationException
If the CharBuffer is empty.
 o pushFront
 public void pushFront(Object object)
Insert an object in front of my first element.

Parameters:
object - The object to insert.
 o pushFront
 public void pushFront(char object)
Insert a value in front of my first element.

Parameters:
object - The object to insert.
 o remove
 public int remove(Object object)
Remove all elements that match a particular object and return the number of objects that were removed.

Parameters:
object - The object to remove.
 o remove
 public synchronized int remove(Object object,
                                int count)
Remove at most a given number of elements that match a particular object and return the number of objects that were removed.

Parameters:
object - The object to remove.
count - The maximum number of objects to remove.
 o remove
 public synchronized int remove(int first,
                                int last,
                                Object object)
Remove all elements within a range of indices that match a particular object and return the number of objects that were removed.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
object - The object to remove.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o replace
 public int replace(Object oldValue,
                    Object newValue)
Replace all elements that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
oldValue - The object to be replaced.
newValue - The value to substitute.
 o replace
 public int replace(char oldValue,
                    char newValue)
Replace all chars that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
oldValue - The char to be replaced.
newValue - The value to substitute.
 o replace
 public int replace(int first,
                    int last,
                    Object oldValue,
                    Object newValue)
Replace all elements within a range of indices that match a particular object with a new value and return the number of objects that were replaced.

Parameters:
first - The index of the first object to be considered.
last - The index just past the last object to be considered.
oldValue - The object to be replaced.
newValue - The value to substitute.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o replace
 public synchronized int replace(int first,
                                 int last,
                                 char oldValue,
                                 char newValue)
Replace all values within a range of indices that match a particular char with a new value and return the number of objects that were replaced.

Parameters:
first - The index of the first element to be considered.
last - The index just past the last element to be considered.
oldValue - The char to be replaced.
newValue - The value to substitute.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o count
 public int count(Object object)
Return the number of objects that match a particular value.

Parameters:
object - The object to count.
 o count
 public int count(char object)
Return the number of objects that equal a particular value.

Parameters:
object - The char to count.
 o count
 public int count(int first,
                  int last,
                  Object object)
Return the number of objects within a particular range of indices that match a particular value.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o count
 public synchronized int count(int first,
                               int last,
                               char object)
Return the number of objects within a particular range of indices that match a particular char.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o indexOf
 public int indexOf(Object object)
Return the index of the first object that matches a particular value, or -1 if the object is not found. Uses .equals() to find a match

Parameters:
object - The object to find.
Throws: ClassCastException
if objects are not Boolean
 o indexOf
 public int indexOf(char object)
Return the index of the first char that matches a particular value, or -1 if the value is not found.

Parameters:
object - The char to find.
 o indexOf
 public int indexOf(int first,
                    int last,
                    Object object)
Return the index of the first object within a range of indices that match a particular object, or -1 if the object is not found.

Parameters:
first - The index of the first object to consider.
last - The index of the last object to consider.
object - The object to find.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o indexOf
 public synchronized int indexOf(int first,
                                 int last,
                                 char object)
Return the index of the first char within a range of indices that match a particular value, or -1 if the char is not found.

Parameters:
first - The index of the first value to consider.
last - The index of the last value to consider.
object - The value to find.
Throws: IndexOutOfBoundsException
If either index is invalid.
 o setSize
 public synchronized void setSize(int newSize)
Sets the size of the CharBuffer. if the size shrinks, the extra elements (at the end of the array) are lost; if the size increases, the new elements are set to null.

Parameters:
newSize - The new size of the CharBuffer.
 o contains
 public boolean contains(Object object)
Return true if I contain a particular object using .equals()

Parameters:
object - The object in question.
 o contains
 public boolean contains(char object)
Return true if I contain a particular char.

Parameters:
object - The char for which ot search.

All Packages  Class Hierarchy  This Package  Previous  Next  Index