Class AttachmentList<E>

  • All Implemented Interfaces:
    Iterable<E>, Collection<E>, List<E>, RandomAccess

    public final class AttachmentList<E>
    extends Object
    implements List<E>, RandomAccess
    A List meant for use with an Attachable object. The list has concurrency semantics equivalent to Collections.synchronizedList; i.e. it is thread safe for reads and writes not involving an iterator or stream but if reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it:
     AttachmentList list = new AttachmentList<>();
     ...
     synchronized (list) {
          Iterator i = list.iterator(); // Must be in synchronized block
          while (i.hasNext())
              foo(i.next());
     }
     
    Author:
    David M. Lloyd
    • Constructor Detail

      • AttachmentList

        public AttachmentList​(int initialCapacity,
                              Class<E> valueClass)
        Creates a new AttachmentList.
        Parameters:
        initialCapacity - the initial capacity of the list
        valueClass - the type of element the list is permitted to hold
      • AttachmentList

        public AttachmentList​(Class<E> valueClass)
        Creates a new AttachmentList.
        Parameters:
        valueClass - the type of element the list is permitted to hold
      • AttachmentList

        public AttachmentList​(Collection<? extends E> c,
                              Class<E> valueClass)
        Creates a new AttachmentList.
        Parameters:
        c - initial contents of the list. Cannot be null
        valueClass - the type of element the list is permitted to hold