Top Methods
com.vladsch.flexmark.experimental.util.collection.iteration

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

extends IPositionListener
Known Direct Subinterfaces
com.vladsch.flexmark.experimental.util.collection.iteration.IPosition
Imports
com.vladsch.flexmark.util.sequence.PositionAnchor, org.jetbrains.annotations.NotNull, .Nullable

Method Summary

Modifier and TypeMethod and Description
public Iterable<P>

Returns:

iterable whose first element is this position, iteration proceeds toward index 0
backwards
()

Iterable for this position and all previous positions in decreasing index order

public 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.

public boolean

Returns:

hash
equals
(Object other)

Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself.

public Iterable<P>

Returns:

iterable whose first element is this position, iteration proceeds toward index list.size()
forwards
()

iterable for this position and all following positions in increasing index order

public @NotNull PositionAnchor

Returns:

position anchor
getAnchor
()

Position Anchor for this position

public int

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]
getIndex
()

FIX: allow getIndex(offset) to return -1

public int

Returns:

hash
hashCode
()

Listeners should not change hashCode() or equals() from their default implementation where the instance is only equal to itself.

public boolean

Returns:

true if getNextIndex() will return a value, false if next() will throw an exception
hasNext
()

public boolean

Returns:

true if getPreviousIndex() will return a value, false if previous() will throw an exception
hasPrevious
()

public boolean
public boolean

Returns:

true if this position was not invalidated by deleting the element at index
isValid
()

public boolean

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
isValidElement
()

public P

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
next
()

Get next index position relative to current, returns next position if it exists even when this position is not valid

public Iterable<P>

Returns:

iterable whose first element is one after this position, iteration proceeds toward index list.size()
nextForwards
()

Iterator for all following positions, excluding this position in increasing index order

public int

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
nextIndex
()

Returns the index of the element that would be returned by a subsequent call to next.

public P

Returns:

next position or null
nextOrNull
()

Return valid next position, with the same position anchor as this position, or null if does not exist.

public P

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
previous
()

Get previous index position relative to current, returns previous index if it exists even when this position is not valid

public Iterable<P>

Returns:

iterable whose first element is previous to this position, iteration proceeds toward index 0
previousBackwards
()

iterable for all previous positions, excluding this position in decreasing index order

public int

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
previousIndex
()

Returns the index of the element that would be returned by a subsequent call to previous.

public P

Returns:

previous position or null
previousOrNull
()

Return valid previous position, with the same position anchor as this position, or null if does not exist.

public T

Returns:

removed current element, throws IllegalStateException if current index is not valid or after last element of list
remove
()

public 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()

public void
unframed()

Mark this position as used outside the iteration frame in which it was created.

public P

Returns:

new position with requested or this if there is no anchor change
withAnchor
(@NotNull PositionAnchor
desired anchor position
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

Inherited from com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener:
deletedinserted

Method Detail

backwardsback to summary
public Iterable<P> backwards()

Iterable for this position and all previous positions in decreasing index order

Returns:Iterable<P>

iterable whose first element is this position, iteration proceeds toward index 0

detachListenerback to summary
public 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()

equalsback to summary
public 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.

Returns:boolean

hash

forwardsback to summary
public Iterable<P> forwards()

iterable for this position and all following positions in increasing index order

Returns:Iterable<P>

iterable whose first element is this position, iteration proceeds toward index list.size()

getAnchorback to summary
public @NotNull PositionAnchor getAnchor()

Position Anchor for this position

Returns:@NotNull PositionAnchor

position anchor

Annotations
@NotNull
getIndexback to summary
public int getIndex()

FIX: allow getIndex(offset) to return -1

Returns:int

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]

hashCodeback to summary
public 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.

Returns:int

hash

hasNextback to summary
public boolean hasNext()
Returns:boolean

true if getNextIndex() will return a value, false if next() will throw an exception

hasPreviousback to summary
public boolean hasPrevious()
Returns:boolean

true if getPreviousIndex() will return a value, false if previous() will throw an exception

isDetachedback to summary
public boolean isDetached()
isValidback to summary
public boolean isValid()
Returns:boolean

true if this position was not invalidated by deleting the element at index

isValidElementback to summary
public boolean isValidElement()
Returns:boolean

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

nextback to summary
public P next()

Get next index position relative to current, returns next position if it exists even when this position is not valid

Returns:P

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

nextForwardsback to summary
public Iterable<P> nextForwards()

Iterator for all following positions, excluding this position in increasing index order

Returns:Iterable<P>

iterable whose first element is one after this position, iteration proceeds toward index list.size()

nextIndexback to summary
public 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:int

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

nextOrNullback to summary
public 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:P

next position or null

Annotations
@Nullable
previousback to summary
public P previous()

Get previous index position relative to current, returns previous index if it exists even when this position is not valid

Returns:P

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

previousBackwardsback to summary
public Iterable<P> previousBackwards()

iterable for all previous positions, excluding this position in decreasing index order

Returns:Iterable<P>

iterable whose first element is previous to this position, iteration proceeds toward index 0

previousIndexback to summary
public 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:int

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

previousOrNullback to summary
public 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:P

previous position or null

Annotations
@Nullable
removeback to summary
public T remove()
Returns:T

removed current element, throws IllegalStateException if current index is not valid or after last element of list

setDetachedback to summary
public 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()

unframedback to summary
public 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.

withAnchorback to summary
public P withAnchor(@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:@NotNull PositionAnchor

desired anchor position

Returns:P

new position with requested or this if there is no anchor change

Annotations
@NotNull