org.joda.primitives.list.impl
Class ArrayCharList

java.lang.Object
  extended by org.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Character>
      extended by org.joda.primitives.collection.impl.AbstractCharCollection
          extended by org.joda.primitives.list.impl.AbstractCharList
              extended by org.joda.primitives.list.impl.ArrayCharList
All Implemented Interfaces:
Cloneable, Iterable<Character>, Collection<Character>, List<Character>, CharCollection, PrimitiveCollection<Character>, CharIterable, CharList, PrimitiveList<Character>, PrimitiveCollectable<Character>

public class ArrayCharList
extends AbstractCharList
implements Cloneable

Array based implementation of CharList for primitive int elements.

This class implements List allowing seamless integration with other APIs.

Add, Remove, Set and Clear are supported.

Since:
1.0
Version:
CODE GENERATED
Author:
Stephen Colebourne, Rodney Waldhoff, Jason Tiscione

Nested Class Summary
 
Nested classes/interfaces inherited from class org.joda.primitives.list.impl.AbstractCharList
AbstractCharList.PListIterator
 
Constructor Summary
ArrayCharList()
          Constructor.
ArrayCharList(char[] values)
          Constructor that copies the specified values.
ArrayCharList(Collection<Character> coll)
          Constructor that copies the specified values.
ArrayCharList(int initialSize)
          Constructor that defines an initial size for the internal storage array.
 
Method Summary
 boolean add(int index, char value)
          Adds a primitive value to this collection.
 boolean addAll(int index, char[] values)
          Adds an array of primitive values to this collection at a specified index.
protected  void arrayCopy(int fromIndex, char[] dest, int destIndex, int size)
          Copies data from this collection into the specified array.
 void clear()
          Clears the collection/map of all elements.
 Object clone()
          Clone implementation that calls Object clone().
 boolean contains(char value)
          Checks whether this collection contains a specified primitive value.
protected  void ensureCapacity(int capacity)
          Ensures that the internal storage array has at least the specified size.
 char getChar(int index)
          Gets the primitive value at the specified index.
protected  boolean isAddModifiable()
          Are the add methods supported.
 boolean isModifiable()
          Checks whether the object can currently be modified.
protected  boolean isRemoveModifiable()
          Are the remove methods supported.
protected  boolean isSetModifiable()
          Are the remove methods supported.
 void optimize()
          Optimizes the implementation.
 char removeCharAt(int index)
          Removes a primitive value by index from the list.
 boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
          Removes a range of values from the list.
 char set(int index, char value)
          Sets the primitive value at a specified index.
 int size()
          Gets the current size of the collection.
 String toStringContents()
          Gets the contents of the list as a String.
 
Methods inherited from class org.joda.primitives.list.impl.AbstractCharList
add, add, add, addAll, addAll, checkIndex, checkIndexExists, checkRange, checkSetModifiable, equals, first, firstChar, get, hashCode, indexOf, indexOf, indexOf, indexOf, iterator, last, lastChar, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeChar, set, subList, toCharArray
 
Methods inherited from class org.joda.primitives.collection.impl.AbstractCharCollection
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toCharArray, toCharArray, toObject, toPrimitive, toPrimitiveArray, toString
 
Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable
isEmpty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
isEmpty
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from interface org.joda.primitives.collection.CharCollection
addAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toCharArray, toCharArray
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
isEmpty
 

Constructor Detail

ArrayCharList

public ArrayCharList()
Constructor.


ArrayCharList

public ArrayCharList(int initialSize)
Constructor that defines an initial size for the internal storage array.

Parameters:
initialSize - the initial size of the internal array, negative treated as zero

ArrayCharList

public ArrayCharList(char[] values)
Constructor that copies the specified values.

Parameters:
values - an array of values to copy, null treated as zero size array

ArrayCharList

public ArrayCharList(Collection<Character> coll)
Constructor that copies the specified values.

Parameters:
coll - a collection of values to copy, null treated as zero size collection
Method Detail

size

public int size()
Gets the current size of the collection.

Specified by:
size in interface Collection<Character>
Specified by:
size in interface List<Character>
Specified by:
size in interface PrimitiveCollectable<Character>
Returns:
the current size

getChar

public char getChar(int index)
Gets the primitive value at the specified index.

