Does java have a skip list implementation

后端 未结 7 1567
北恋
北恋 2021-02-13 03:51

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 in

7条回答
  •  一向
    一向 (楼主)
    2021-02-13 04:20

    When you create a ConcurrentSkipListSet, you pass a comparator to the constructor.

    new ConcurrentSkipListSet<>(new ExampleComparator());
    
    public class ExampleComparator implements Comparator {//your impl }
    

    You could create a comparator that will make your SkipListSet behave as a normal List.

提交回复
热议问题