Class TLcdCharArrayList

All Implemented Interfaces:
ILcdCharList, ILcdCloneable, Cloneable, Iterable<Character>, Collection<Character>, List<Character>, SequencedCollection<Character>

public class TLcdCharArrayList extends AbstractList<Character> implements Cloneable, ILcdCharList
Array-based implementation of ILcdCharList.
Since:
9.0
  • Constructor Details

    • TLcdCharArrayList

      public TLcdCharArrayList()
      Creates a new, empty TLcdCharArrayList.
    • TLcdCharArrayList

      public TLcdCharArrayList(int aInitialCapacity)
      Creates a new, empty TLcdCharArrayList with the specified initial capacity.
      Parameters:
      aInitialCapacity - the initial capacity of this list.
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Collection<Character>
      Specified by:
      size in interface List<Character>
      Specified by:
      size in class AbstractCollection<Character>
    • get

      public Character get(int index)
      Specified by:
      get in interface List<Character>
      Specified by:
      get in class AbstractList<Character>
    • set

      public Character set(int index, Character element)
      Specified by:
      set in interface List<Character>
      Overrides:
      set in class AbstractList<Character>
    • add

      public void add(int index, Character element)
      Specified by:
      add in interface List<Character>
      Overrides:
      add in class AbstractList<Character>
    • addAll

      public boolean addAll(Collection<? extends Character> c)
      Specified by:
      addAll in interface Collection<Character>
      Specified by:
      addAll in interface List<Character>
      Overrides:
      addAll in class AbstractCollection<Character>
    • addAll

      public boolean addAll(int index, Collection<? extends Character> c)
      Specified by:
      addAll in interface List<Character>
      Overrides:
      addAll in class AbstractList<Character>
    • addAll

      public boolean addAll(int aIndex, char[] aValues, int aOffset, int aLength)
      Description copied from interface: ILcdCharList
      Adds aLength integer values from the given array to this list, starting from the given aOffset
      Specified by:
      addAll in interface ILcdCharList
      Parameters:
      aIndex - The position in this list where to start inserting the given integer values.
      aValues - The array containing the integer values to add to this list
      aOffset - The offset in aValues from where to start copying the integer values
      aLength - The number of integer values to copy from aValues to this list.
      Returns:
      Whether this list was modified as a result of this call.
    • remove

      public Character remove(int index)
      Specified by:
      remove in interface List<Character>
      Overrides:
      remove in class AbstractList<Character>
    • getChar

      public char getChar(int aIndex)
      Description copied from interface: ILcdCharList
      Returns the value at the specified position in this list.
      Specified by:
      getChar in interface ILcdCharList
      Parameters:
      aIndex - index of the value to return
      Returns:
      the value at the specified position in this list
    • setChar

      public char setChar(int aIndex, char aValue)
      Description copied from interface: ILcdCharList
      Replaces the value at the specified position in this list with the specified value (optional operation).
      Specified by:
      setChar in interface ILcdCharList
      Parameters:
      aIndex - index of the value to replace
      aValue - value to be stored at the specified position
      Returns:
      the value previously at the specified position
    • addChar

      public boolean addChar(char aValue)
      Description copied from interface: ILcdCharList
      Appends the specified value to the end of this list (optional operation).
      Specified by:
      addChar in interface ILcdCharList
      Parameters:
      aValue - value to be appended to this list
      Returns:
      true
    • addChar

      public void addChar(int aIndex, char aValue)
      Description copied from interface: ILcdCharList
      Inserts the specified value at the specified position in this list (optional operation). Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices).
      Specified by:
      addChar in interface ILcdCharList
      Parameters:
      aIndex - index at which the specified value is to be inserted
      aValue - value to be inserted
    • removeChar

      public boolean removeChar(char aValue)
      Description copied from interface: ILcdCharList
      Removes the first occurrence of the specified value from this list, if it is present (optional operation). If this list does not contain the value, it is unchanged. Returns true if this list contained the specified value (or equivalently, if this list changed as a result of the call).
      Specified by:
      removeChar in interface ILcdCharList
      Parameters:
      aValue - value to be removed from this list, if present
      Returns:
      true if this list contained the specified value
    • removeChar

      public char removeChar(int aIndex)
      Description copied from interface: ILcdCharList
      Removes the value at the specified position in this list (optional operation). Shifts any subsequent values to the left (subtracts one from their indices). Returns the value that was removed from the list.
      Specified by:
      removeChar in interface ILcdCharList
      Parameters:
      aIndex - the index of the value to be removed
      Returns:
      the value previously at the specified position
    • toCharArray

      public char[] toCharArray()
      Description copied from interface: ILcdCharList
      Returns an array containing all of the values in this list in proper sequence (from first to last value). The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array.
      Specified by:
      toCharArray in interface ILcdCharList
      Returns:
      an array containing all of the values in this list in proper sequence
    • toCharArray

      public char[] toCharArray(char[] anArray)
      Description copied from interface: ILcdCharList
      Returns an array containing all of the values in this list in proper sequence (from first to last value); If the list fits in the specified array, t is returned therein. Otherwise, a new array is allocated with the size of this list. If the list fits in the specified array with room to spare (i.e., the array has more values than the list), the value in the array immediately following the end of the list is set to 0. (This is useful in determining the length of the list only if the caller knows that the list does not contain any 0 values.)
      Specified by:
      toCharArray in interface ILcdCharList
      Parameters:
      anArray - the array into which the values of this list are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
      Returns:
      an array containing the values of this list
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<Character>
      Specified by:
      clear in interface List<Character>
      Overrides:
      clear in class AbstractList<Character>
    • binarySearch

      public int binarySearch(char aKey)
      Performs a binary search on this list. It behaves exactly like Collections.binarySearch(List, Object).

      The list must be sorted into ascending order according to the natural ordering of its elements (as by the Collections.sort(List) method) prior to making this call. If it is not sorted, the results are undefined. If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found.

      Parameters:
      aKey - the value to search
      Returns:
      the index as defined on Collections.binarySearch(List, Object)
    • clone

      public TLcdCharArrayList clone()
      Description copied from interface: ILcdCharList
      Creates and returns a copy of this object.
      Specified by:
      clone in interface ILcdCharList
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      Returns:
      a copy of this object.
      See Also:
    • ensureCapacity

      public void ensureCapacity(int minCapacity)
      Increases the capacity of this list to the specified capacity. This method has no effect if the specified capacity is smaller than the current capacity.
      Parameters:
      minCapacity - the new capacity for this list.
    • trimToSize

      public void trimToSize()
      Trims the internal data array of this list to match the size of this list.
    • indexOf

      public int indexOf(Object aO)
      Specified by:
      indexOf in interface List<Character>
      Overrides:
      indexOf in class AbstractList<Character>
    • indexOfChar

      public int indexOfChar(char aValue)
      Description copied from interface: ILcdCharList
      Returns the index of the first occurrence of the specified value in this list, or -1 if this list does not contain the value.
      Specified by:
      indexOfChar in interface ILcdCharList
      Parameters:
      aValue - value to search for
      Returns:
      the index of the first occurrence of the specified value in this list, or -1 if this list does not contain the value
    • lastIndexOf

      public int lastIndexOf(Object aO)
      Specified by:
      lastIndexOf in interface List<Character>
      Overrides:
      lastIndexOf in class AbstractList<Character>
    • lastIndexOfChar

      public int lastIndexOfChar(char aValue)
      Description copied from interface: ILcdCharList
      Returns the index of the last occurrence of the specified value in this list, or -1 if this list does not contain the value.
      Specified by:
      lastIndexOfChar in interface ILcdCharList
      Parameters:
      aValue - value to search for
      Returns:
      the index of the last occurrence of the specified value in this list, or -1 if this list does not contain the value
    • containsChar

      public boolean containsChar(char aValue)
      Description copied from interface: ILcdCharList
      Returns true if this list contains the specified value.
      Specified by:
      containsChar in interface ILcdCharList
      Parameters:
      aValue - value whose presence in this list is to be tested
      Returns:
      true if this list contains the specified value
    • contains

      public boolean contains(Object aO)
      Specified by:
      contains in interface Collection<Character>
      Specified by:
      contains in interface List<Character>
      Overrides:
      contains in class AbstractCollection<Character>