Class UnaryTupleList

  • All Implemented Interfaces:
    java.lang.Iterable<java.util.List<Member>>, java.util.Collection<java.util.List<Member>>, java.util.List<java.util.List<Member>>, TupleIterable, TupleList

    public class UnaryTupleList
    extends java.util.AbstractList<java.util.List<Member>>
    implements TupleList
    Implementation of TupleList where the tuples are unary (each tuple consists of just one Member).

    It is implemented as a straightforward wrapper on a backing list. You can provide the backing list explicitly using the UnaryTupleList(java.util.List) constructor, and you can access the backing list by calling slice(int)(0).

    Author:
    jhyde
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.List<Member> list  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      UnaryTupleList()
      Creates an empty UnaryTupleList.
      UnaryTupleList​(java.util.List<Member> list)
      Creates a UnaryTupleList with a given backing list.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, java.util.List<Member> element)  
      boolean add​(java.util.List<Member> element)  
      void addCurrent​(TupleCursor tupleIter)  
      void addTuple​(Member... members)  
      void clear()  
      TupleList cloneList​(int capacity)
      Creates a copy of this list that has the same type and has a given capacity.
      TupleList fix()
      Fixes the tuples of this list, so that their contents will not change even if elements of the list are reordered or removed.
      java.util.List<Member> get​(int index)  
      Member get​(int slice, int index)
      Returns a particular column of a particular row.
      int getArity()
      Returns the number of members in each tuple.
      java.util.Iterator<java.util.List<Member>> iterator()  
      TupleList project​(int[] destIndices)  
      java.util.List<Member> remove​(int index)  
      java.util.List<Member> set​(int index, java.util.List<Member> element)  
      int size()  
      java.util.List<Member> slice​(int column)
      Returns a list of the members at a given column.
      TupleList subList​(int fromIndex, int toIndex)  
      TupleCursor tupleCursor()
      Creates a cursor over the contents of this iterable.
      TupleIterator tupleIterator()
      Creates an iterator over the contents of this iterable.
      TupleList withPositionCallback​(TupleList.PositionCallback positionCallback)  
      • Methods inherited from class java.util.AbstractList

        addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, 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, addAll, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Field Detail

      • list

        final java.util.List<Member> list
    • Constructor Detail

      • UnaryTupleList

        public UnaryTupleList()
        Creates an empty UnaryTupleList.
      • UnaryTupleList

        public UnaryTupleList​(java.util.List<Member> list)
        Creates a UnaryTupleList with a given backing list.
        Parameters:
        list - Backing list
    • Method Detail

      • get

        public Member get​(int slice,
                          int index)
        Description copied from interface: TupleList
        Returns a particular column of a particular row.

        Note that list.get(row, column) is equivalent to list.slice(column).get(row) and list.get(row).get(column) but is more efficient for most implementations of TupleList.

        Specified by:
        get in interface TupleList
        Parameters:
        slice - Column ordinal
        index - Row ordinal
        Returns:
        Member at given row and column
      • get

        public java.util.List<Member> get​(int index)
        Specified by:
        get in interface java.util.List<java.util.List<Member>>
        Specified by:
        get in class java.util.AbstractList<java.util.List<Member>>
      • add

        public void add​(int index,
                        java.util.List<Member> element)
        Specified by:
        add in interface java.util.List<java.util.List<Member>>
        Overrides:
        add in class java.util.AbstractList<java.util.List<Member>>
      • add

        public boolean add​(java.util.List<Member> element)
        Specified by:
        add in interface java.util.Collection<java.util.List<Member>>
        Specified by:
        add in interface java.util.List<java.util.List<Member>>
        Overrides:
        add in class java.util.AbstractList<java.util.List<Member>>
      • fix

        public TupleList fix()
        Description copied from interface: TupleList
        Fixes the tuples of this list, so that their contents will not change even if elements of the list are reordered or removed. Returns this list if possible.
        Specified by:
        fix in interface TupleList
        Returns:
        List whose tuples are invariant if the list is sorted or filtered
      • set

        public java.util.List<Member> set​(int index,
                                          java.util.List<Member> element)
        Specified by:
        set in interface java.util.List<java.util.List<Member>>
        Overrides:
        set in class java.util.AbstractList<java.util.List<Member>>
      • remove

        public java.util.List<Member> remove​(int index)
        Specified by:
        remove in interface java.util.List<java.util.List<Member>>
        Overrides:
        remove in class java.util.AbstractList<java.util.List<Member>>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.util.List<Member>>
        Specified by:
        clear in interface java.util.List<java.util.List<Member>>
        Overrides:
        clear in class java.util.AbstractList<java.util.List<Member>>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.util.List<Member>>
        Specified by:
        size in interface java.util.List<java.util.List<Member>>
        Specified by:
        size in class java.util.AbstractCollection<java.util.List<Member>>
      • getArity

        public int getArity()
        Description copied from interface: TupleIterable
        Returns the number of members in each tuple.
        Specified by:
        getArity in interface TupleIterable
        Returns:
        The number of members in each tuple
      • slice

        public java.util.List<Member> slice​(int column)
        Description copied from interface: TupleList
        Returns a list of the members at a given column.

        The list is modifiable if and only if this TupleList is modifiable. Adding an element to a slice will create a tuple whose members in other columns are null. Removing an element from a slicer will remove a tuple.

        Specified by:
        slice in interface TupleIterable
        Specified by:
        slice in interface TupleList
        Parameters:
        column - Ordinal of the member in each tuple to project
        Returns:
        List of members
      • cloneList

        public TupleList cloneList​(int capacity)
        Description copied from interface: TupleList
        Creates a copy of this list that has the same type and has a given capacity.

        If capacity is negative, populates the list. A deep copy is made, so that it the contents of the list are not affected to changes to any backing collections.

        Specified by:
        cloneList in interface TupleList
        Parameters:
        capacity - Capacity
        Returns:
        Copy of list, empty if capacity is non-negative
      • iterator

        public final java.util.Iterator<java.util.List<Member>> iterator()
        Specified by:
        iterator in interface java.util.Collection<java.util.List<Member>>
        Specified by:
        iterator in interface java.lang.Iterable<java.util.List<Member>>
        Specified by:
        iterator in interface java.util.List<java.util.List<Member>>
        Overrides:
        iterator in class java.util.AbstractList<java.util.List<Member>>
      • subList

        public TupleList subList​(int fromIndex,
                                 int toIndex)
        Specified by:
        subList in interface java.util.List<java.util.List<Member>>
        Specified by:
        subList in interface TupleList
        Overrides:
        subList in class java.util.AbstractList<java.util.List<Member>>