5
在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));
}
這個算法什麼時候適用,哪裏(是一個本地代碼)?
'synchronizedList'創建一個數據結構,它不是一個真正的算法... – 2013-03-12 08:40:02
@OliCharlesworth這是正確的,但看到的文檔評論,談論算法...即時詢問什麼時候和在算法應用 – Prateek 2013-03-12 08:42:13
什麼算法你指的是? – 2013-03-12 08:43:41