Class ListSlice<T>

    • Constructor Detail

      • ListSlice

        public ListSlice​(int sliceBeginIndex,
                         int sliceEndIndex)
        Constructs a new slice for a given list.
        Parameters:
        sliceBeginIndex - the index in the original list at which this slice starts.
        sliceEndIndex - the index in the original list at which this slice should end in the list. The value must be equal or greater than the slice beginning index; a value equal to the beginning index means the last item index in this slice isn't yet known. If the index of the last item in the original list is lesser than the specified index, then this slice ends up at the index of this last item.
      • ListSlice

        public ListSlice​(int sliceBeginIndex,
                         int sliceEndIndex,
                         long originalListSize)
        Constructs a new slice for a given list.
        Parameters:
        sliceBeginIndex - the index in the original list at which this slice starts.
        sliceEndIndex - the index in the original list at which this slice should end in the list. The value must be equal or greater than the slice beginning index; a value equal to the beginning index means the last item index in this slice isn't yet known. If the index of the last item in the original list is lesser than the specified index, then this slice ends up at the index of this last item.
        originalListSize - the size of the original list this slice comes from. It must be greater or equal to 0.
      • ListSlice

        public ListSlice​(int sliceBeginIndex,
                         int sliceEndIndex,
                         List<? extends T> originalList)
        Constructs a new slice for a given list.
        Parameters:
        sliceBeginIndex - the index in the original list at which this slice starts.
        sliceEndIndex - the index in the original list at which this slice should end in the list. If the index of the last item in the original list is lesser than the specified index, then this slice ends up at the index of this last item. If this index is the same than the beginning index then the slice is empty.
        originalList - the original list from which this slice comes from.
      • ListSlice

        public ListSlice​(Collection<? extends T> collection)
        Constructs a new list slice with all the items of the specified collection. This slice will contain the items of the whole specified collection and as such the original list size is equal to its real size.
        Parameters:
        collection - a collection of items of type T
    • Method Detail

      • emptyList

        public static <T> ListSlice<T> emptyList()
        Returns an empty list.
        Type Parameters:
        T - type of the list's items.
        Returns:
        an empty list slice.
      • newEmptyListWithSameProperties

        public <U> SilverpeasList<U> newEmptyListWithSameProperties()
        Description copied from interface: SilverpeasList
        Builds a new empty SilverpeasList with the same properties than this list.

        This method is mainly dedicated to be used for making a collector for the Java Stream API.

        Specified by:
        newEmptyListWithSameProperties in interface SilverpeasList<T>
        Type Parameters:
        U - the concrete type of the items of the returned list.
        Returns:
        an empty SilverpeasList with the same properties than this list.
      • getFirstIndex

        public int getFirstIndex()
        Gets the first index of this slice in the original list from which it comes. It is the inclusive index at which this slice begins in the original list.
        Returns:
        the index at which this slice begins in the original list.
      • getLastIndex

        public int getLastIndex()
        Gets the last index of this slice in the original list from which it comes. It is the inclusive index at which this slice ends in the original list.
        Returns:
        the index at which this slice ends in the original list.
      • originalListSize

        public long originalListSize()
        Gets the size of the original list this slice comes from. If this slice covers all the original list then originalListSize() == size(). The size of the original list can be unknown at the time the slice is built, in this case -1 is returned.
        Specified by:
        originalListSize in interface SilverpeasList<T>
        Returns:
        the size of the original list or -1 if such a size isn't known.
      • setOriginalListSize

        public void setOriginalListSize​(long size)
        Sets the size of the original list this slice comes from.
        Parameters:
        size - the size of the original list