# CircularIntArray

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/CircularIntArray.kt+class:androidx.collection.CircularIntArray) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/collection/CircularIntArray "View this page in Java") Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class CircularIntArray
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` is a circular integer array data structure that provides O(1) random read, O(1) prepend and O(1) append. The CircularIntArray automatically grows its capacity when number of added integers is over its capacity.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#CircularIntArray(kotlin.Int)(minCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a circular array with capacity for at least `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#(kotlin.Int)` elements. | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#addFirst(kotlin.Int)(element: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Add an integer in front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#addLast(kotlin.Int)(element: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Add an integer at end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#clear()()` Remove all integers from the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#get(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Get nth (0 \<= n \<= size()-1) integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#isEmpty()()` Return `true` if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()` is 0. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#popFirst()()` Remove first integer from front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` and return it. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#popLast()()` Remove last integer from end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` and return it. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromEnd(kotlin.Int)(count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Remove multiple elements from end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`, ignore when `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromEnd(kotlin.Int)` is less than or equals to 0. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromStart(kotlin.Int)(count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Remove multiple integers from front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`, ignore when `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromStart(kotlin.Int)` is less than or equals to 0. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()()` Get number of integers in the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#first()` Get first integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#last()` Get last integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. | Cmn |

## Public constructors

### CircularIntArray

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
CircularIntArray(minCapacity: Int = 8)
```

Creates a circular array with capacity for at least `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#(kotlin.Int)` elements.

| Parameters |
|---|---|
| `minCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 8` | the minimum capacity, between 1 and 2\^30 inclusive |

## Public functions

### addFirst

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun addFirst(element: Int): Unit
```

Add an integer in front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Parameters |
|---|---|
| `element: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` to add. |

### addLast

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun addLast(element: Int): Unit
```

Add an integer at end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Parameters |
|---|---|
| `element: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` to add. |

### clear

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun clear(): Unit
```

Remove all integers from the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

### get

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
operator fun get(index: Int): Int
```

Get nth (0 \<= n \<= size()-1) integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The zero based element index in the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The nth integer. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if n \< 0 or n \>= size(). |

### isEmpty

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun isEmpty(): Boolean
```

Return `true` if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()` is 0.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()` is 0. |

### popFirst

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun popFirst(): Int
```

Remove first integer from front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` and return it.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The integer removed. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` is empty. |

### popLast

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun popLast(): Int
```

Remove last integer from end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` and return it.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The integer removed. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` is empty. |

### removeFromEnd

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun removeFromEnd(count: Int): Unit
```

Remove multiple elements from end of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`, ignore when `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromEnd(kotlin.Int)` is less than or equals to 0.

| Parameters |
|---|---|
| `count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Number of integers to remove. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromEnd(kotlin.Int)` is larger than `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()` |

### removeFromStart

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun removeFromStart(count: Int): Unit
```

Remove multiple integers from front of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`, ignore when `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#removeFromStart(kotlin.Int)` is less than or equals to 0.

| Parameters |
|---|---|
| `count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Number of integers to remove. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if numOfElements is larger than `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray#size()` |

### size

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun size(): Int
```

Get number of integers in the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Number of integers in the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`. |

## Public properties

### first

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
val first: Int
```

Get first integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The first integer. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` is empty. |

### last

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
val last: Int
```

Get last integer of the `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The last integer. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/collection/CircularIntArray` is empty. |