Specified by:
getChar in interface CharList
Parameters:
index - the index to get from
Returns:
value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid

add

public boolean add(int index,
                   char value)
Adds a primitive value to this collection.

Specified by:
add in interface CharList
Overrides:
add in class AbstractCharList
Parameters:
index - the index to insert at
value - the value to add to this collection
Returns:
true if this collection was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid

removeCharAt

public char removeCharAt(int index)
Removes a primitive value by index from the list.

Specified by:
removeCharAt in interface CharList
Overrides:
removeCharAt in class AbstractCharList
Parameters:
index - the index to remove from
Returns:
the primitive value previously at this index
Throws:
IndexOutOfBoundsException - if the index is invalid

removeRange

public boolean removeRange(int fromIndexInclusive,
                           int toIndexExclusive)
Removes a range of values from the list.

Specified by:
removeRange in interface PrimitiveList<Character>
Overrides:
removeRange in class AbstractCharList
Parameters:
fromIndexInclusive - the start of the range to remove, inclusive
toIndexExclusive - the end of the range to remove, exclusive
Returns:
true if the collection was modified

set

public char set(int index,
                char value)
Sets the primitive value at a specified index.

Specified by:
set in interface CharList
Overrides:
set in class AbstractCharList
Parameters:
index - the index to set
value - the value to store
Returns:
the previous value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid

optimize

public void optimize()
Optimizes the implementation.

This implementation changes the internal array to be the same size as the size of the collection.

Specified by:
optimize in interface PrimitiveCollectable<Character>
Overrides:
optimize in class AbstractPrimitiveCollectable<Character>

clear

public void clear()
Clears the collection/map of all elements.

This implementation resets the size, but does not reduce the internal storage array.

The collection/map will have a zero size after this method completes.

Specified by:
clear in interface Collection<Character>
Specified by:
clear in interface List<Character>
Specified by:
clear in interface PrimitiveCollectable<Character>
Overrides:
clear in class AbstractCharList

contains

public boolean contains(char value)
Checks whether this collection contains a specified primitive value.

This implementation accesses the internal storage array directly.

Specified by:
contains in interface CharCollection
Overrides:
contains in class AbstractCharList
Parameters:
value - the value to search for
Returns:
true if the value is found

addAll

public boolean addAll(int index,
                      char[] values)
Adds an array of primitive values to this collection at a specified index.

Specified by:
addAll in interface CharList
Overrides:
addAll in class AbstractCharList
Parameters:
index - the index to add at
values - the values to add to this collection
Returns:
true if this collection was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid

toStringContents

public String toStringContents()
Gets the contents of the list as a String.

Specified by:
toStringContents in interface CharList
Overrides:
toStringContents in class AbstractCharList
Returns:
the list contents

isAddModifiable

protected boolean isAddModifiable()
Are the add methods supported.

Overrides:
isAddModifiable in class AbstractCharCollection
Returns:
true

isRemoveModifiable

protected boolean isRemoveModifiable()
Are the remove methods supported.

Overrides:
isRemoveModifiable in class AbstractCharCollection
Returns:
true

isSetModifiable

protected boolean isSetModifiable()
Are the remove methods supported.

Overrides:
isSetModifiable in class AbstractCharList
Returns:
true

isModifiable

public boolean isModifiable()
Checks whether the object can currently be modified.

Specified by:
isModifiable in interface PrimitiveCollectable<Character>
Overrides:
isModifiable in class AbstractCharList
Returns:
true

clone

public Object clone()
Clone implementation that calls Object clone().

Specified by:
clone in interface PrimitiveCollectable<Character>
Overrides:
clone in class AbstractPrimitiveCollectable<Character>
Returns:
the clone

arrayCopy

protected void arrayCopy(int fromIndex,
                         char[] dest,
                         int destIndex,
                         int size)
Copies data from this collection into the specified array. This method is pre-validated.

Overrides:
arrayCopy in class AbstractCharList
Parameters:
fromIndex - the index to start from
dest - the destination array
destIndex - the destination start index
size - the number of items to copy

ensureCapacity

protected void ensureCapacity(int capacity)
Ensures that the internal storage array has at least the specified size.

Parameters:
capacity - the amount to expand to


Copyright © 2005-2010 Joda.org. All Rights Reserved.