Interface ICursor<TElement>

Type Parameters:
TElement - type of collection elements
All Known Subinterfaces:
IBorderedCursor<TElement>
All Known Implementing Classes:
BorderedCursor, Cursor

public interface ICursor<TElement>
Represents a generic cursor that can be used for navigation by collection of objects and provide object at current position of cursor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the cursor can be repositioned to element, i.e. is present in collection.
    Gets current element at cursor position.
    boolean
    Checks for the availability to move cursor to the next element.
    boolean
    Checks for the availability to move cursor to the previous element.
    void
    init(List<TElement> input)
    Initializes by the specified list of elements.
    Moves cursor to the next element.
    Moves cursor to the previous element.
    int
    Repositions to element by according to the specific condition.
    int
    Repositions to specific element.
    void
    Repositions to the begining of data.
    void
    Repositions to the end of data.
    int
    Returns the size of elements in cursor
  • Method Details

    • init

      void init(List<TElement> input)
      Initializes by the specified list of elements.
      Parameters:
      input - the list of elements, can not be null
    • current

      TElement current()
      Gets current element at cursor position.
      Returns:
      the current element; null after initialization
    • hasNext

      boolean hasNext()
      Checks for the availability to move cursor to the next element.
      Returns:
      true if has previous element for the cursor; otherwise, false
    • next

      TElement next()
      Moves cursor to the next element.
      Returns:
      the next element
      Throws:
      IndexOutOfBoundsException - if the position is out of range
      See Also:
    • hasPrevious

      boolean hasPrevious()
      Checks for the availability to move cursor to the previous element.
      Returns:
      true if has previous element for the cursor; otherwise, false
    • previous

      TElement previous()
      Moves cursor to the previous element.
      Returns:
      the previous element
      Throws:
      IndexOutOfBoundsException - if the position is out of range
      See Also:
    • repositionToTheBeginning

      void repositionToTheBeginning()
      Repositions to the begining of data.
    • repositionToTheEnd

      void repositionToTheEnd()
      Repositions to the end of data.
    • repositionTo

      int repositionTo(TElement element)
      Repositions to specific element.
      Parameters:
      element - the element to which to reposition, can not be null
      Throws:
      NoSuchElementException - when the requested element does not exist
    • repositionBy

      int repositionBy(Predicate<TElement> condition)
      Repositions to element by according to the specific condition.
      Parameters:
      condition - the condition for repositioning, can not be null
      Throws:
      NoSuchElementException - when the requested element does not exist
    • canRepositionTo

      boolean canRepositionTo(TElement element)
      Checks if the cursor can be repositioned to element, i.e. is present in collection.
      Parameters:
      element - the element to check ability to reposition, can not be null
      Returns:
      true if cursor can be repositioned to element, false otherwise
    • size

      int size()
      Returns the size of elements in cursor