[英]Can we reduce Time complexity O(n) of preparing a Java HashSet from an ArrayList?
[英]What is the computational complexity of generating a stream from a hashset in java? We may consider a hashset with $n$ elements and $m$ capacity
從 java 中的哈希集生成流的計算復雜度是多少? 我們可以考慮一個具有 $n$ 個元素和 $m$ 容量的哈希集。
例如:
Hashset hashset = new HashSet(m);
// ... put n < m elements in the hashset ...
hashset.stream().do something;
我對做某事的復雜性不感興趣,只是對構建流的復雜性感興趣。
創建流是O(1)
,它只是管道結構的創建。
然后,終端操作從源(在本例中為散列集)中提取元素並應用中間操作(如果有)。
創建流是聲明性的,即元素不會發生任何事情,直到調用終端操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.