Class DoubleList
java.lang.Object
cloud.opencode.base.collections.primitive.DoubleList
- All Implemented Interfaces:
Serializable, Iterable<Double>
DoubleList - Primitive double List
DoubleList - 原始 double 列表
A resizable array implementation for primitive double values. Avoids boxing overhead of Double objects.
原始 double 值的可调整大小数组实现。避免 Double 对象的装箱开销。
Features | 主要功能:
- No boxing overhead - 无装箱开销
- Memory efficient - 内存高效
- Random access - 随机访问
- Resizable - 可调整大小
- Stream support - 流支持
Usage Examples | 使用示例:
// Create empty - 创建空
DoubleList list = DoubleList.create();
// Create from values - 从值创建
DoubleList list = DoubleList.of(1.0, 2.0, 3.0);
// Operations - 操作
list.add(10.5);
double value = list.get(0);
// Statistics - 统计
double sum = list.sum();
double avg = list.average();
Performance | 性能特性:
- get/set: O(1) - get/set: O(1)
- add: O(1) amortized - add: O(1) 均摊
- contains: O(n) - contains: O(n)
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: N/A (primitive) - 空值安全: 不适用(原始类型)
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double value) voidadd(int index, double value) voidaddAll(double... values) doubleaverage()voidclear()booleancontains(double value) static DoubleListcreate()Create an empty DoubleList.static DoubleListcreate(int initialCapacity) Create a DoubleList with initial capacity.booleanvoidforEach(DoubleConsumer action) doubleget(int index) inthashCode()intindexOf(double value) booleanisEmpty()iterator()intlastIndexOf(double value) doublemax()doublemin()static DoubleListof(double... values) Create a DoubleList from values.booleanremove(double value) doubleremoveAt(int index) voidreverse()doubleset(int index, double value) intsize()voidsort()doubleReturn the standard deviation.stream()doublesum()double[]toArray()toString()doublevariance()Return the variance.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
create
Create an empty DoubleList. 创建空 DoubleList。- Returns:
- new DoubleList | 新的 DoubleList
-
create
Create a DoubleList with initial capacity. 创建指定初始容量的 DoubleList。- Parameters:
initialCapacity- initial capacity | 初始容量- Returns:
- new DoubleList | 新的 DoubleList
-
of
Create a DoubleList from values. 从值创建 DoubleList。- Parameters:
values- the values | 值- Returns:
- new DoubleList | 新的 DoubleList
-
size
public int size() -
isEmpty
public boolean isEmpty() -
get
public double get(int index) -
set
public double set(int index, double value) -
add
public void add(double value) -
add
public void add(int index, double value) -
addAll
public void addAll(double... values) -
removeAt
public double removeAt(int index) -
remove
public boolean remove(double value) -
clear
public void clear() -
contains
public boolean contains(double value) -
indexOf
public int indexOf(double value) -
lastIndexOf
public int lastIndexOf(double value) -
sum
public double sum() -
min
public double min() -
max
public double max() -
average
public double average() -
variance
public double variance()Return the variance. 返回方差。- Returns:
- variance | 方差
- Throws:
NoSuchElementException- if empty | 如果为空
-
standardDeviation
public double standardDeviation()Return the standard deviation. 返回标准差。- Returns:
- standard deviation | 标准差
- Throws:
NoSuchElementException- if empty | 如果为空
-
toArray
public double[] toArray() -
stream
-
sort
public void sort() -
reverse
public void reverse() -
primitiveIterator
-
iterator
-
forEach
-
equals
-
hashCode
-
toString
-