开发者

Java PriorityQueue(PriorityQueue) constructor

开发者 https://www.devze.com 2023-03-04 12:14 出处:网络
Is the java API PriorityQueue constructor that takes another priority queue destructive to the argument?开发者_运维问答If so, is its clone() method adequate for creating a shallow copy?No, it is not d

Is the java API PriorityQueue constructor that takes another priority queue destructive to the argument?开发者_运维问答 If so, is its clone() method adequate for creating a shallow copy?


No, it is not destructive. Pretty much all the collection classes have copy constructors, and are non-destructive by convention.

The reason there are overloaded constructors is for efficiency; when a PQ or SortedSet is supplied, one can imagine that the initial population of elements can be O(n) instead of O(n log n)

0

精彩评论

暂无评论...
验证码 换一张
取 消