# Package-level declarations

## Types

PaginatedIterable
Link copied to clipboard
class PaginatedIterable < T >(pageSize: Int , countGetter: () -> Long , paginationResultGetter: Pagination .() -> PaginationResult < T >) : Iterable < T >

An iterable that lazily fetches items from a paginated data source. It creates a PaginatedIterator that automatically fetches pages as needed.

PaginatedIterator
Link copied to clipboard
class PaginatedIterator < T >(pageSize: Int , countGetter: () -> Long , paginationResultGetter: Pagination .() -> PaginationResult < T >) : Iterator < T >

An iterator that lazily fetches items from a paginated data source. It automatically fetches the next page when the current page is exhausted.

## Functions

doAllWithCurrentPaging
Link copied to clipboard
inline fun < T > doAllWithCurrentPaging (initialPagination: Pagination = FirstPagePagination(), block: ( Pagination ) -> PaginationResult < T >)

Executes block for each page in a paginated sequence, automatically moving to the next page until an empty page or the last page is reached. Uses current page pagination logic.

doForAll
Link copied to clipboard
inline fun < T > doForAll (initialPagination: Pagination = FirstPagePagination(), paginationMapper: ( PaginationResult < T >) -> Pagination ?, block: ( Pagination ) -> PaginationResult < T >)

Executes block for each page in a paginated sequence. The paginationMapper determines the next pagination to use based on the current result. Stops when paginationMapper returns null.

doForAllWithCurrentPaging
Link copied to clipboard
inline fun < T > doForAllWithCurrentPaging (initialPagination: Pagination = FirstPagePagination(), block: ( Pagination ) -> PaginationResult < T >)

Alias for doAllWithCurrentPaging. Executes block for each page in a paginated sequence.

doForAllWithNextPaging
Link copied to clipboard
inline fun < T > doForAllWithNextPaging (initialPagination: Pagination = FirstPagePagination(), block: ( Pagination ) -> PaginationResult < T >)

Executes block for each page in a paginated sequence, automatically moving to the next page until an empty page or the last page is reached.

getAll
Link copied to clipboard
inline fun < T > getAll (initialPagination: Pagination = FirstPagePagination(), paginationMapper: ( PaginationResult < T >) -> Pagination ?, block: ( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source by repeatedly calling block with different pagination parameters. The paginationMapper determines the next pagination to use based on the current result.

getAllBy
Link copied to clipboard
inline fun < T , R > R . getAllBy (initialPagination: Pagination = FirstPagePagination(), paginationMapper: R .( PaginationResult < T >) -> Pagination ?, block: R .( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source using a receiver context. This is useful when the pagination logic depends on the receiver object's state.

getAllByWithCurrentPaging
Link copied to clipboard
inline fun < T , R > R . getAllByWithCurrentPaging (initialPagination: Pagination = FirstPagePagination(), block: R .( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source using a receiver context, automatically moving to the next page until an empty page or the last page is reached. Uses current page pagination logic.

getAllByWithNextPaging
Link copied to clipboard
inline fun < T , R > R . getAllByWithNextPaging (initialPagination: Pagination = FirstPagePagination(), block: R .( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source using a receiver context, automatically moving to the next page until an empty page or the last page is reached.

getAllWithCurrentPaging
Link copied to clipboard
inline fun < T > getAllWithCurrentPaging (initialPagination: Pagination = FirstPagePagination(), block: ( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source, automatically moving to the next page until an empty page or the last page is reached. Uses current page pagination logic.

getAllWithNextPaging
Link copied to clipboard
inline fun < T > getAllWithNextPaging (initialPagination: Pagination = FirstPagePagination(), block: ( Pagination ) -> PaginationResult < T >): List < T >

Retrieves all items from a paginated source, automatically moving to the next page until an empty page or the last page is reached.

makeIterable
Link copied to clipboard
inline fun < T > makeIterable (noinline countGetter: () -> Long , pageSize: Int = defaultPaginationPageSize, noinline paginationResultGetter: Pagination .() -> PaginationResult < T >): Iterable < T >

Creates an Iterable that lazily fetches items from a paginated data source. This is useful for iterating over large datasets without loading all items into memory at once.

optionallyReverse
Link copied to clipboard
inline fun < T > Array < T >. optionallyReverse (reverse: Boolean ): Array < T >

Optionally reverses this Array based on the reverse parameter.

fun < T > Iterable < T >. optionallyReverse (reverse: Boolean ): Iterable < T >

Optionally reverses this Iterable based on the reverse parameter. Delegates to specialized implementations for List and Set for better performance.

fun < T > List < T >. optionallyReverse (reverse: Boolean ): List < T >

Optionally reverses this List based on the reverse parameter.

fun < T > Set < T >. optionallyReverse (reverse: Boolean ): Set < T >

Optionally reverses this Set based on the reverse parameter. Note that the resulting set may have a different iteration order than the original.

fun Pagination . optionallyReverse (objectsCount: Int , reverse: Boolean ): Pagination
fun Pagination . optionallyReverse (objectsCount: Long , reverse: Boolean ): Pagination
paginate
Link copied to clipboard
fun < T > Iterable < T >. paginate (with: Pagination ): PaginationResult < T >

Paginates this Iterable according to the given Pagination parameters. Returns a PaginationResult containing the items within the specified page range.

fun < T > List < T >. paginate (with: Pagination ): PaginationResult < T >

Paginates this List according to the given Pagination parameters. Returns a PaginationResult containing the items within the specified page range. More efficient than the Iterable version as it uses direct indexing.

fun < T > Set < T >. paginate (with: Pagination ): PaginationResult < T >

Paginates this Set according to the given Pagination parameters. Returns a PaginationResult containing the items within the specified page range.

fun < T > List < T >. paginate (with: Pagination , reversed: Boolean ): PaginationResult < T >

Paginates this List according to the given Pagination parameters, optionally in reverse order.

fun < T > Set < T >. paginate (with: Pagination , reversed: Boolean ): PaginationResult < T >

Paginates this Set according to the given Pagination parameters, optionally in reverse order.

reverse
Link copied to clipboard
fun Pagination . reverse (objectsCount: Int ): SimplePagination

Shortcut for reverse

fun Pagination . reverse (datasetSize: Long ): SimplePagination

Example: