Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grammatical errors in documentation in SlidingWindow.kt #5268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions libraries/stdlib/src/kotlin/collections/SlidingWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ internal class MovingSubList<out E>(private val list: List<E>) : AbstractList<E>


/**
* Provides ring buffer implementation.
* Provides a ring buffer implementation.
*
* Buffer overflow is not allowed so [add] doesn't overwrite tail but raises an exception.
* Buffer overflow is not allowed so [add] doesn't overwrite the tail but raises an exception.
*/
private class RingBuffer<T>(private val buffer: Array<Any?>, filledSize: Int) : AbstractList<T>(), RandomAccess {
init {
Expand Down Expand Up @@ -155,7 +155,7 @@ private class RingBuffer<T>(private val buffer: Array<Any?>, filledSize: Int) :
}

/**
* Creates a new ring buffer with the capacity equal to the minimum of [maxCapacity] and 1.5 * [capacity].
* Creates a new ring buffer with capacity equal to the minimum of [maxCapacity] and 1.5 * [capacity].
* The returned ring buffer contains the same elements as this ring buffer.
*/
fun expanded(maxCapacity: Int): RingBuffer<T> {
Expand All @@ -165,7 +165,7 @@ private class RingBuffer<T>(private val buffer: Array<Any?>, filledSize: Int) :
}

/**
* Add [element] to the buffer or fail with [IllegalStateException] if no free space available in the buffer
* Add [element] to the buffer or fail with [IllegalStateException] if no free space is available in the buffer.
*/
fun add(element: T) {
if (isFull()) {
Expand All @@ -177,7 +177,8 @@ private class RingBuffer<T>(private val buffer: Array<Any?>, filledSize: Int) :
}

/**
* Removes [n] first elements from the buffer or fails with [IllegalArgumentException] if not enough elements in the buffer to remove
* Removes the first [n] elements from the buffer or fails with [IllegalArgumentException] if there are fewer than [n]
* elements in the buffer.
*/
fun removeFirst(n: Int) {
require(n >= 0) { "n shouldn't be negative but it is $n" }
Expand Down