Documentation of 'org.matheclipse.core.generic.util.HMArrayList' Java class
HMArrayList
org.matheclipse.core.generic.util

Class HMArrayList<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess
    Direct Known Subclasses:
    AST


    public class HMArrayList<E>
    extends java.util.AbstractList<E>
    implements java.util.List<E>, java.lang.Cloneable, java.io.Serializable, java.util.RandomAccess
    HMArrayList is an implementation of List, backed by an array. All optional operations adding, removing, and replacing are supported. The elements can be any objects. Copied and modified from the Apache Harmony project.
    Since:
    1.2
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      HMArrayList()
      Constructs a new instance of ArrayList with ten capacity.
      HMArrayList(java.util.Collection<? extends E> collection)
      Constructs a new instance of ArrayList containing the elements of the specified collection.
      HMArrayList(E ex, E... es) 
      HMArrayList(int capacity)
      Constructs a new instance of ArrayList with the specified capacity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean add(E object)
      Adds the specified object at the end of this ArrayList.
      void add(int location, E object)
      Inserts the specified object into this ArrayList at the specified location.
      boolean addAll(java.util.Collection<? extends E> collection)
      Adds the objects in the specified collection to this ArrayList.
      boolean addAll(int location, java.util.Collection<? extends E> collection)
      Inserts the objects in the specified collection at the specified location in this List.
      void clear()
      Removes all elements from this ArrayList, leaving it empty.
      java.lang.Object clone()
      Returns a new ArrayList with the same elements, the same size and the same capacity as this ArrayList.
      boolean contains(java.lang.Object object)
      Searches this ArrayList for the specified object.
      void ensureCapacity(int minimumCapacity)
      Ensures that after this operation the ArrayList can hold the specified number of elements without further growing.
      boolean equals(java.lang.Object obj) 
      E get(int location) 
      int hashCode() 
      int indexOf(java.lang.Object object) 
      boolean isEmpty() 
      boolean isSameHead(E head)
      Check if the object at index 0 (i.e.
      boolean isSameHead(E head, int length)
      Check if the object at index 0 (i.e.
      boolean isSameHeadSizeGE(E head, int length)
      Check if the object at index 0 (i.e.
      int lastIndexOf(java.lang.Object object) 
      E remove(int location)
      Removes the object at the specified location from this list.
      boolean remove(java.lang.Object object) 
      E set(int location, E object)
      Replaces the element at the specified location in this ArrayList with the specified object.
      int size()
      Returns the number of elements in this ArrayList.
      java.lang.Object[] toArray()
      Returns a new array containing all elements contained in this ArrayList.
      <T> T[] toArray(T[] contents)
      Returns an array containing all elements contained in this ArrayList.
      void trimToSize()
      Sets the capacity of this ArrayList to be the same as the current size.
      • Methods inherited from class java.util.AbstractList

        iterator, listIterator, listIterator, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, removeAll, retainAll, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.List

        containsAll, iterator, listIterator, listIterator, removeAll, replaceAll, retainAll, sort, spliterator, subList
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Constructor Detail

      • HMArrayList

        public HMArrayList()
        Constructs a new instance of ArrayList with ten capacity.
      • HMArrayList

        public HMArrayList(E ex,
                           E... es)
      • HMArrayList

        public HMArrayList(int capacity)
        Constructs a new instance of ArrayList with the specified capacity.
        Parameters:
        capacity - the initial capacity of this ArrayList.
      • HMArrayList

        public HMArrayList(java.util.Collection<? extends E> collection)
        Constructs a new instance of ArrayList containing the elements of the specified collection. The initial size of the ArrayList will be 10% higher than the size of the specified collection.
        Parameters:
        collection - the collection of elements to add.
    • Method Detail

      • add

        public void add(int location,
                        E object)
        Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
        Parameters:
        location - the index at which to insert the object.
        object - the object to add.
        Throws:
        java.lang.IndexOutOfBoundsException - when location < 0 || > size()
      • add

        public boolean add(E object)
        Adds the specified object at the end of this ArrayList.
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
        Parameters:
        object - the object to add.
        Returns:
        always true
      • addAll

        public boolean addAll(int location,
                              java.util.Collection<? extends E> collection)
        Inserts the objects in the specified collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractList<E>
        Parameters:
        location - the index at which to insert.
        collection - the collection of objects.
        Returns:
        true if this ArrayList is modified, false otherwise.
        Throws:
        java.lang.IndexOutOfBoundsException - when location < 0 || > size()
      • addAll

        public boolean addAll(java.util.Collection<? extends E> collection)
        Adds the objects in the specified collection to this ArrayList.
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractCollection<E>
        Parameters:
        collection - the collection of objects.
        Returns:
        true if this ArrayList is modified, false otherwise.
      • clear

        public void clear()
        Removes all elements from this ArrayList, leaving it empty.
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class java.util.AbstractList<E>
        See Also:
        isEmpty(), size()
      • clone

        public java.lang.Object clone()
        Returns a new ArrayList with the same elements, the same size and the same capacity as this ArrayList.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a shallow copy of this ArrayList
        See Also:
        Cloneable
      • contains

        public boolean contains(java.lang.Object object)
        Searches this ArrayList for the specified object.
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
        Parameters:
        object - the object to search for.
        Returns:
        true if object is an element of this ArrayList, false otherwise
      • ensureCapacity

        public void ensureCapacity(int minimumCapacity)
        Ensures that after this operation the ArrayList can hold the specified number of elements without further growing.
        Parameters:
        minimumCapacity - the minimum capacity asked for.
      • equals

        public boolean equals(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class java.util.AbstractList<E>
      • isSameHead

        public final boolean isSameHead(E head)
        Check if the object at index 0 (i.e. the head of the list) is the same object as head and if the size of the list equals length.
        Parameters:
        head - object to compare with element at location 0
        Returns:
      • isSameHead

        public final boolean isSameHead(E head,
                                        int length)
        Check if the object at index 0 (i.e. the head of the list) is the same object as head and if the size of the list equals length.
        Parameters:
        head - object to compare with element at location 0
        length -
        Returns:
      • isSameHeadSizeGE

        public final boolean isSameHeadSizeGE(E head,
                                              int length)
        Check if the object at index 0 (i.e. the head of the list) is the same object as head and if the size of the list is greater or equal length.
        Parameters:
        head - object to compare with element at location 0
        length -
        Returns:
      • get

        public E get(int location)
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class java.util.AbstractList<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.util.AbstractList<E>
      • indexOf

        public int indexOf(java.lang.Object object)
        Specified by:
        indexOf in interface java.util.List<E>
        Overrides:
        indexOf in class java.util.AbstractList<E>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.List<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E>
      • lastIndexOf

        public int lastIndexOf(java.lang.Object object)
        Specified by:
        lastIndexOf in interface java.util.List<E>
        Overrides:
        lastIndexOf in class java.util.AbstractList<E>
      • remove

        public E remove(int location)
        Removes the object at the specified location from this list.
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractList<E>
        Parameters:
        location - the index of the object to remove.
        Returns:
        the removed object.
        Throws:
        java.lang.IndexOutOfBoundsException - when location < 0 || >= size()
      • remove

        public boolean remove(java.lang.Object object)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • set

        public E set(int location,
                     E object)
        Replaces the element at the specified location in this ArrayList with the specified object.
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class java.util.AbstractList<E>
        Parameters:
        location - the index at which to put the specified object.
        object - the object to add.
        Returns:
        the previous element at the index.
        Throws:
        java.lang.IndexOutOfBoundsException - when location < 0 || >= size()
      • size

        public int size()
        Returns the number of elements in this ArrayList.
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
        Returns:
        the number of elements in this ArrayList.
      • toArray

        public java.lang.Object[] toArray()
        Returns a new array containing all elements contained in this ArrayList.
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
        Returns:
        an array of the elements from this ArrayList
      • toArray

        public <T> T[] toArray(T[] contents)
        Returns an array containing all elements contained in this ArrayList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this ArrayList, the array element following the collection elements is set to null.
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
        Parameters:
        contents - the array.
        Returns:
        an array of the elements from this ArrayList.
        Throws:
        java.lang.ArrayStoreException - when the type of an element in this ArrayList cannot be stored in the type of the specified array.
      • trimToSize

        public void trimToSize()
        Sets the capacity of this ArrayList to be the same as the current size.
        See Also:
        size()

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.