• LinkedHashSet与TreeSet


    区别

    类型 实现 特点
    TreeSet hashMap、实现sortedSet接口 升序(基本类型……),自定义
    LinkedHashSet HashSet 初始顺序

    **注意点:
    1.treeSet的排序和toString实际上是基于 插入的对象的 compareTo
    和toString方法
    换言之:就是插入的对象的类需要有comparable接口
    2.set都不可以使用 collections.sort( List l)
    你看我里面的参数哦,知道原因了吧
    3.linkedHashSet的出现主要是为了规避 hashSet所造成的顺序混乱
    和TreeSet因关联而造成的开销
    **

  • 相关阅读:
    HDU 3537
    POJ 1175
    POJ 1021 人品题
    POJ 2068
    POJ 2608
    POJ 2960
    poj 1635
    ustc 1117
    ural 1468
    数字游戏
  • 原文地址:https://www.cnblogs.com/xieji233/p/6155627.html
Copyright © 2020-2023  润新知