Class AbstractCharCollection
java.lang.Object
com.uwyn.jhighlight.pcj.AbstractCharCollection
- All Implemented Interfaces:
CharCollection
- Direct Known Subclasses:
AbstractCharSet
This class represents an abstract base for implementing
collections of char values. All operations that can be implemented
using iterators are implemented as such. In most cases, this is
hardly an efficient solution, and at least some of those
methods should be overridden by sub-classes.
In this implementation, size() is calculated by iterating over the collection. Make sure that size() is overwritten or that iterators do not depend on the size() method.
- Since:
- 1.0
- Version:
- 1.3 21-08-2003 20:16
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor to be invoked by sub-classes. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(char v) Throws UnsupportedOperationException.booleanAdds all the elements of a specified collection to this collection.voidclear()Clears this collection.booleancontains(char v) Indicates whether this collection contains a specified element.booleanIndicates whether all elements of a specified collection is contained in this collection.booleanisEmpty()Indicates whether this collection is empty.booleanremove(char v) Removes a specified element from this collection.booleanRemoves all the elements of a specified collection from this collection.booleanRetains only the elements of a specified collection in this collection.intsize()Returns the number of elements in this collection.char[]toArray()Returns the elements of this collection as an array.char[]toArray(char[] a) Returns the elements of this collection as an array.toString()Returns a string representation of this collection.voidDoes nothing.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CharCollection
equals, hashCode, iterator
-
Constructor Details
-
AbstractCharCollection
protected AbstractCharCollection()Default constructor to be invoked by sub-classes.
-
-
Method Details
-
add
public boolean add(char v) Throws UnsupportedOperationException.- Specified by:
addin interfaceCharCollection- Parameters:
v- the element to add to this collection.- Returns:
- true if this collection was modified as a result of adding v; returns false otherwise.
- Throws:
UnsupportedOperationException- unconditionally.- See Also:
-
addAll
Description copied from interface:CharCollectionAdds all the elements of a specified collection to this collection.- Specified by:
addAllin interfaceCharCollection- Parameters:
c- the collection whose elements to add to this collection.- Returns:
- true if this collection was modified as a result of adding the elements of c; returns false otherwise.
- See Also:
-
clear
public void clear()Description copied from interface:CharCollectionClears this collection.- Specified by:
clearin interfaceCharCollection
-
contains
public boolean contains(char v) Description copied from interface:CharCollectionIndicates whether this collection contains a specified element.- Specified by:
containsin interfaceCharCollection- Parameters:
v- the element to test for containment.- Returns:
- true if v is contained in this collection; returns false otherwise.
- See Also:
-
containsAll
Description copied from interface:CharCollectionIndicates whether all elements of a specified collection is contained in this collection.- Specified by:
containsAllin interfaceCharCollection- Parameters:
c- the collection whose elements to test for containment.- Returns:
- true if all the elements of c are contained in this collection; returns false otherwise.
- See Also:
-
isEmpty
public boolean isEmpty()Description copied from interface:CharCollectionIndicates whether this collection is empty.- Specified by:
isEmptyin interfaceCharCollection- Returns:
- true if this collection is empty; returns false otherwise.
-
remove
public boolean remove(char v) Description copied from interface:CharCollectionRemoves a specified element from this collection.- Specified by:
removein interfaceCharCollection- Parameters:
v- the char value to remove from this collection.- Returns:
- true if this collection was modified as a result of removing v; returns false otherwise.
-
removeAll
Description copied from interface:CharCollectionRemoves all the elements of a specified collection from this collection.- Specified by:
removeAllin interfaceCharCollection- Parameters:
c- the collection whose elements to remove from this collection.- Returns:
- true if this collection was modified as a result of removing the elements of c; returns false otherwise.
-
retainAll
Description copied from interface:CharCollectionRetains only the elements of a specified collection in this collection.- Specified by:
retainAllin interfaceCharCollection- Parameters:
c- the collection whose elements to retain in this collection.- Returns:
- true if this collection was modified as a result of removing the elements not contained in c; returns false otherwise.
-
size
public int size()Description copied from interface:CharCollectionReturns the number of elements in this collection.- Specified by:
sizein interfaceCharCollection- Returns:
- the number of elements in this collection.
-
toArray
public char[] toArray()Description copied from interface:CharCollectionReturns the elements of this collection as an array.- Specified by:
toArrayin interfaceCharCollection- Returns:
- a new array containing the elements of this collection.
-
toArray
public char[] toArray(char[] a) Description copied from interface:CharCollectionReturns the elements of this collection as an array.- Specified by:
toArrayin interfaceCharCollection- Parameters:
a- an array to fill with the elements of this collection; if a is null or not big enough to contain all the elements of this collection, an new array is allocated, and a is not changed.- Returns:
- a, if a has room for all the elements of this collection; otherwise a new array is allocated, filled with the elements of this collection, and returned.
-
trimToSize
public void trimToSize()Does nothing. Sub-classes may provide an implementation to minimize memory usage, but this is not required since many implementations will always have minimal memory usage.- Specified by:
trimToSizein interfaceCharCollection
-
toString
-