在 RandomAccess 标记接口描述中它是这样写的:
* <p>The best algorithms for manipulating random access lists (such as
* <tt>ArrayList</tt>) can produce quadratic behavior when applied to
* sequential access lists (such as <tt>LinkedList</tt>). Generic list
* algorithms are encouraged to check whether the given list is an
* <tt>instanceof</tt> this interface before applying an algorithm that would
* provide poor performance if it were applied to a sequential access list,
* and to alter their behavior if necessary to guarantee acceptable
* performance.
在集合类 synchronisedList 方法中,检查 RandomAccess 并且如果成功创建 SynchronizedRandomAccessList 对象,但它们也没有关于算法的详细信息。
public static <T> List<T> synchronizedList(List<T> list) {
return (list instanceof RandomAccess ?
new SynchronizedRandomAccessList<T>(list) :
new SynchronizedList<T>(list));
}
该算法何时应用以及在哪里应用(它是本机代码)?