Package com._1c.g5.v8.dt.common.search
Class Cursor<TElement,TKey>
java.lang.Object
com._1c.g5.v8.dt.common.search.Cursor<TElement,TKey>
- Type Parameters:
TElement- type of collection elementsTKey- type of key used for hashing elements position
- All Implemented Interfaces:
ICursor<TElement>
- Direct Known Subclasses:
BorderedCursor
Represents an abstract generic navigation cursor over input with fast access to any element position of collection.
When reposition to specific element is needed, hash function is used. If
TElement can be hashed
it is enough to pass Function.identity().-
Field Summary
FieldsModifier and TypeFieldDescriptionHash function for fast element position retrieval.Base input.Map containing elements.protected intPosition of current element. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRepositionTo(TElement element) Checks if the cursor can be repositioned to element, i.e. is present in collection.current()Gets current element at cursor position.booleanhasNext()Checks for the availability to move cursor to the next element.booleanChecks for the availability to move cursor to the previous element.voidInitializes by the specified list of elements.next()Moves cursor to the next element.previous()Moves cursor to the previous element.intrepositionBy(Predicate<TElement> condition) Repositions to element by according to the specific condition.intrepositionTo(TElement element) Repositions to specific element.voidRepositions to the begining of data.voidRepositions to the end of data.
-
Field Details
-
input
Base input. -
mapElementToPosition
Map containing elements. -
hashRetriever
Hash function for fast element position retrieval. -
position
protected int positionPosition of current element.
-
-
Constructor Details
-
Cursor
Creates instance of cursor with given hash function for fast access to elements of collection.- Parameters:
hashRetriever- ID function to access the related element from collection viahashRetrieverreturn value, cannot benull
-
-
Method Details
-
init
Description copied from interface:ICursorInitializes by the specified list of elements. -
current
Description copied from interface:ICursorGets current element at cursor position. -
hasNext
public boolean hasNext()Description copied from interface:ICursorChecks for the availability to move cursor to the next element. -
next
Description copied from interface:ICursorMoves cursor to the next element. -
hasPrevious
public boolean hasPrevious()Description copied from interface:ICursorChecks for the availability to move cursor to the previous element.- Specified by:
hasPreviousin interfaceICursor<TElement>- Returns:
trueif has previous element for the cursor; otherwise,false
-
previous
Description copied from interface:ICursorMoves cursor to the previous element. -
repositionToTheBeginning
public void repositionToTheBeginning()Description copied from interface:ICursorRepositions to the begining of data.- Specified by:
repositionToTheBeginningin interfaceICursor<TElement>
-
repositionTo
Description copied from interface:ICursorRepositions to specific element.- Specified by:
repositionToin interfaceICursor<TElement>- Parameters:
element- the element to which to reposition, can not benull
-
repositionBy
Description copied from interface:ICursorRepositions to element by according to the specific condition.- Specified by:
repositionByin interfaceICursor<TElement>- Parameters:
condition- the condition for repositioning, can not benull
-
repositionToTheEnd
public void repositionToTheEnd()Description copied from interface:ICursorRepositions to the end of data.- Specified by:
repositionToTheEndin interfaceICursor<TElement>
-
canRepositionTo
Description copied from interface:ICursorChecks if the cursor can be repositioned to element, i.e. is present in collection.- Specified by:
canRepositionToin interfaceICursor<TElement>- Parameters:
element- the element to check ability to reposition, can not benull- Returns:
trueif cursor can be repositioned to element,falseotherwise
-