Class FilteredSegmentList

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

    public class FilteredSegmentList
    extends java.util.AbstractList
    Virtual list generated from a backing list by filtering on the element types. This exposes a segment of the backing list through the filter, with multiple filters used to expose the entire backing list piecemeal. It can only be used with lists of elements.
    Author:
    Dennis M. Sosnoski
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int m_lastModify
      Last modify count matching cached values.
      private LazyList m_list
      Base list.
      private long m_matchBits
      Mask for element types to match in filter.
      private OpenAttrBase m_owner
      Element owning this list.
      private FilteredSegmentList m_prior
      Filter for elements prior to this filter in list.
      private int m_size
      Cached size of filtered list.
      private int m_startIndex
      Cached filtered list start index in base list.
      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, java.lang.Object element)  
      java.lang.Object get​(int index)  
      java.lang.Object remove​(int index)
      Removes the item at the index position.
      boolean remove​(java.lang.Object o)  
      protected void removeRange​(int from, int to)  
      java.lang.Object set​(int index, java.lang.Object element)  
      private void setModify()
      Update modify count to show cached state is current.
      int size()  
      private void sync()
      Synchronize filter to current list state.
      • Methods inherited from class java.util.AbstractList

        add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

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

        forEach
      • Methods inherited from interface java.util.List

        addAll, contains, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Field Detail

      • m_list

        private final LazyList m_list
        Base list.
      • m_matchBits

        private final long m_matchBits
        Mask for element types to match in filter.
      • m_prior

        private final FilteredSegmentList m_prior
        Filter for elements prior to this filter in list.
      • m_owner

        private final OpenAttrBase m_owner
        Element owning this list.
      • m_lastModify

        private int m_lastModify
        Last modify count matching cached values.
      • m_startIndex

        private int m_startIndex
        Cached filtered list start index in base list.
      • m_size

        private int m_size
        Cached size of filtered list.
    • Constructor Detail

      • FilteredSegmentList

        private FilteredSegmentList()
        Dummy default constructor for unmarshalling.
      • FilteredSegmentList

        public FilteredSegmentList​(LazyList list,
                                   long match,
                                   FilteredSegmentList prior,
                                   OpenAttrBase owner)
        Constructor with everything specified.
        Parameters:
        list - backing list
        match - included element types mask
        prior - filter which comes before this one (null if none)
        owner - element owning this list
      • FilteredSegmentList

        public FilteredSegmentList​(LazyList list,
                                   long match,
                                   OpenAttrBase owner)
        Constructor with no prior filter.
        Parameters:
        list - backing list
        match - included element types mask
        owner - element owning this list
    • Method Detail

      • setModify

        private void setModify()
        Update modify count to show cached state is current. This propagates to any prior filter(s).
      • sync

        private void sync()
        Synchronize filter to current list state. If the cached state is not current this updates the cached state to reflect the current state of the backing list.
      • get

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

        public int size()
        Specified by:
        size in interface java.util.Collection
        Specified by:
        size in interface java.util.List
        Specified by:
        size in class java.util.AbstractCollection
      • add

        public void add​(int index,
                        java.lang.Object element)
        Specified by:
        add in interface java.util.List
        Overrides:
        add in class java.util.AbstractList
      • remove

        public java.lang.Object remove​(int index)
        Removes the item at the index position.
        Specified by:
        remove in interface java.util.List
        Overrides:
        remove in class java.util.AbstractList
        Parameters:
        index -
        Returns:
        removed item
      • remove

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

        public java.lang.Object set​(int index,
                                    java.lang.Object element)
        Specified by:
        set in interface java.util.List
        Overrides:
        set in class java.util.AbstractList
      • removeRange

        protected void removeRange​(int from,
                                   int to)
        Overrides:
        removeRange in class java.util.AbstractList