Interface IPositionHolder<T,P extends IPositionHolder<T,P>>

All Superinterfaces:
IPositionListener
All Known Subinterfaces:
IPosition<T,P>
All Known Implementing Classes:
IPositionBase, Position

public interface IPositionHolder<T,P extends IPositionHolder<T,P>> extends IPositionListener
  • Method Summary

    Modifier and Type
    Method
    Description
    Iterable for this position and all previous positions in decreasing index order
    void
    Tells listener to remove itself from parent NOTE: used as optimization in iterators which are guaranteed not to have any other references to their position element.
    boolean
    equals(Object other)
    Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself.
    iterable for this position and all following positions in increasing index order
    Position Anchor for this position
    int
    FIX: allow getIndex(offset) to return -1
    int
    Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself.
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    Get next index position relative to current, returns next position if it exists even when this position is not valid
    Iterator for all following positions, excluding this position in increasing index order
    int
    Returns the index of the element that would be returned by a subsequent call to next().
    Return valid next position, with the same position anchor as this position, or null if does not exist.
    Get previous index position relative to current, returns previous index if it exists even when this position is not valid
    iterable for all previous positions, excluding this position in decreasing index order
    int
    Returns the index of the element that would be returned by a subsequent call to previous().
    Return valid previous position, with the same position anchor as this position, or null if does not exist.
     
    void
    Tells the listener it has been detached by its parent list NOTE: used as optimization in position list frames to detach any positions which have not been unframed()
    void
    Mark this position as used outside the iteration frame in which it was created.
    withAnchor(@NotNull PositionAnchor anchor)
    Get a new position with requested anchor from this position

    Methods inherited from interface com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener

    deleted, inserted
  • Method Details

    • forwards

      Iterable<P> forwards()
      iterable for this position and all following positions in increasing index order
      Returns:
      iterable whose first element is this position, iteration proceeds toward index list.size()
    • nextForwards

      Iterable<P> nextForwards()
      Iterator for all following positions, excluding this position in increasing index order
      Returns:
      iterable whose first element is one after this position, iteration proceeds toward index list.size()
    • backwards

      Iterable<P> backwards()
      Iterable for this position and all previous positions in decreasing index order
      Returns:
      iterable whose first element is this position, iteration proceeds toward index 0
    • previousBackwards

      Iterable<P> previousBackwards()
      iterable for all previous positions, excluding this position in decreasing index order
      Returns:
      iterable whose first element is previous to this position, iteration proceeds toward index 0
    • getIndex

      int getIndex()
      FIX: allow getIndex(offset) to return -1
      Returns:
      absolute index in list, even when this position does not refer to a valid element it will always be [-1, list.size()] if it is referring to a valid element then the returned range will be [0, list.size()-1]
    • detachListener

      void detachListener()
      Tells listener to remove itself from parent NOTE: used as optimization in iterators which are guaranteed not to have any other references to their position element.

      Do not otherwise use this because this position will stop having the list modification updates and will throw IllegalStateException on any attempt to use any methods of this position other than isDetached()

    • isDetached

      boolean isDetached()
    • setDetached

      void setDetached()
      Tells the listener it has been detached by its parent list NOTE: used as optimization in position list frames to detach any positions which have not been unframed()
    • unframed

      void unframed()
      Mark this position as used outside the iteration frame in which it was created. It allows positions to not be detached when the frame is closed.
    • getAnchor

      @NotNull @NotNull PositionAnchor getAnchor()
      Position Anchor for this position
      Returns:
      position anchor
    • withAnchor

      @NotNull P withAnchor(@NotNull @NotNull PositionAnchor anchor)
      Get a new position with requested anchor from this position

      CURRENT - position represents the element and if deleted will be invalidated, if inserting at or before index then will advance to keep position of element

      NEXT - position represents the next element

      PREVIOUS - position represents the previous element

      Parameters:
      anchor - desired anchor position
      Returns:
      new position with requested or this if there is no anchor change
    • previous

      P previous()
      Get previous index position relative to current, returns previous index if it exists even when this position is not valid
      Returns:
      previous valid position relative to this position, with the same position anchor as this position throws IndexOutOfBoundsException if there is no elements before current position
    • previousOrNull

      @Nullable P previousOrNull()
      Return valid previous position, with the same position anchor as this position, or null if does not exist. Does not throw exceptions
      Returns:
      previous position or null
    • next

      P next()
      Get next index position relative to current, returns next position if it exists even when this position is not valid
      Returns:
      previous valid position relative to this position, with the same position anchor as this position throws IndexOutOfBoundsException if there is no elements before current position
    • nextOrNull

      @Nullable P nextOrNull()
      Return valid next position, with the same position anchor as this position, or null if does not exist. Does not throw exceptions
      Returns:
      next position or null
    • nextIndex

      int nextIndex()
      Returns the index of the element that would be returned by a subsequent call to next(). (Returns list size if the list iterator is at the end of the list.)
      Returns:
      the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list
    • previousIndex

      int previousIndex()
      Returns the index of the element that would be returned by a subsequent call to previous(). (Returns -1 if the list iterator is at the beginning of the list.)
      Returns:
      the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list
    • isValid

      boolean isValid()
      Returns:
      true if this position was not invalidated by deleting the element at index
    • hasPrevious

      boolean hasPrevious()
      Returns:
      true if getPreviousIndex() will return a value, false if previous() will throw an exception
    • hasNext

      boolean hasNext()
      Returns:
      true if getNextIndex() will return a value, false if next() will throw an exception
    • isValidElement

      boolean isValidElement()
      Returns:
      true if this position represents a valid element in the list, ie. isValid() is true and index is at or before last element in list
    • remove

      T remove()
      Returns:
      removed current element, throws IllegalStateException if current index is not valid or after last element of list
    • hashCode

      int hashCode()
      Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself. Otherwise, a new instance can remove an old one from the weak hash map used to hold listener instances.
      Overrides:
      hashCode in class Object
      Returns:
      hash
    • equals

      boolean equals(Object other)
      Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself. Otherwise, a new instance can remove an old one from the weak hash map used to hold listener instances.
      Overrides:
      equals in class Object
      Returns:
      hash