Class SyncList

  • All Implemented Interfaces:
    java.lang.Iterable, java.util.Collection, java.util.List

    public class SyncList
    extends SyncCollection
    implements java.util.List
    SyncLists wrap Sync-based control around java.util.Lists. They support the following additional reader operations over SyncCollection: hashCode, equals, get, indexOf, lastIndexOf, subList. They support additional writer operations remove(int), set(int), add(int), addAll(int). The corresponding listIterators and are similarly extended.

    [ Introduction to this package. ]

    See Also:
    SyncCollection
    • Constructor Detail

      • SyncList

        public SyncList​(java.util.List list,
                        Sync sync)
        Create a new SyncList protecting the given collection, and using the given sync to control both reader and writer methods. Common, reasonable choices for the sync argument include Mutex, ReentrantLock, and Semaphores initialized to 1.
      • SyncList

        public SyncList​(java.util.List list,
                        ReadWriteLock rwl)
        Create a new SyncList protecting the given list, and using the given ReadWriteLock to control reader and writer methods.
      • SyncList

        public SyncList​(java.util.List list,
                        Sync readLock,
                        Sync writeLock)
        Create a new SyncList protecting the given list, and using the given pair of locks to control reader and writer methods.
    • Method Detail

      • baseList

        protected java.util.List baseList()
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection
        Specified by:
        hashCode in interface java.util.List
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection
        Specified by:
        equals in interface java.util.List
        Overrides:
        equals in class java.lang.Object
      • get

        public java.lang.Object get​(int index)
        Specified by:
        get in interface java.util.List
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List
      • subList

        public java.util.List subList​(int fromIndex,
                                      int toIndex)
        Specified by:
        subList in interface java.util.List
      • set

        public java.lang.Object set​(int index,
                                    java.lang.Object o)
        Specified by:
        set in interface java.util.List
      • remove

        public java.lang.Object remove​(int index)
        Specified by:
        remove in interface java.util.List
      • add

        public void add​(int index,
                        java.lang.Object o)
        Specified by:
        add in interface java.util.List
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection coll)
        Specified by:
        addAll in interface java.util.List
      • unprotectedListIterator

        public java.util.ListIterator unprotectedListIterator()
      • listIterator

        public java.util.ListIterator listIterator()
        Specified by:
        listIterator in interface java.util.List
      • unprotectedListIterator

        public java.util.ListIterator unprotectedListIterator​(int index)
      • listIterator

        public java.util.ListIterator listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List