Interface OrderedSet<E>

Type Parameters:
E - the type of elements contained in the set
All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>

@NonExtendable public interface OrderedSet<E> extends Set<E>
A Set retaining the iteration order
Since:
4.0
  • Field Details

    • NEW_VALUE

      static final int NEW_VALUE
      Constant indicating that a value is newly added
      Since:
      4.0
      See Also:
  • Method Details

    • get

      E get(int index) throws IndexOutOfBoundsException
      Returns the element with the given index
      Parameters:
      index - the index of the element
      Returns:
      the element with the given index
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      Since:
      4.0
    • getFirst

      E getFirst() throws IndexOutOfBoundsException
      Returns the first element
      Returns:
      the first element
      Throws:
      IndexOutOfBoundsException - if the set does not contain any elements
      Since:
      4.0
    • getLast

      E getLast() throws IndexOutOfBoundsException
      Returns the last element
      Returns:
      the last element
      Throws:
      IndexOutOfBoundsException - if the set does not contain any elements
      Since:
      4.0
    • set

      E set(int index, E element) throws IndexOutOfBoundsException
      Replaces the element at the given index
      Parameters:
      index - the index of the element to replace
      element - the new element
      Returns:
      the previous element at the given index
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      Since:
      4.0
    • add

      int add(int index, E element) throws IndexOutOfBoundsException
      Adds an element at the given index
      Parameters:
      index - the index of the element
      element - the element to add
      Returns:
      the old index of the element if it was already contained in the set, NEW_VALUE otherwise
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      Since:
      4.0
    • addFirst

      int addFirst(E element)
      Adds an element at the beginning
      Parameters:
      element - the element to add
      Returns:
      the old index of the element if it was already contained in the set, NEW_VALUE otherwise
      Since:
      4.0
    • addLast

      int addLast(E element)
      Adds an element at the end
      Parameters:
      element - the element to add
      Returns:
      the old index of the element if it was already contained in the set, NEW_VALUE otherwise
      Since:
      4.0
    • remove

      E remove(int index) throws IndexOutOfBoundsException
      Removes the element with the given index
      Parameters:
      index - the index of the element to remove
      Returns:
      the removed element
      Throws:
      IndexOutOfBoundsException - if the index is out of range
      Since:
      4.0
    • indexOf

      int indexOf(E element)
      Returns the index of an element
      Parameters:
      element - the element to find
      Returns:
      the index of the element or -1 if it is not contained in the set
      Since:
      4.0