热门标签 | HotTags
当前位置:  开发笔记 > 开发工具 > 正文

Java之TreeSet的详细使用说明

这篇文章主要介绍了Java之TreeSet的详细使用说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

第1部分 TreeSet介绍

TreeSet简介

TreeSet 是一个有序的集合,它的作用是提供有序的Set集合。它继承于AbstractSet抽象类,实现了NavigableSet, Cloneable, java.io.Serializable接口。

TreeSet 继承于AbstractSet,所以它是一个Set集合,具有Set的属性和方法。

TreeSet 实现了NavigableSet接口,意味着它支持一系列的导航方法。比如查找与指定目标最匹配项。

TreeSet 实现了Cloneable接口,意味着它能被克隆。

TreeSet 实现了java.io.Serializable接口,意味着它支持序列化。

TreeSet是基于TreeMap实现的。TreeSet中的元素支持2种排序方式:自然排序 或者 根据创建TreeSet 时提供的 Comparator 进行排序。这取决于使用的构造方法。

TreeSet为基本操作(add、remove 和 contains)提供受保证的 log(n) 时间开销。

另外,TreeSet是非同步的。 它的iterator 方法返回的迭代器是fail-fast的。

TreeSet的构造函数

// 默认构造函数。使用该构造函数,TreeSet中的元素按照自然排序进行排列。
TreeSet()
// 创建的TreeSet包含collection
TreeSet(Collection<&#63; extends E> collection)
// 指定TreeSet的比较器
TreeSet(Comparator<&#63; super E> comparator)
// 创建的TreeSet包含set
TreeSet(SortedSet set)
TreeSet的API
boolean   add(E object)
boolean   addAll(Collection<&#63; extends E> collection)
void   clear()
Object   clone()
boolean   contains(Object object)
E    first()
boolean   isEmpty()
E    last()
E    pollFirst()
E    pollLast()
E    lower(E e)
E    floor(E e)
E    ceiling(E e)
E    higher(E e)
boolean   remove(Object object)
int   size()
Comparator<&#63; super E> comparator()
Iterator  iterator()
Iterator  descendingIterator()
SortedSet  headSet(E end)
NavigableSet  descendingSet()
NavigableSet  headSet(E end, boolean endInclusive)
SortedSet  subSet(E start, E end)
NavigableSet  subSet(E start, boolean startInclusive, E end, boolean endInclusive)
NavigableSet  tailSet(E start, boolean startInclusive)
SortedSet  tailSet(E start)

说明:

(01) TreeSet是有序的Set集合,因此支持add、remove、get等方法。

(02) 和NavigableSet一样,TreeSet的导航方法大致可以区分为两类,一类时提供元素项的导航方法,返回某个元素;另一类时提供集合的导航方法,返回某个集合。

lower、floor、ceiling 和 higher 分别返回小于、小于等于、大于等于、大于给定元素的元素,如果不存在这样的元素,则返回 null。

第2部分 TreeSet数据结构

TreeSet的继承关系

java.lang.Object
 &#8627; java.util.AbstractCollection
  &#8627; java.util.AbstractSet
  &#8627; java.util.TreeSet
public class TreeSet extends AbstractSet 
 implements NavigableSet, Cloneable, java.io.Serializable{}

TreeSet与Collection关系如下图:

从图中可以看出:

(01) TreeSet继承于AbstractSet,并且实现了NavigableSet接口。

(02) TreeSet的本质是一个"有序的,并且没有重复元素"的集合,它是通过TreeMap实现的。TreeSet中含有一个"NavigableMap类型的成员变量"m,而m实际上是"TreeMap的实例"。

第3部分 TreeSet源码解析(基于JDK1.6.0_45)

为了更了解TreeSet的原理,下面对TreeSet源码代码作出分析。

 package java.util; 
 public class TreeSet extends AbstractSet
 implements NavigableSet, Cloneable, java.io.Serializable
 {
 // NavigableMap对象
 private transient NavigableMap m;
 
 // TreeSet是通过TreeMap实现的,
 // PRESENT是键-值对中的值。
 private static final Object PRESENT = new Object();
 // 不带参数的构造函数。创建一个空的TreeMap
 public TreeSet() {
 this(new TreeMap());
 }
 // 将TreeMap赋值给 "NavigableMap对象m"
 TreeSet(NavigableMap m) {
 this.m = m;
 }
 // 带比较器的构造函数。
 public TreeSet(Comparator<&#63; super E> comparator) {
 this(new TreeMap(comparator));
 }
 // 创建TreeSet,并将集合c中的全部元素都添加到TreeSet中
 public TreeSet(Collection<&#63; extends E> c) {
 this();
 // 将集合c中的元素全部添加到TreeSet中
 addAll(c);
 }
 // 创建TreeSet,并将s中的全部元素都添加到TreeSet中
 public TreeSet(SortedSet s) {
 this(s.comparator());
 addAll(s);
 }
 // 返回TreeSet的顺序排列的迭代器。
 // 因为TreeSet时TreeMap实现的,所以这里实际上时返回TreeMap的“键集”对应的迭代器
 public Iterator iterator() {
 return m.navigableKeySet().iterator();
 }
 // 返回TreeSet的逆序排列的迭代器。
 // 因为TreeSet时TreeMap实现的,所以这里实际上时返回TreeMap的“键集”对应的迭代器
 public Iterator descendingIterator() {
 return m.descendingKeySet().iterator();
 }
 // 返回TreeSet的大小
 public int size() {
 return m.size();
 }
 // 返回TreeSet是否为空
 public boolean isEmpty() {
 return m.isEmpty();
 }
 // 返回TreeSet是否包含对象(o)
 public boolean contains(Object o) {
 return m.containsKey(o);
 }
 // 添加e到TreeSet中
 public boolean add(E e) {
 return m.put(e, PRESENT)==null;
 }
 // 删除TreeSet中的对象o
 public boolean remove(Object o) {
 return m.remove(o)==PRESENT;
 }
 // 清空TreeSet
 public void clear() {
 m.clear();
 }
 // 将集合c中的全部元素添加到TreeSet中
 public boolean addAll(Collection<&#63; extends E> c) {
 // Use linear-time version if applicable
 if (m.size()==0 && c.size() > 0 &&
  c instanceof SortedSet &&
  m instanceof TreeMap) {
  SortedSet<&#63; extends E> set = (SortedSet<&#63; extends E>) c;
  TreeMap map = (TreeMap) m;
  Comparator<&#63; super E> cc = (Comparator<&#63; super E>) set.comparator();
  Comparator<&#63; super E> mc = map.comparator();
  if (cc==mc || (cc != null && cc.equals(mc))) {
  map.addAllForTreeSet(set, PRESENT);
  return true;
  }
 }
 return super.addAll(c);
 }
 
 // 返回子Set,实际上是通过TreeMap的subMap()实现的。
 public NavigableSet subSet(E fromElement, boolean fromInclusive,
     E toElement, boolean toInclusive) {
  return new TreeSet(m.subMap(fromElement, fromInclusive,
     toElement, toInclusive));
 }
 
 // 返回Set的头部,范围是:从头部到toElement。
 // inclusive是是否包含toElement的标志
 public NavigableSet headSet(E toElement, boolean inclusive) {
  return new TreeSet(m.headMap(toElement, inclusive));
 }
 
 // 返回Set的尾部,范围是:从fromElement到结尾。
 // inclusive是是否包含fromElement的标志
 public NavigableSet tailSet(E fromElement, boolean inclusive) {
  return new TreeSet(m.tailMap(fromElement, inclusive));
 }
 
 // 返回子Set。范围是:从fromElement(包括)到toElement(不包括)。
 public SortedSet subSet(E fromElement, E toElement) {
  return subSet(fromElement, true, toElement, false);
 }
 
 // 返回Set的头部,范围是:从头部到toElement(不包括)。
 public SortedSet headSet(E toElement) {
  return headSet(toElement, false);
 }
 
 // 返回Set的尾部,范围是:从fromElement到结尾(不包括)。
 public SortedSet tailSet(E fromElement) {
  return tailSet(fromElement, true);
 }
 
 // 返回Set的比较器
 public Comparator<&#63; super E> comparator() {
  return m.comparator();
 }
 
 // 返回Set的第一个元素
 public E first() {
  return m.firstKey();
 }
 
 // 返回Set的最后一个元素
 public E first() {
 public E last() {
  return m.lastKey();
 }
 
 // 返回Set中小于e的最大元素
 public E lower(E e) {
  return m.lowerKey(e);
 }
 
 // 返回Set中小于/等于e的最大元素
 public E floor(E e) {
  return m.floorKey(e);
 }
 
 // 返回Set中大于/等于e的最小元素
 public E ceiling(E e) {
  return m.ceilingKey(e);
 }
 
 // 返回Set中大于e的最小元素
 public E higher(E e) {
  return m.higherKey(e);
 }
 
 // 获取第一个元素,并将该元素从TreeMap中删除。
 public E pollFirst() {
  Map.Entry e = m.pollFirstEntry();
  return (e == null)&#63; null : e.getKey();
 }
 
 // 获取最后一个元素,并将该元素从TreeMap中删除。
 public E pollLast() {
  Map.Entry e = m.pollLastEntry();
  return (e == null)&#63; null : e.getKey();
 }
 
 // 克隆一个TreeSet,并返回Object对象
 public Object clone() {
  TreeSet clOne= null;
  try {
  clOne= (TreeSet) super.clone();
  } catch (CloneNotSupportedException e) {
  throw new InternalError();
  }
 
  clone.m = new TreeMap(m);
  return clone;
 }
 
 // java.io.Serializable的写入函数
 // 将TreeSet的“比较器、容量,所有的元素值”都写入到输出流中
 private void writeObject(java.io.ObjectOutputStream s)
  throws java.io.IOException {
  s.defaultWriteObject();
 
  // 写入比较器
  s.writeObject(m.comparator());
 
  // 写入容量
  s.writeInt(m.size());
 
  // 写入“TreeSet中的每一个元素”
  for (Iterator i=m.keySet().iterator(); i.hasNext(); )
  s.writeObject(i.next());
 }
 
 // java.io.Serializable的读取函数:根据写入方式读出
 // 先将TreeSet的“比较器、容量、所有的元素值”依次读出
 private void readObject(java.io.ObjectInputStream s)
  throws java.io.IOException, ClassNotFoundException {
  // Read in any hidden stuff
  s.defaultReadObject();
 
  // 从输入流中读取TreeSet的“比较器”
  Comparator<&#63; super E> c = (Comparator<&#63; super E>) s.readObject();
 
  TreeMap tm;
  if (c==null)
  tm = new TreeMap();
  else
  tm = new TreeMap(c);
  m = tm;
 
  // 从输入流中读取TreeSet的“容量”
  int size = s.readInt();
 
  // 从输入流中读取TreeSet的“全部元素”
  tm.readTreeSet(size, s, PRESENT);
 }
 
 // TreeSet的序列版本号
 private static final long serialVersiOnUID= -2479143000061671589L;
 }

总结:

(01) TreeSet实际上是TreeMap实现的。当我们构造TreeSet时;若使用不带参数的构造函数,则TreeSet的使用自然比较器;若用户需要使用自定义的比较器,则需要使用带比较器的参数。

(02) TreeSet是非线程安全的。

(03) TreeSet实现java.io.Serializable的方式。当写入到输出流时,依次写入“比较器、容量、全部元素”;当读出输入流时,再依次读取。

第4部分 TreeSet遍历方式

4.1 Iterator顺序遍历

for(Iterator iter = set.iterator(); iter.hasNext(); ) { 
 iter.next();
} 

4.2 Iterator顺序遍历

// 假设set是TreeSet对象
for(Iterator iter = set.descendingIterator(); iter.hasNext(); ) { 
 iter.next();
}

4.3 for-each遍历HashSet

// 假设set是TreeSet对象,并且set中元素是String类型
String[] arr = (String[])set.toArray(new String[0]);
for (String str:arr)
 System.out.printf("for each : %s\n", str);

TreeSet不支持快速随机遍历,只能通过迭代器进行遍历!

TreeSet遍历测试程序如下:

 import java.util.*;
 
 /**
 * @desc TreeSet的遍历程序
 *
 * @author skywang
 * @email kuiwu-wang@163.com
 */
 public class TreeSetIteratorTest {
 
 public static void main(String[] args) {
  TreeSet set = new TreeSet();
  set.add("aaa");
  set.add("aaa");
  set.add("bbb");
  set.add("eee");
  set.add("ddd");
  set.add("ccc");
 
  // 顺序遍历TreeSet
  ascIteratorThroughIterator(set) ;
  // 逆序遍历TreeSet
  descIteratorThroughIterator(set);
  // 通过for-each遍历TreeSet。不推荐!此方法需要先将Set转换为数组
  foreachTreeSet(set);
 }
 
 // 顺序遍历TreeSet
 public static void ascIteratorThroughIterator(TreeSet set) {
  System.out.print("\n ---- Ascend Iterator ----\n");
  for(Iterator iter = set.iterator(); iter.hasNext(); ) {
  System.out.printf("asc : %s\n", iter.next());
  }
 }
 
 // 逆序遍历TreeSet
 public static void descIteratorThroughIterator(TreeSet set) {
  System.out.printf("\n ---- Descend Iterator ----\n");
  for(Iterator iter = set.descendingIterator(); iter.hasNext(); )
  System.out.printf("desc : %s\n", (String)iter.next());
 }
 
 // 通过for-each遍历TreeSet。不推荐!此方法需要先将Set转换为数组
 private static void foreachTreeSet(TreeSet set) {
  System.out.printf("\n ---- For-each ----\n");
  String[] arr = (String[])set.toArray(new String[0]);
  for (String str:arr)
  System.out.printf("for each : %s\n", str);
 }
 }

运行结果:

---- Ascend Iterator ----
asc : aaa
asc : bbb
asc : ccc
asc : ddd
asc : eee
---- Descend Iterator ----
desc : eee
desc : ddd
desc : ccc
desc : bbb
desc : aaa
---- For-each ----
for each : aaa
for each : bbb
for each : ccc
for each : ddd
for each : eee

第5部分 TreeSet示例

下面通过实例学习如何使用TreeSet

import java.util.*;
/**
 * @desc TreeSet的API测试
 *
 * @author skywang
 * @email kuiwu-wang@163.com
 */
public class TreeSetTest {
 public static void main(String[] args) {
 testTreeSetAPIs();
 }
 
 // 测试TreeSet的api
 public static void testTreeSetAPIs() {
 String val;
 // 新建TreeSet
 TreeSet tSet = new TreeSet();
 // 将元素添加到TreeSet中
 tSet.add("aaa");
 // Set中不允许重复元素,所以只会保存一个“aaa”
 tSet.add("aaa");
 tSet.add("bbb");
 tSet.add("eee");
 tSet.add("ddd");
 tSet.add("ccc");
 System.out.println("TreeSet:"+tSet);
 // 打印TreeSet的实际大小
 System.out.printf("size : %d\n", tSet.size());
 // 导航方法
 // floor(小于、等于)
 System.out.printf("floor bbb: %s\n", tSet.floor("bbb"));
 // lower(小于)
 System.out.printf("lower bbb: %s\n", tSet.lower("bbb"));
 // ceiling(大于、等于)
 System.out.printf("ceiling bbb: %s\n", tSet.ceiling("bbb"));
 System.out.printf("ceiling eee: %s\n", tSet.ceiling("eee"));
 // ceiling(大于)
 System.out.printf("higher bbb: %s\n", tSet.higher("bbb"));
 // subSet()
 System.out.printf("subSet(aaa, true, ccc, true): %s\n", tSet.subSet("aaa", true, "ccc", true));
 System.out.printf("subSet(aaa, true, ccc, false): %s\n", tSet.subSet("aaa", true, "ccc", false));
 System.out.printf("subSet(aaa, false, ccc, true): %s\n", tSet.subSet("aaa", false, "ccc", true));
 System.out.printf("subSet(aaa, false, ccc, false): %s\n", tSet.subSet("aaa", false, "ccc", false));
 // headSet()
 System.out.printf("headSet(ccc, true): %s\n", tSet.headSet("ccc", true));
 System.out.printf("headSet(ccc, false): %s\n", tSet.headSet("ccc", false));
 // tailSet()
 System.out.printf("tailSet(ccc, true): %s\n", tSet.tailSet("ccc", true));
 System.out.printf("tailSet(ccc, false): %s\n", tSet.tailSet("ccc", false));
 // 删除“ccc”
 tSet.remove("ccc");
 // 将Set转换为数组
 String[] arr = (String[])tSet.toArray(new String[0]);
 for (String str:arr)
  System.out.printf("for each : %s\n", str);
 // 打印TreeSet
 System.out.printf("TreeSet:%s\n", tSet);
 // 遍历TreeSet
 for(Iterator iter = tSet.iterator(); iter.hasNext(); ) {
  System.out.printf("iter : %s\n", iter.next());
 }
 // 删除并返回第一个元素
 val = (String)tSet.pollFirst();
 System.out.printf("pollFirst=%s, set=%s\n", val, tSet);
 // 删除并返回最后一个元素
 val = (String)tSet.pollLast();
 System.out.printf("pollLast=%s, set=%s\n", val, tSet);
 // 清空HashSet
 tSet.clear();
 // 输出HashSet是否为空
 System.out.printf("%s\n", tSet.isEmpty()&#63;"set is empty":"set is not empty");
 }
}

运行结果:

TreeSet:[aaa, bbb, ccc, ddd, eee]
size : 5
floor bbb: bbb
lower bbb: aaa
ceiling bbb: bbb
ceiling eee: eee
higher bbb: ccc
subSet(aaa, true, ccc, true): [aaa, bbb, ccc]
subSet(aaa, true, ccc, false): [aaa, bbb]
subSet(aaa, false, ccc, true): [bbb, ccc]
subSet(aaa, false, ccc, false): [bbb]
headSet(ccc, true): [aaa, bbb, ccc]
headSet(ccc, false): [aaa, bbb]
tailSet(ccc, true): [ccc, ddd, eee]
tailSet(ccc, false): [ddd, eee]
for each : aaa
for each : bbb
for each : ddd
for each : eee
TreeSet:[aaa, bbb, ddd, eee]
iter : aaa
iter : bbb
iter : ddd
iter : eee
pollFirst=aaa, set=[bbb, ddd, eee]
pollLast=eee, set=[bbb, ddd]
set is empty

补充:Java中关于使用TreeSet存储数据的自然排序和定制排序

一、题目

创建类的 5 个对象,并把这些对象放入 TreeSet 集合中(TreeSet 需使用泛型和不用泛型分别来定义)

分别按以下两种方式对集合中的元素进行排序,并遍历输出:

1、使 Employee 实现 Comparable 接口,并按 name 排序

2、创建 TreeSet 时传入 Comparator 对象,按生日日期的先后排序。

二、定义一个 Employee 类

/**
 * 该类包含:private 成员变量 name,age,birthday,其中 birthday 为
 * MyDate 类的对象;
 * 并为每一个属性定义 getter, setter 方法;
 * 并重写 toString 方法输出 name, age, birthday
 * @author
 * @create 2021-01-22-15:00
 */
public class Employee implements Comparable {
 private String name;
 private int age;
 private MyDate birthday;
 public Employee() {
 }
 public Employee(String name, int age, MyDate birthday) {
  this.name = name;
  this.age = age;
  this.birthday = birthday;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public int getAge() {
  return age;
 }
 public void setAge(int age) {
  this.age = age;
 }
 public MyDate getBirthday() {
  return birthday;
 }
 public void setBirthday(MyDate birthday) {
  this.birthday = birthday;
 }
 @Override
 public String toString() {
  return "Employee{" +
    "name='" + name + '\'' +
    ", age=" + age +
    ", birthday=" + birthday +
    '}';
 }
  //不用泛型
// @Override
// public int compareTo(Object o) {
//  if(o instanceof Employee){
//   Employee employee = (Employee) o;
//   return this.name.compareTo(employee.name);
//  }
//  throw new RuntimeException("输入的数据类型不一致");
// }
  //使用泛型
 @Override
 public int compareTo(Employee o) {
  return this.name.compareTo(o.name);
 }
}

三、MyDate 类

/**
 * MyDate 类包含:
 * private 成员变量 year,month,day;并为每一个属性定义 getter, setter
 * 方法;
 * @author 
 * @create 2021-01-22-15:00
 */
public class MyDate implements Comparable {
 private int year;
 private int month;
 private int day;
 public MyDate() {
 }
 public MyDate(int year, int month, int day) {
  this.year = year;
  this.mOnth= month;
  this.day = day;
 }
 @Override
 public String toString() {
  return "MyDate{" +
    "year=" + year +
    ", mOnth=" + month +
    ", day=" + day +
    '}';
 }
 public int getYear() {
  return year;
 }
 public void setYear(int year) {
  this.year = year;
 }
 public int getMonth() {
  return month;
 }
 public void setMonth(int month) {
  this.mOnth= month;
 }
 public int getDay() {
  return day;
 }
 public void setDay(int day) {
  this.day = day;
 }
 @Override
 public int compareTo(MyDate o) {
  int minusYear= this.year-o.year;
  if (minusYear !=0){
   return minusYear;
  }
  int minusMOnth= this.month-o.month;
  if (minusMonth !=0){
   return minusMonth;
  }
  return this.day-o.day;
 }
}

四、单元测试

(一)

@Test
 public void test1(){
  TreeSet set = new TreeSet<>();
  set.add(new Employee("hh",23,new MyDate(1992,4,12)));
  set.add(new Employee("ff",43,new MyDate(1956,5,4)));
  set.add(new Employee("aa",27,new MyDate(1936,8,6)));
  set.add(new Employee("gg",38,new MyDate(1992,4,4)));
  Iterator iterator = set.iterator();
  while (iterator.hasNext()){
   System.out.println(iterator.next());
  }
 }

结果如下:

(二)

 @Test
 public void test2(){
  TreeSet set = new TreeSet<>(new Comparator() {
   @Override
   public int compare(Employee e1, Employee e2) {
    //加上泛型
    MyDate b1 = e1.getBirthday();
    MyDate b2 = e2.getBirthday();
    return b1.compareTo(b2);
    //不加泛型
//    if (o1 instanceof Employee && o2 instanceof Employee){
//     Employee m1 = (Employee) o1;
//     Employee m2 = (Employee) o2;
//     MyDate m1Birthday = m1.getBirthday();
//     MyDate m2Birthday = m2.getBirthday();
//
//     int minusYear = m1Birthday.getYear()- m2Birthday.getYear();
//     if (minusYear!=0){
//      return minusYear;
//     }
//     int minusMOnth= m1Birthday.getMonth()- m2Birthday.getMonth();
//     if (minusMonth!=0){
//      return minusMonth;
//     }
//     int minusDay = m1Birthday.getDay()- m2Birthday.getDay();
//     return minusDay;
//
//    }
//    throw new RuntimeException("传入的数据类型不一致");
   }
  });
  set.add(new Employee("hh",23,new MyDate(1944,12,4)));
  set.add(new Employee("ff",43,new MyDate(1957,5,4)));
  set.add(new Employee("aa",27,new MyDate(1906,12,6)));
  set.add(new Employee("gg",38,new MyDate(1906,4,4)));
  Iterator iterator = set.iterator();
  while (iterator.hasNext()){
   System.out.println(iterator.next());
  }
 }

结果如下:

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。


推荐阅读
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 电话号码的字母组合解题思路和代码示例
    本文介绍了力扣题目《电话号码的字母组合》的解题思路和代码示例。通过使用哈希表和递归求解的方法,可以将给定的电话号码转换为对应的字母组合。详细的解题思路和代码示例可以帮助读者更好地理解和实现该题目。 ... [详细]
  • 本文介绍了adg架构设置在企业数据治理中的应用。随着信息技术的发展,企业IT系统的快速发展使得数据成为企业业务增长的新动力,但同时也带来了数据冗余、数据难发现、效率低下、资源消耗等问题。本文讨论了企业面临的几类尖锐问题,并提出了解决方案,包括确保库表结构与系统测试版本一致、避免数据冗余、快速定位问题等。此外,本文还探讨了adg架构在大版本升级、上云服务和微服务治理方面的应用。通过本文的介绍,读者可以了解到adg架构设置的重要性及其在企业数据治理中的应用。 ... [详细]
  • 本文详细介绍了云服务器API接口的概念和作用,以及如何使用API接口管理云上资源和开发应用程序。通过创建实例API、调整实例配置API、关闭实例API和退还实例API等功能,可以实现云服务器的创建、配置修改和销毁等操作。对于想要学习云服务器API接口的人来说,本文提供了详细的入门指南和使用方法。如果想进一步了解相关知识或阅读更多相关文章,请关注编程笔记行业资讯频道。 ... [详细]
  • 生成对抗式网络GAN及其衍生CGAN、DCGAN、WGAN、LSGAN、BEGAN介绍
    一、GAN原理介绍学习GAN的第一篇论文当然由是IanGoodfellow于2014年发表的GenerativeAdversarialNetworks(论文下载链接arxiv:[h ... [详细]
  • 信息安全等级保护是指对国家秘密信息、法人和其他组织及公民的专有信息以及公开信息和存储、传输、处理这些信息的信息系统分等级实行安全保护,对信息系统中使用的信息安全产品实 ... [详细]
  • 无线认证设置故障排除方法及注意事项
    本文介绍了解决无线认证设置故障的方法和注意事项,包括检查无线路由器工作状态、关闭手机休眠状态下的网络设置、重启路由器、更改认证类型、恢复出厂设置和手机网络设置等。通过这些方法,可以解决无线认证设置可能出现的问题,确保无线网络正常连接和上网。同时,还提供了一些注意事项,以便用户在进行无线认证设置时能够正确操作。 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • 本文详细介绍了相机防抖的设置方法和使用技巧,包括索尼防抖设置、VR和Stabilizer档位的选择、机身菜单设置等。同时解释了相机防抖的原理,包括电子防抖和光学防抖的区别,以及它们对画质细节的影响。此外,还提到了一些运动相机的防抖方法,如大疆的Osmo Action的Rock Steady技术。通过本文,你将更好地理解相机防抖的重要性和使用技巧,提高拍摄体验。 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 本文详细介绍了华为4GLTE路由器B310的外置天线安装和设置方法。通过连接电源和网线,输入路由器的IP并登陆设置页面,选择手动设置和手动因特网设置,输入ISP提供商的用户名和密码,并设置MTU值。同时,还介绍了无线加密的设置方法。最后,将外网线连在路由器的WAN口即可使用。 ... [详细]
  • 本文讨论了前端工程化的准备工作,主要包括性能优化、安全防护和监控等方面需要注意的事项。通过系统的答案,帮助前端开发者更好地进行工程化的准备工作,提升网站的性能、安全性和监控能力。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • MyBatis错题分析解析及注意事项
    本文对MyBatis的错题进行了分析和解析,同时介绍了使用MyBatis时需要注意的一些事项,如resultMap的使用、SqlSession和SqlSessionFactory的获取方式、动态SQL中的else元素和when元素的使用、resource属性和url属性的配置方式、typeAliases的使用方法等。同时还指出了在属性名与查询字段名不一致时需要使用resultMap进行结果映射,而不能使用resultType。 ... [详细]
author-avatar
IDC小林
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有