Package com._1c.g5.v8.dt.common.search
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 TypeMethodDescriptionboolean
canRepositionTo
(TElement element) Checks if the cursor can be repositioned to element, i.e. is present in collection.current()
Gets current element at cursor position.boolean
hasNext()
Checks for the availability to move cursor to the next element.boolean
Checks for the availability to move cursor to the previous element.void
Initializes by the specified list of elements.next()
Moves cursor to the next element.previous()
Moves cursor to the previous element.int
repositionBy
(Predicate<TElement> condition) Repositions to element by according to the specific condition.int
repositionTo
(TElement element) Repositions to specific element.void
Repositions to the begining of data.void
Repositions to the end of data.
-
Method Details
-
init
Initializes by the specified list of elements.- Parameters:
input
- the list of elements, can not benull
-
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
Repositions to specific element.- Parameters:
element
- the element to which to reposition, can not benull
- Throws:
NoSuchElementException
- when the requested element does not exist
-
repositionBy
Repositions to element by according to the specific condition.- Parameters:
condition
- the condition for repositioning, can not benull
- Throws:
NoSuchElementException
- when the requested element does not exist
-
canRepositionTo
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 benull
- Returns:
true
if cursor can be repositioned to element,false
otherwise
-