企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] TreeSet内部使用TreeMap的key列来存储数据 ## 构造函数 ~~~ public class TreeSet<E> extends AbstractSet<E> implements NavigableSet<E>, Cloneable, Serializable { private transient NavigableMap<E, Object> m; private static final Object PRESENT = new Object(); TreeSet(NavigableMap<E, Object> var1) { this.m = var1; } public TreeSet() { this((NavigableMap)(new TreeMap())); } } ~~~ ## add ~~~ public boolean add(E var1) { return this.m.put(var1, PRESENT) == null; } ~~~ ## remove ~~~ public boolean remove(Object var1) { return this.m.remove(var1) == PRESENT; } ~~~