Class AbstractCharCollection
- java.lang.Object
-
- java.util.AbstractCollection<Character>
-
- org.codelibs.jhighlight.fastutil.chars.AbstractCharCollection
-
- All Implemented Interfaces:
Iterable<Character>
,Collection<Character>
,CharCollection
,CharIterable
- Direct Known Subclasses:
AbstractCharList
,AbstractCharSet
public abstract class AbstractCharCollection extends AbstractCollection<Character> implements CharCollection
An abstract class providing basic methods for collections implementing a type-specific interface.In particular, this class provide
iterator()
,add()
,remove(Object)
andcontains(Object)
methods that just call the type-specific counterpart.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCharCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(char k)
boolean
add(Character o)
Delegates to the corresponding type-specific method.boolean
addAll(Collection<? extends Character> c)
Adds all elements of the given collection to this collection.boolean
addAll(CharCollection c)
Adds all elements of the given type-specific collection to this collection.CharIterator
charIterator()
Deprecated.boolean
contains(char k)
boolean
contains(Object o)
Delegates to the corresponding type-specific method.boolean
containsAll(Collection<?> c)
Checks whether this collection contains all elements from the given collection.boolean
containsAll(CharCollection c)
Checks whether this collection contains all elements from the given type-specific collection.boolean
isEmpty()
abstract CharIterator
iterator()
Returns a type-specific iterator on the elements of this collection.boolean
rem(char k)
boolean
rem(Object o)
Delegates to the corresponding type-specific method.boolean
remove(Object ok)
Delegates to the type-specificrem()
method.boolean
removeAll(Collection<?> c)
Remove from this collection all elements in the given collection.boolean
removeAll(CharCollection c)
Remove from this collection all elements in the given type-specific collection.boolean
retainAll(Collection<?> c)
Retains in this collection only elements from the given collection.boolean
retainAll(CharCollection c)
Retains in this collection only elements from the given type-specific collection.Object[]
toArray()
char[]
toArray(char[] a)
Returns a primitive type array containing the items of this collection.<T> T[]
toArray(T[] a)
Returns an containing the items of this collection; the runtime type of the returned array is that of the specified array.char[]
toCharArray()
Returns a primitive type array containing the items of this collection.char[]
toCharArray(char[] a)
Returns a primitive type array containing the items of this collection.String
toString()
-
Methods inherited from class java.util.AbstractCollection
clear, size
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
clear, equals, hashCode, parallelStream, removeIf, size, spliterator, stream, toArray
-
-
-
-
Method Detail
-
toArray
public char[] toArray(char[] a)
Description copied from interface:CharCollection
Returns a primitive type array containing the items of this collection.Note that, contrarily to
Collection.toArray(Object[])
, this methods just writes all elements of this collection: no special value will be added after the last one.- Specified by:
toArray
in interfaceCharCollection
- Parameters:
a
- if this array is big enough, it will be used to store this collection.- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray(Object[])
-
toCharArray
public char[] toCharArray()
Description copied from interface:CharCollection
Returns a primitive type array containing the items of this collection.- Specified by:
toCharArray
in interfaceCharCollection
- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray()
-
toCharArray
public char[] toCharArray(char[] a)
Description copied from interface:CharCollection
Returns a primitive type array containing the items of this collection.Note that, contrarily to
Collection.toArray(Object[])
, this methods just writes all elements of this collection: no special value will be added after the last one.- Specified by:
toCharArray
in interfaceCharCollection
- Parameters:
a
- if this array is big enough, it will be used to store this collection.- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray(Object[])
-
addAll
public boolean addAll(CharCollection c)
Adds all elements of the given type-specific collection to this collection.- Specified by:
addAll
in interfaceCharCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection changed as a result of the call.- See Also:
Collection.addAll(Collection)
-
containsAll
public boolean containsAll(CharCollection c)
Checks whether this collection contains all elements from the given type-specific collection.- Specified by:
containsAll
in interfaceCharCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection contains all elements of the argument.- See Also:
Collection.containsAll(Collection)
-
retainAll
public boolean retainAll(CharCollection c)
Retains in this collection only elements from the given type-specific collection.- Specified by:
retainAll
in interfaceCharCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection changed as a result of the call.- See Also:
Collection.retainAll(Collection)
-
removeAll
public boolean removeAll(CharCollection c)
Remove from this collection all elements in the given type-specific collection.- Specified by:
removeAll
in interfaceCharCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection changed as a result of the call.- See Also:
Collection.removeAll(Collection)
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<Character>
- Overrides:
toArray
in classAbstractCollection<Character>
-
toArray
public <T> T[] toArray(T[] a)
Description copied from interface:CharCollection
Returns an containing the items of this collection; the runtime type of the returned array is that of the specified array.Warning: Note that, contrarily to
Collection.toArray(Object[])
, this methods just writes all elements of this collection: no special value will be added after the last one.- Specified by:
toArray
in interfaceCharCollection
- Specified by:
toArray
in interfaceCollection<Character>
- Overrides:
toArray
in classAbstractCollection<Character>
- Parameters:
a
- if this array is big enough, it will be used to store this collection.- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray(Object[])
-
addAll
public boolean addAll(Collection<? extends Character> c)
Adds all elements of the given collection to this collection.- Specified by:
addAll
in interfaceCollection<Character>
- Overrides:
addAll
in classAbstractCollection<Character>
- Parameters:
c
- a collection.- Returns:
true
if this collection changed as a result of the call.
-
add
public boolean add(char k)
- Specified by:
add
in interfaceCharCollection
- See Also:
Collection.add(Object)
-
charIterator
@Deprecated public CharIterator charIterator()
Deprecated.Delegates to the new covariantly stronger generic method.- Specified by:
charIterator
in interfaceCharCollection
- See Also:
CharCollection.iterator()
-
iterator
public abstract CharIterator iterator()
Description copied from interface:CharCollection
Returns a type-specific iterator on the elements of this collection.Note that this specification strengthens the one given in
Iterable.iterator()
, which was already strengthened in the corresponding type-specific class, but was weakened by the fact that this interface extendsCollection
.- Specified by:
iterator
in interfaceCharCollection
- Specified by:
iterator
in interfaceCharIterable
- Specified by:
iterator
in interfaceCollection<Character>
- Specified by:
iterator
in interfaceIterable<Character>
- Specified by:
iterator
in classAbstractCollection<Character>
- Returns:
- a type-specific iterator on the elements of this collection.
-
remove
public boolean remove(Object ok)
Delegates to the type-specificrem()
method.- Specified by:
remove
in interfaceCollection<Character>
- Overrides:
remove
in classAbstractCollection<Character>
-
add
public boolean add(Character o)
Delegates to the corresponding type-specific method.- Specified by:
add
in interfaceCollection<Character>
- Overrides:
add
in classAbstractCollection<Character>
-
rem
public boolean rem(Object o)
Delegates to the corresponding type-specific method.
-
contains
public boolean contains(Object o)
Delegates to the corresponding type-specific method.- Specified by:
contains
in interfaceCollection<Character>
- Overrides:
contains
in classAbstractCollection<Character>
-
contains
public boolean contains(char k)
- Specified by:
contains
in interfaceCharCollection
- See Also:
Collection.contains(Object)
-
rem
public boolean rem(char k)
Description copied from interface:CharCollection
Note that this method should be calledremove()
, but the clash with the similarly named index-based method in theList
interface forces us to use a distinguished name. For simplicity, the set interfaces reinstatesremove()
.- Specified by:
rem
in interfaceCharCollection
- See Also:
Collection.remove(Object)
-
containsAll
public boolean containsAll(Collection<?> c)
Checks whether this collection contains all elements from the given collection.- Specified by:
containsAll
in interfaceCollection<Character>
- Overrides:
containsAll
in classAbstractCollection<Character>
- Parameters:
c
- a collection.- Returns:
true
if this collection contains all elements of the argument.
-
retainAll
public boolean retainAll(Collection<?> c)
Retains in this collection only elements from the given collection.- Specified by:
retainAll
in interfaceCollection<Character>
- Overrides:
retainAll
in classAbstractCollection<Character>
- Parameters:
c
- a collection.- Returns:
true
if this collection changed as a result of the call.
-
removeAll
public boolean removeAll(Collection<?> c)
Remove from this collection all elements in the given collection. If the collection is an instance of this class, it uses faster iterators.- Specified by:
removeAll
in interfaceCollection<Character>
- Overrides:
removeAll
in classAbstractCollection<Character>
- Parameters:
c
- a collection.- Returns:
true
if this collection changed as a result of the call.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Character>
- Overrides:
isEmpty
in classAbstractCollection<Character>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<Character>
-
-