public final class CircularIntArray
extends Object
| java.lang.Object | |
| android.support.v4.util.CircularIntArray | |
CircularIntArray是一个循环整数数组结构,它提供O(1)随机读取,O(1)前置和O(1)追加。 当添加的整数数量超过其容量时,CircularIntArray会自动增加其容量。
Public constructors |
|
|---|---|
CircularIntArray() 用默认容量创建一个圆形数组。 |
|
CircularIntArray(int minCapacity) 创建一个至少包含 |
|
公共方法(Public methods) |
|
|---|---|
void |
addFirst(int e) 在CircularIntArray前添加一个整数。 |
void |
addLast(int e) 在CircularIntArray的末尾添加一个整数。 |
void |
clear() 从CircularIntArray中删除所有整数。 |
int |
get(int n) 获取CircularIntArray的第n个(0 <= n <= size() - 1)整数。 |
int |
getFirst() 获取CircularIntArray的第一个整数。 |
int |
getLast() 获取CircularIntArray的最后一个整数。 |
boolean |
isEmpty() 如果size()为0,则返回true。 |
int |
popFirst() 从CircularIntArray前移除第一个整数并返回。 |
int |
popLast() 从CircularIntArray末尾删除最后一个整数并返回。 |
void |
removeFromEnd(int numOfElements) 从CircularIntArray结尾删除多个元素,当numOfElements小于或等于0时忽略。 |
void |
removeFromStart(int numOfElements) 删除CircularIntArray前面的多个整数,当numOfElements小于或等于0时忽略。 |
int |
size() 获取CircularIntArray中的整数数量。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
CircularIntArray ()
用默认容量创建一个圆形数组。
CircularIntArray (int minCapacity)
创建一个至少包含 minCapacity元素的圆形阵列。
| 参数(Parameters) | |
|---|---|
minCapacity |
int: the minimum capacity, between 1 and 2^30 inclusive |
void addFirst (int e)
在CircularIntArray前添加一个整数。
| 参数(Parameters) | |
|---|---|
e |
int: Integer to add. |
void addLast (int e)
在CircularIntArray的末尾添加一个整数。
| 参数(Parameters) | |
|---|---|
e |
int: Integer to add. |
void clear ()
从CircularIntArray中删除所有整数。
int get (int n)
获取CircularIntArray的第n个(0 <= n <= size() - 1)整数。
| 参数(Parameters) | |
|---|---|
n |
int: The zero based element index in the CircularIntArray. |
| 返回(Returns) | |
|---|---|
int |
The nth integer. |
| 抛出异常(Throws) | |
|---|---|
|
ArrayIndexOutOfBoundsException} if n < 0 or n >= size(). |
int getFirst ()
获取CircularIntArray的第一个整数。
| 返回(Returns) | |
|---|---|
int |
The first integer. |
| 抛出异常(Throws) | |
|---|---|
|
ArrayIndexOutOfBoundsException} if CircularIntArray is empty. |
int getLast ()
获取CircularIntArray的最后一个整数。
| 返回(Returns) | |
|---|---|
int |
The last integer. |
| 抛出异常(Throws) | |
|---|---|
|
ArrayIndexOutOfBoundsException} if CircularIntArray is empty. |
boolean isEmpty ()
如果size()为0,则返回true。
| 返回(Returns) | |
|---|---|
boolean |
true if size() is 0. |
int popFirst ()
从CircularIntArray前移除第一个整数并返回。
| 返回(Returns) | |
|---|---|
int |
The integer removed. |
| 抛出异常(Throws) | |
|---|---|
ArrayIndexOutOfBoundsException |
if CircularIntArray is empty. |
int popLast ()
从CircularIntArray末尾删除最后一个整数并返回。
| 返回(Returns) | |
|---|---|
int |
The integer removed. |
| 抛出异常(Throws) | |
|---|---|
ArrayIndexOutOfBoundsException |
if CircularIntArray is empty. |
void removeFromEnd (int numOfElements)
从CircularIntArray结尾删除多个元素,当numOfElements小于或等于0时忽略。
| 参数(Parameters) | |
|---|---|
numOfElements |
int: Number of integers to remove. |
| 抛出异常(Throws) | |
|---|---|
ArrayIndexOutOfBoundsException |
if numOfElements is larger than size() |
void removeFromStart (int numOfElements)
删除CircularIntArray前面的多个整数,当numOfElements小于或等于0时忽略。
| 参数(Parameters) | |
|---|---|
numOfElements |
int: Number of integers to remove. |
| 抛出异常(Throws) | |
|---|---|
ArrayIndexOutOfBoundsException |
if numOfElements is larger than size() |
int size ()
获取CircularIntArray中的整数数量。
| 返回(Returns) | |
|---|---|
int |
Number of integers in the CircularIntArray. |