关于Java.util.ArrayList<E>的英文简介的翻译

Java.util.ArrayList

源码中对ArrayList的说明介绍截图:源码中对ArrayList的说明

拆分-翻译

1.动态数组(可调整大小,Resizable-array)

  • Resizable-array implementation of the List interface.
  • Implements all optional(可选的) list operations(操作), and permits(允许) all elements, including null.
  • In addition to(除…之外) implementing the List interface,
  • this class provides methods to manipulate(操纵) the size of the array that is used internally(内部地) to store the list.
  • (This class is roughly(大致) equivalent(相当) to Vector, except that it is unsynchronized(不同步).)

2.定时间(Constant time)方法和线性时间(Linear time)方法

  • The size, isEmpty, get, set, iterator, and listIterator operations run in constant time.
  • The add operation runs in amortized(摊销) constant time,that is, adding n elements requires O(n) time.
  • All of the other operations run in linear time (roughly speaking(大体来说)).
  • The constant factor(常量因子) is low compared to that for the LinkedList implementation.

3.使用之前先指定容量(capacity)

  • Each ArrayList instance has a capacity(容量).
  • The capacity is the size of the array used to store the elements in the list.
  • It is always at least as large as(和…一样大) the list size.
  • As elements are added to an ArrayList,its capacity grows automatically.
  • The details of the growth policy are not specified beyond(除…之外) the fact(事实) that adding an element has constant amortized(摊销) time cost.
  • An application can increase the capacity of an ArrayList instance
    before adding a large number of elements using the ensureCapacity operation.
    This may reduce the amount of incremental(增加的) reallocation(重新分配).

4.不是同步的(Is Not Synchronized.)

  • Note that this implementation is not synchronized.
  • If multiple(多个) threads access an ArrayList instance concurrently(同时发生地),
    and at least one of the threads modifies the list structurally(在结构上),
    it must be synchronized externally(外部地).
  • (A structural modification(结构上的修改) is any operation that adds or deletes one or more elements, or explicitly(明确地) resizes(调整大小) the backing array;
    merely(仅仅) setting the value of an element is not a structural modification.)
  • This is typically(通常) accomplished(完成) by synchronizing on(正在同步) some object that naturally encapsulates(压缩?) the list.(百度翻译:这通常是通过在自然封装列表的某个对象上进行同步来实现的。)
  • If no such object exists, the list should be “wrapped”(被包装) using the Collections.synchronizedList method.
  • This is best done at creation time, to prevent(阻止) accidental(意外的) unsynchronized access to the list:
    List list = Collections.synchronizedList(new ArrayList(…));

5.快速失败(Fail-Fast)机制

  • The iterators returned by this class’s iterator and listIterator methods are fail-fast:
    if the list is structurally modified at any time after the iterator is created,
    in any way except(除…之外) through the iterator’s own remove or add methods,
    the iterator will throw a ConcurrentModificationException.
  • Thus(因此), in the face of(面对) concurrent(并存的) modification, the iterator fails quickly and cleanly,
    rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future. (百度翻译:而不是冒着武断、不确定的行为在未来不确定的时间。)

6.无法确保迭代器的快速失败行为一定能发生

  • Note that the fail-fast behavior of an iterator cannot be guaranteed(必然的) as it is,
  • generally speaking(一般来说), impossible to make any hard guarantees(硬保证) in the presence(存在,出现) of unsynchronized concurrent modification.
  • Fail-fast iterators throw ConcurrentModificationException on a best-effort(尽最大努力) basis(原因 ; 缘由??).
  • Therefore, it would be wrong to write a program that depended on this exception for its correctness(准确性):
    the fail-fast behavior of iterators should be used only to detect bugs.
    (百度翻译:因此,编写依赖于此异常的正确性的程序是错误的:
    迭代器的快速失败行为应该只用于检测错误。
    )

7.java集合框架的一员

  • This class is a member of the Java Collections Framework

笔记

  1. 关于structural modification(结构上的修改)
    包括add(),delete(),resize(),不包括set().
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值