国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - java 中RandomAccess接口源碼分析

java 中RandomAccess接口源碼分析

2020-11-01 23:05songwenlong Java教程

這篇文章主要介紹了java 中RandomAccess接口源碼分析的相關資料,需要的朋友可以參考下

javaRandomAccess接口源碼分析

RandomAccess是一個接口,位于java.util包中。

這個接口的作用注釋寫的很清楚了:

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * Marker interface used by <tt>List</tt> implementations to indicate that
 * they support fast (generally constant time) random access. The primary
 * purpose of this interface is to allow generic algorithms to alter their
 * behavior to provide good performance when applied to either random or
 * sequential access lists.
 * List實現所使用的標記接口,用來表明實現了這些接口的list支持快速(通常是常數時間)隨機訪問。
 * 這個接口的主要目的是允許一般的算法更改它們的行為,以便在隨機或者順序存取列表時能提供更好的性能。
 * <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.
 * 操作隨機訪問列表(如ArrayList)的最佳算法在應用于順序存取列表時,有可能產生二次項行為。
 * 泛型算法列表鼓勵在將某個算法應用于順序存取列表可能導致差的性能之前,先檢查給定的列表是否是這個接口的一個實例,
 * 并在需要時去改變這些算法的行為以保證性能。
 * <p>It is recognized that the distinction between random and sequential
 * access is often fuzzy. For example, some <tt>List</tt> implementations
 * provide asymptotically linear access times if they get huge, but constant
 * access times in practice. Such a <tt>List</tt> implementation
 * should generally implement this interface. As a rule of thumb, a
 * <tt>List</tt> implementation should implement this interface if,
 * for typical instances of the class, this loop:
 
 * 隨機訪問和順序存取之間的界限通常是模糊的。例如,一些List實現在變得很大時會導致漸進的非線性訪問時間,但實際上是常量訪問時間。
 * 這樣的List實現通常都應該實現該接口。
 * 一般來說,某個List實現如果(對某些典型的類的實例來說)滿足下面的條件,就應該實現這個接口:循環
 * <pre>
 *   for (int i=0, n=list.size(); i &lt; n; i++)
 *     list.get(i);
 * </pre>
 * runs faster than this loop:
 * 比下面的循環運行速度快。
 * <pre>
 *   for (Iterator i=list.iterator(); i.hasNext(); )
 *     i.next();
 * </pre>
 *
 * <p>This interface is a member of the
 * <a href="{@docRoot}/../technotes/guides/collections/index.html" rel="external nofollow" >
 * Java Collections Framework</a>.
 * 這個接口是Java集合框架的一員。
 * @since 1.4
 */
public interface RandomAccess {
}

 RandomAccess是一個空接口,而空接口的作用一般是起到一個標識的作用。

通俗點講,就是判斷一個list是否實現了RandomAcess接口,如果實現了,采用下面所示的簡單的for循環進行訪問速度比較快:

?
1
2
for (int i=0, n=list.size(); i &lt; n; i++)
   list.get(i);

如果未實現RandomAcess接口,則采用下面的iterator循環訪問速度比較快。

?
1
2
for (Iterator i=list.iterator(); i.hasNext(); )
   i.next();

判斷使用instanceof,即

?
1
if (list instanceof RandomAccess)

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

原文鏈接:http://www.cnblogs.com/songwenlong/p/6901669.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 91精品国产日韩91久久久久久 | 自拍偷拍一区二区三区 | 视频三区 | 日韩高清不卡一区二区三区 | 亚洲免费大片 | 国产精品久久久久久久久福交 | 久久久嫩草 | 樱桃小丸子在线观看 | 欧美一级片免费在线观看 | 亚洲蜜桃精久久久久久久 | 日韩精品一区二区三区中文在线 | 亚洲黄色高清 | 午夜免费| 久久精品国产亚卅av嘿嘿 | 国内精品一区二区 | 色综合视频在线观看 | 日韩精品一区二区三区视频播放 | 日本不卡高字幕在线2019 | 啊啊啊网站 | 欧美精品免费在线 | 欧美一级片在线 | 日韩成人免费 | 国产高清精品在线 | 中文在线一区二区 | 欧美色综合天天久久综合精品 | 曰本人一级毛片免费完整视频 | av在线电影网站 | 最新中文字幕在线 | 久久久99精品免费观看 | 黄a在线 | 午夜色电影 | 国产精品成人一区二区三区夜夜夜 | 欧美一区二区三区在线播放 | 欧美午夜精品久久久久久浪潮 | 国产福利一区二区三区四区 | 亚洲一区二区久久 | 久久久精品影院 | 成人福利免费在线观看 | 日韩欧美h | 亚洲五码在线 | 毛片在线免费观看网站 |