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

public Class IPositionBase<T, P extends IPosition<T, P>>

extends Object
implements IPosition<T, P extends IPosition<T, P>>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.experimental.util.collection.iteration.IPosition, com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder, com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener
Known Direct Subclasses
com.vladsch.flexmark.experimental.util.collection.iteration.Position
Imports
com.vladsch.flexmark.util.misc.Utils, com.vladsch.flexmark.util.sequence.PositionAnchor, org.jetbrains.annotations.NotNull, java.util.Collection, .List, java.util.function.Predicate

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private byte
private int
private final @NotNull List<T>
private final @NotNull IPositionUpdater<T, P>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(T
to insert after the current position in the list, not at the end of the list as a regular List does. throws IllegalStateException if current index is not valid
element
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.add.

public boolean
add(int
offset, can be negative. 0 means insert before current, 1 means after current, -1 means before previous
offset
,
T
to insert
element
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.add.

Add element at position given by relative offset to current position.

public boolean
addAll(@NotNull Collection<T> elements)

public boolean
addAll(int offset, @NotNull Collection<T> elements)

public boolean
public Iterable<P>
backwards()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.backwards.

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

public void
deleted(int
at which delete was performed, list contents and size at this point are already updated
index
,
int
of elements deleted
count
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.deleted.

delete Notification

public void
detachListener()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.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 final boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.equals.

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

public Iterable<P>
forwards()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.forwards.

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

public T
public T
get(int
relative to this position, absolute index [0, size()], if absolute index == size() then element is added at the end of the list. The latter is also considered an insert at size() index.
offset
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.get.

Insert element at index

public @NotNull PositionAnchor
public int
public int
getIndex(int
offset to current position

FIX: allow getIndex(offset) to return -1

offset
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.getIndex.

public T
public T
getOrNull(int
relative to this position, absolute index [0, size()], if absolute index == size() then element is added at the end of the list. The latter is also considered an insert at size() index.
offset
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.getOrNull.

Insert element at index

public <S extends T> S
getOrNull(Class<S>
class of element desired
elementClass
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.getOrNull.

Get the requested class or null if element at position cannot be cast to this class

public <S extends T> S
getOrNull(int
relative to this position, absolute index [0, size()], if absolute index == size() then element is added at the end of the list. The latter is also considered an insert at size() index.
offset
,
Class<S>
class of element desired
elementClass
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.getOrNull.

Get the requested class or null if element at position cannot be cast to this class

public P
getPosition(int
index relative to current position, <0 previous elements, 0 means current, >0 following elements
offset
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.getPosition.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.hashCode.

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

public boolean
public boolean
public P
public P
public P
public P
public void
inserted(int
position of insert
index
,
int
number of elements inserted
count
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionListener.inserted.

Anchor position effect on insert/delete, IPosition#isValid(), IPosition#isValidIndex() and IPosition#isValidElement()

PositionAnchor#CURRENT - tracks a specific element at index when the position is instantiated.

public void
invalidate()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.invalidate.

Mark position as not valid may be useful for something.

public boolean
public boolean
public boolean
public boolean
public boolean
public P
public P
public P
public P
public int
public int
public P
next()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.next.

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

public Iterable<P>
nextForwards()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.nextForwards.

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

public int
nextIndex()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.nextIndex.

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

public P
nextOrNull()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.nextOrNull.

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

public P
previous()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.previous.

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

public Iterable<P>
previousBackwards()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.previousBackwards.

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

public int
previousIndex()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.previousIndex.

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

public P
previousOrNull()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.previousOrNull.

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

public T
public T
public void
public void
set(T
to which to set the current element in the list throws IllegalStateException if current index is not valid

If the current index is after the last element this will add the value to the end of the list treating as an insert, with corresponding updates to any positions that this would affect.

element
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.set.

public T
set(int
relative to this position, absolute index [0, size()], if absolute index == size() then element is added at the end of the list. The latter is considered an insert at the index.
offset
,
T
value to set at offset
element
)

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPosition.set.

Set element at given index

public void
setDetached()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.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()

private void
setIndex(int i, boolean isValid)

public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
unframed()

Implements com.vladsch.flexmark.experimental.util.collection.iteration.IPositionHolder.unframed.

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

private void
private void
validateIndex(int index, int offset)

throw if offset is out list index range

private void
validateOffset(int offset)

private void
validateWithElementIndex(int index, int offset)

throw if not valid or index is out list index range of element indices

private void
validateWithIndex(int index, int offset)

throw if not valid or index is out list index range

public P
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait