limit

inline fun <T> Iterable<T>.limit(limitSize: Int): Iterable<T>(source)

Returns a view of this containing its first limitSize elements. If this contains fewer than limitSize elements, the returned view contains all of its elements. The returned iterable's iterator supports remove() if this's iterator does.

Stream equivalent: Stream.limit

See also

Parameters

limitSize

the maximum number of elements in the returned iterable

Throws

if limitSize is negative


inline fun <T> Iterator<T>.limit(limitSize: Int): Iterator<T>(source)

Returns a view containing the first limitSize elements of this. If this contains fewer than limitSize elements, the returned view contains all of its elements.

See also

Parameters

limitSize

the maximum number of elements in the returned iterator

Throws


@JvmName(name = "limitMutable")
inline fun <T> MutableIterator<T>.limit(limitSize: Int): MutableIterator<T>(source)

Returns a view containing the first limitSize elements of this. If this contains fewer than limitSize elements, the returned view contains all of its elements. The returned iterator supports remove() if iterator does.

See also

Parameters

limitSize

the maximum number of elements in the returned iterator

Throws