Class SortedListModel<E>

    • Constructor Detail

      • SortedListModel

        public SortedListModel​(@NonNull
                               @NonNull Comparator<E> comparator)
    • Method Detail

      • getSize

        public int getSize()
      • getElementAt

        public E getElementAt​(int index)
      • addElement

        public void addElement​(E element)
        Add an element to the list. Sorts the list.
        Parameters:
        element - element to add
      • remove

        public void remove​(int index)
        Removes the element at the given index.
        Parameters:
        index - position to remove an element from
      • removeRange

        public void removeRange​(int fromIndex,
                                int toIndex)
        Deletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between.
        Parameters:
        fromIndex - the index of the lower end of the range
        toIndex - the index of the upper end of the range
        Throws:
        ArrayIndexOutOfBoundsException - if the index was invalid
        IllegalArgumentException - if fromIndex &gt; toIndex
        See Also:
        remove(int)
      • indexOf

        public int indexOf​(E element)
        Searches for the first occurrence of elem.
        Parameters:
        element - an object
        Returns:
        the index of the first occurrence of the argument in this list; returns -1 if the object is not found
        See Also:
        Vector.indexOf(Object)
      • sort

        public void sort()
        Sort the list.