gpt4 book ai didi

java - 有没有一种方法可以按照传递的顺序从集合中恢复对象?

转载 作者:行者123 更新时间:2023-12-02 03:39:27 25 4
gpt4 key购买 nike

我需要按照传递到集合中的顺序恢复 java Set 集合接口(interface)的元素。

java中怎么可能

最佳答案

怎么样LinkedHashSet

Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). Note that insertion order is not affected if an element is re-inserted into the set. (An element e is reinserted into a set s if s.add(e) is invoked when s.contains(e) would return true immediately prior to the invocation.)

关于java - 有没有一种方法可以按照传递的顺序从集合中恢复对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6030780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com