java是否有跳过列表实现 [英] Does java have a skip list implementation
问题描述
我找到 Java Collection Framework中的ConcurrentSkipListSet
,它使用跳过列表进行备份。但Java中是否有跳过列表?一套在我的用例中不起作用。我需要一个支持重复的可索引列表。
I find ConcurrentSkipListSet
in Java Collection Framework, which is backed up with a skip list. But is there a skip list in Java? A set does not work in my use case. I need a indexable list that supports duplicates.
推荐答案
因为你已经提到了一个可以索引的List(我假设你想要的)快速检索)并且需要允许重复,我建议你去找一个带有LinkedList或ArrayList的自定义Set。
Since you've mentioned a List that is both Indexable (I assume you want speedy retrieval) and need to allow duplicates, I would advise you go for a custom Set with a LinkedList or ArrayList perhaps.
你需要有一个基本集,一个HashSet例如,并继续向其添加值。如果您遇到重复,则该Set的值应指向List。因此,您将同时进行Speedy检索,当然您将以伪集合的方式存储对象。
You need to have a base Set, an HashSet for example and keep adding values to it. If you face a duplicate, the value of that Set should point to a List. So, that you will have both Speedy retrieval and of course you will store your objects in a psuedo Collection manner.
这样可以提高检索效率。理想情况下,如果您的密钥不重复,您将获得O(1)作为检索速度。
This should give you good efficiency for retrieval. Ideally if your Keys are not duplicates, you will achieve an O(1) as the retrieval speed.
这篇关于java是否有跳过列表实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!