# CircularIntArray

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
Summary:[Ctors](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#)  

# CircularIntArray

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
CircularIntArray
`  
`

extends Object


``


`

|---|------------------------------------------|
| java.lang.Object                            ||
| ↳ | android.support.v4.util.CircularIntArray |

<br />

*** ** * ** ***

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                                                                                                     ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#CircularIntArray())`() ` Creates a circular array with default capacity.                                             |
| ` `[CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#CircularIntArray(int))`(int minCapacity) ` Creates a circular array with capacity for at least`minCapacity`elements. |

|                                                                                                                                ### Public methods                                                                                                                                 ||
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[addFirst](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#addFirst(int))`(int e) ` Add an integer in front of the CircularIntArray.                                                                                              |
| ` void`    | ` `[addLast](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#addLast(int))`(int e) ` Add an integer at end of the CircularIntArray.                                                                                                  |
| ` void`    | ` `[clear](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#clear())`() ` Remove all integers from the CircularIntArray.                                                                                                              |
| ` int`     | ` `[get](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#get(int))`(int n) ` Get nth (0 \<= n \<= size()-1) integer of the CircularIntArray.                                                                                         |
| ` int`     | ` `[getFirst](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#getFirst())`() ` Get first integer of the CircularIntArray.                                                                                                            |
| ` int`     | ` `[getLast](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#getLast())`() ` Get last integer of the CircularIntArray.                                                                                                               |
| ` boolean` | ` `[isEmpty](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#isEmpty())`() ` Return true if size() is 0.                                                                                                                             |
| ` int`     | ` `[popFirst](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#popFirst())`() ` Remove first integer from front of the CircularIntArray and return it.                                                                                |
| ` int`     | ` `[popLast](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#popLast())`() ` Remove last integer from end of the CircularIntArray and return it.                                                                                     |
| ` void`    | ` `[removeFromEnd](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#removeFromEnd(int))`(int numOfElements) ` Remove multiple elements from end of the CircularIntArray, ignore when numOfElements is less than or equals to 0.       |
| ` void`    | ` `[removeFromStart](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#removeFromStart(int))`(int numOfElements) ` Remove multiple integers from front of the CircularIntArray, ignore when numOfElements is less than or equals to 0. |
| ` int`     | ` `[size](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#size())`() ` Get number of integers in the CircularIntArray.                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### CircularIntArray

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CircularIntArray ()
```

Creates a circular array with default capacity.

<br />

### CircularIntArray

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CircularIntArray (int minCapacity)
```

Creates a circular array with capacity for at least`minCapacity`elements.

<br />

|                                    Parameters                                    ||
|---------------|-------------------------------------------------------------------|
| `minCapacity` | `int`: the minimum capacity, between 1 and 2\^30 inclusive <br /> |

## Public methods

### addFirst

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addFirst (int e)
```

Add an integer in front of the CircularIntArray.

<br />

|             Parameters             ||
|-----|-------------------------------|
| `e` | `int`: Integer to add. <br /> |

### addLast

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addLast (int e)
```

Add an integer at end of the CircularIntArray.

<br />

|             Parameters             ||
|-----|-------------------------------|
| `e` | `int`: Integer to add. <br /> |

### clear

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void clear ()
```

Remove all integers from the CircularIntArray.

<br />

### get

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int get (int n)
```

Get nth (0 \<= n \<= size()-1) integer of the CircularIntArray.

<br />

|                                Parameters                                ||
|-----|---------------------------------------------------------------------|
| `n` | `int`: The zero based element index in the CircularIntArray. <br /> |

|            Returns             ||
|-------|-------------------------|
| `int` | The nth integer. <br /> |

|                            Throws                             ||
|---|------------------------------------------------------------|
|   | ArrayIndexOutOfBoundsException} if n \< 0 or n \>= size(). |

### getFirst

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getFirst ()
```

Get first integer of the CircularIntArray.

<br />

|             Returns              ||
|-------|---------------------------|
| `int` | The first integer. <br /> |

|                              Throws                              ||
|---|---------------------------------------------------------------|
|   | ArrayIndexOutOfBoundsException} if CircularIntArray is empty. |

