Class BasicEventList<E>

  • All Implemented Interfaces:
    EventList<E>, java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

    public final class BasicEventList<E>
    extends AbstractEventList<E>
    implements java.io.Serializable, java.util.RandomAccess
    An EventList that wraps any simple List, such as ArrayList or LinkedList.

    Unlike most EventLists, this class is Serializable. When BasicEventList is serialized, all of its elements are serialized and all of its listeners that implement Serializable. Upon deserialization, the new copy uses a different lock than its source BasicEventList.

    EventList Overview
    Writable:yes
    Concurrency:thread ready, not thread safe
    Performance:reads: O(1), writes O(1) amortized
    Memory:O(N)
    Unit Tests:N/A
    Issues:N/A
    Author:
    Jesse Wilson
    See Also:
    Serialized Form
    • Method Detail

      • add

        public void add​(int index,
                        E element)
        Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class AbstractEventList<E>
        Parameters:
        index - index at which the specified element is to be inserted.
        element - element to be inserted.
      • add

        public boolean add​(E element)
        Appends the specified element to the end of this list (optional operation).

        Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class AbstractEventList<E>
        Parameters:
        element - element to be appended to this list.
        Returns:
        true (as per the general contract of the Collection.add method).
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> collection)
        Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class AbstractEventList<E>
        Parameters:
        collection - collection whose elements are to be added to this list.
        Returns:
        true if this list changed as a result of the call.
        See Also:
        AbstractEventList.add(Object)
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> collection)
        Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class AbstractEventList<E>
        Parameters:
        index - index at which to insert first element from the specified collection.
        collection - elements to be inserted into this list.
        Returns:
        true if this list changed as a result of the call.
      • remove

        public E remove​(int index)
        Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class AbstractEventList<E>
        Parameters:
        index - the index of the element to removed.
        Returns:
        the element previously at the specified position.
      • remove

        public boolean remove​(java.lang.Object element)
        Removes the first occurrence in this list of the specified element (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class AbstractEventList<E>
        Parameters:
        element - element to be removed from this list, if present.
        Returns:
        true if this list contained the specified element.
      • clear

        public void clear()
        Removes all of the elements from this list (optional operation). This list will be empty after this call returns (unless it throws an exception).
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class AbstractEventList<E>
      • set

        public E set​(int index,
                     E element)
        Replaces the element at the specified position in this list with the specified element (optional operation).
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class AbstractEventList<E>
        Parameters:
        index - index of element to replace.
        element - element to be stored at the specified position.
        Returns:
        the element previously at the specified position.
      • get

        public E get​(int index)
        Returns the element at the specified position in this list.
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class AbstractEventList<E>
        Parameters:
        index - index of element to return.
        Returns:
        the element at the specified position in this list.
      • size

        public int size()
        Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
        Specified by:
        size in class AbstractEventList<E>
        Returns:
        the number of elements in this list.
      • removeAll

        public boolean removeAll​(java.util.Collection<?> collection)
        Removes from this list all the elements that are contained in the specified collection (optional operation).
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
        Overrides:
        removeAll in class AbstractEventList<E>
        Parameters:
        collection - collection that defines which elements will be removed from this list.
        Returns:
        true if this list changed as a result of the call.
        See Also:
        AbstractEventList.remove(Object), AbstractEventList.contains(Object)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> collection)
        Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all the elements that are not contained in the specified collection.
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.List<E>
        Overrides:
        retainAll in class AbstractEventList<E>
        Parameters:
        collection - collection that defines which elements this set will retain.
        Returns:
        true if this list changed as a result of the call.
        See Also:
        AbstractEventList.remove(Object), AbstractEventList.contains(Object)
      • dispose

        public void dispose()
        This method does nothing. It is not necessary to dispose a BasicEventList.
        Specified by:
        dispose in interface EventList<E>