Class Collection4<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T element)
      Adds an element to the end of this collection.
      void addAll​(Iterable4<T> other)  
      void addAll​(Iterator4<T> iterator)  
      void addAll​(T[] elements)  
      void clear()  
      boolean contains​(T element)  
      boolean containsAll​(Iterable4<T> iter)  
      boolean containsAll​(Iterator4<T> iter)  
      boolean containsByIdentity​(T element)
      tests if the object is in the Collection.
      java.lang.Object deepClone​(java.lang.Object newParent)
      The parameter allows passing one new object so parent references can be corrected on children.
      T ensure​(T element)
      makes sure the passed object is in the Collection.
      T get​(int index)  
      T get​(T element)
      returns the first object found in the Collections that equals() the passed object
      int indexOf​(T obj)  
      boolean isEmpty()  
      Iterator4<T> iterator()
      Iterates through the collection in reversed insertion order which happens to be the fastest.
      void prepend​(T element)  
      boolean remove​(T a_object)
      removes an object from the Collection equals() comparison returns the removed object or null, if none found
      void removeAll​(Iterable4<T> iterable)
      Removes all the elements from this collection that are returned by iterable.
      void removeAll​(Iterator4<T> iterator)
      Removes all the elements from this collection that are returned by iterator.
      void replace​(T oldObject, T newObject)  
      void replaceByIdentity​(T oldObject, T newObject)  
      T singleElement()  
      int size()  
      java.lang.Object[] toArray()  
      T[] toArray​(T[] array)
      This is a non reflection implementation for more speed.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Collection4

        public Collection4()
      • Collection4

        public Collection4​(int initialLength)
        For jdk11 compatibility only.
      • Collection4

        public Collection4​(T[] elements)
      • Collection4

        public Collection4​(Iterable4<T> other)
      • Collection4

        public Collection4​(Iterator4<T> iterator)
    • Method Detail

      • singleElement

        public T singleElement()
      • add

        public final boolean add​(T element)
        Adds an element to the end of this collection.
        Specified by:
        add in interface Sequence4<T>
        Parameters:
        element -
      • prepend

        public final void prepend​(T element)
      • addAll

        public final void addAll​(T[] elements)
      • addAll

        public final void addAll​(Iterator4<T> iterator)
      • clear

        public final void clear()
        Specified by:
        clear in interface Sequence4<T>
      • contains

        public final boolean contains​(T element)
        Specified by:
        contains in interface Sequence4<T>
      • containsAll

        public boolean containsAll​(Iterator4<T> iter)
      • containsByIdentity

        public final boolean containsByIdentity​(T element)
        tests if the object is in the Collection. == comparison.
      • get

        public final T get​(T element)
        returns the first object found in the Collections that equals() the passed object
      • deepClone

        public java.lang.Object deepClone​(java.lang.Object newParent)
        Description copied from interface: DeepClone
        The parameter allows passing one new object so parent references can be corrected on children.
        Specified by:
        deepClone in interface DeepClone
      • ensure

        public final T ensure​(T element)
        makes sure the passed object is in the Collection. equals() comparison.
      • iterator

        public final Iterator4<T> iterator()
        Iterates through the collection in reversed insertion order which happens to be the fastest.
        Specified by:
        iterator in interface Iterable4<T>
        Returns:
      • get

        public T get​(int index)
        Specified by:
        get in interface Sequence4<T>
      • removeAll

        public void removeAll​(Iterable4<T> iterable)
        Removes all the elements from this collection that are returned by iterable.
        Parameters:
        iterable -
      • removeAll

        public void removeAll​(Iterator4<T> iterator)
        Removes all the elements from this collection that are returned by iterator.
      • remove

        public boolean remove​(T a_object)
        removes an object from the Collection equals() comparison returns the removed object or null, if none found
        Specified by:
        remove in interface Sequence4<T>
      • replace

        public void replace​(T oldObject,
                            T newObject)
      • replaceByIdentity

        public void replaceByIdentity​(T oldObject,
                                      T newObject)
      • size

        public final int size()
        Specified by:
        size in interface Sequence4<T>
      • indexOf

        public int indexOf​(T obj)
      • isEmpty

        public final boolean isEmpty()
        Specified by:
        isEmpty in interface Sequence4<T>
      • toArray

        public final T[] toArray​(T[] array)
        This is a non reflection implementation for more speed. In contrast to the JDK behaviour, the passed array has to be initialized to the right length.
        Specified by:
        toArray in interface Sequence4<T>
      • toArray

        public final java.lang.Object[] toArray()
        Specified by:
        toArray in interface Sequence4<T>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object