### getLast

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getLast ()
```

Get last integer of the CircularIntArray.

<br />

|             Returns             ||
|-------|--------------------------|
| `int` | The last integer. <br /> |

|                              Throws                              ||
|---|---------------------------------------------------------------|
|   | ArrayIndexOutOfBoundsException} if CircularIntArray is empty. |

### isEmpty

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isEmpty ()
```

Return true if size() is 0.

<br />

|                Returns                 ||
|-----------|-----------------------------|
| `boolean` | true if size() is 0. <br /> |

### popFirst

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int popFirst ()
```

Remove first integer from front of the CircularIntArray and return it.

<br />

|              Returns               ||
|-------|-----------------------------|
| `int` | The integer removed. <br /> |

|                             Throws                              ||
|----------------------------------|-------------------------------|
| `ArrayIndexOutOfBoundsException` | if CircularIntArray is empty. |

### popLast

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int popLast ()
```

Remove last integer from end of the CircularIntArray and return it.

<br />

|              Returns               ||
|-------|-----------------------------|
| `int` | The integer removed. <br /> |

|                             Throws                              ||
|----------------------------------|-------------------------------|
| `ArrayIndexOutOfBoundsException` | if CircularIntArray is empty. |

### removeFromEnd

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void removeFromEnd (int numOfElements)
```

Remove multiple elements from end of the CircularIntArray, ignore when numOfElements is less than or equals to 0.

<br />

|                          Parameters                          ||
|-----------------|---------------------------------------------|
| `numOfElements` | `int`: Number of integers to remove. <br /> |

|                                                                               Throws                                                                               ||
|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| `ArrayIndexOutOfBoundsException` | if numOfElements is larger than[size()](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#size()) |

### removeFromStart

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void removeFromStart (int numOfElements)
```

Remove multiple integers from front of the CircularIntArray, ignore when numOfElements is less than or equals to 0.

<br />

|                          Parameters                          ||
|-----------------|---------------------------------------------|
| `numOfElements` | `int`: Number of integers to remove. <br /> |

|                                                                               Throws                                                                               ||
|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| `ArrayIndexOutOfBoundsException` | if numOfElements is larger than[size()](https://developer.android.com/reference/android/support/v4/util/CircularIntArray#size()) |

### size

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int size ()
```

Get number of integers in the CircularIntArray.

<br />

|                          Returns                          ||
|-------|----------------------------------------------------|
| `int` | Number of integers in the CircularIntArray. <br /> |

-

  ## Interfaces

  - [Pools.Pool](https://developer.android.com/reference/android/support/v4/util/Pools.Pool)
-

  ## Classes

  - [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)
  - [ArraySet](https://developer.android.com/reference/android/support/v4/util/ArraySet)
  - [AtomicFile](https://developer.android.com/reference/android/support/v4/util/AtomicFile)
  - [CircularArray](https://developer.android.com/reference/android/support/v4/util/CircularArray)
  - [CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray)
  - [LongSparseArray](https://developer.android.com/reference/android/support/v4/util/LongSparseArray)
  - [LruCache](https://developer.android.com/reference/android/support/v4/util/LruCache)
  - [ObjectsCompat](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat)
  - [Pair](https://developer.android.com/reference/android/support/v4/util/Pair)
  - [PatternsCompat](https://developer.android.com/reference/android/support/v4/util/PatternsCompat)
  - [Pools](https://developer.android.com/reference/android/support/v4/util/Pools)
  - [Pools.SimplePool](https://developer.android.com/reference/android/support/v4/util/Pools.SimplePool)
  - [Pools.SynchronizedPool](https://developer.android.com/reference/android/support/v4/util/Pools.SynchronizedPool)
  - [SimpleArrayMap](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap)
  - [SparseArrayCompat](https://developer.android.com/reference/android/support/v4/util/SparseArrayCompat)