Java官方笔记13集合

news2024/11/13 10:18:06

Storing Data

The Collections Framework is the most widely used API of the JDK.

集合不是数据类型,它是JDK的API,可以用来存储数据等,相当于数据结构。

the Collections Framework is a set of interfaces that models different way of storing data in different types of containers. Then the Framework provides at least one implementation for each interface.

There are two main categories of interfaces in the Collections Framework: collections and maps.(所以我猜想Python也是基于这样的考虑,设计了List和Dict,并作为Python基本数据类型,实际编码中要用到的也主要是这两类)

That makes two main categories, Collection and Map, a subcategory, Queue, and a side category, Iterator.

a collection is an object,but an array is not an object in Java.

Collection Hierarchy

The Iterable Interface is the super interface of the Collection interface, and thus of all the interfaces of this hierarchy. An object that implements Iterable is an object that you can iterate over.

the Collection interface also models different ways of accessing its elements:

  • you can iterate over the elements of a collection, through the use of an iterator;
  • you can create a stream on these elements, that can be parallel.

List是有序列表

The difference between a List of elements and a Collection of elements, is that a List remembers in what order its elements have been added. If you iterate over the elements of a list, the first element you will get is the first that has been added.

You do not have this guarantee with a plain Collection nor for a Set.

List跟Collection的区别是,增加了index。

Set跟Collection的区别是,不允许重复。

Set是无序的,SortedSet是排序过的,SortedSet的排序是指从小到大排列,跟List的有序不一样,List有序是指的先添加排前面,不一定是最小的。

Storing Elements

Collection<String> strings = new ArrayList<>();
strings.add("one");
strings.add("two");
System.out.println("strings = " + strings);
strings.remove("one");
System.out.println("strings = " + strings);
  • containsAll(): defines the inclusion

    Collection<String> strings = new ArrayList<>();
    strings.add("one");
    strings.add("two");
    strings.add("three");
    
    Collection<String> first = new ArrayList<>();
    strings.add("one");
    strings.add("two");
    
    Collection<String> second = new ArrayList<>();
    strings.add("one");
    strings.add("four");
    
    System.out.println("Is first contained in strings? " + strings.containsAll(first));
    System.out.println("Is second contained in strings? " + strings.containsAll(second));
  • addAll(): defines the union 并集

    Getting a true value does not mean that all the elements of the other collection have been added; it means that at least one has been added.

    Collection<String> strings = new ArrayList<>();
    strings.add("one");
    strings.add("two");
    strings.add("three");
    
    Collection<String> first = new ArrayList<>();
    first.add("one");
    first.add("four");
    
    boolean hasChanged = strings.addAll(first);
    
    System.out.println("Has strings changed? " + hasChanged);
    System.out.println("strings = " + strings);
  • removeAll(): defines the complement

    Collection<String> strings = new ArrayList<>();
    strings.add("one");
    strings.add("two");
    strings.add("three");
    
    Collection<String> toBeRemoved = new ArrayList<>();
    toBeRemoved.add("one");
    toBeRemoved.add("four");
    
    boolean hasChanged = strings.removeAll(toBeRemoved);
    
    System.out.println("Has strings changed? " + hasChanged);
    System.out.println("strings = " + strings);
  • retainAll(): defines the intersection 交集

    Collection<String> strings = new ArrayList<>();
    strings.add("one");
    strings.add("two");
    strings.add("three");
    
    Collection<String> toBeRetained = new ArrayList<>();
    toBeRetained.add("one");
    toBeRetained.add("four");
    
    boolean hasChanged = strings.retainAll(toBeRetained);
    
    System.out.println("Has strings changed? " + hasChanged);
    System.out.println("strings = " + strings);

注意上面的并集和交集,Collection本来就是集合,所以能够求并集和交集是理所当然的。

isEmpty()、clear()

Collection<String> strings = new ArrayList<>();
strings.add("one");
strings.add("two");
if (!strings.isEmpty()) {
    System.out.println("Indeed strings is not empty!");
}
System.out.println("The number of elements in strings is " + strings.size());
Collection<String> strings = new ArrayList<>();
strings.add("one");
strings.add("two");
System.out.println("The number of elements in strings is " + strings.size());
strings.clear();
System.out.println("After clearing it, this number is now " + strings.size());

size(),Collection相当于容器,用size。而array和String,相当于序列,用length。

toArray

将Collection转为array:

①无入参:

Collection<String> strings = ...; // suppose you have 15 elements in that collection

String[] tabString1 = strings.toArray(new String[] {}); // you can pass an empty array
String[] tabString2 = strings.toArray(new String[15]);   // or an array of the right size

②传参

Collection<String> strings = List.of("one", "two");

String[] largerTab = {"three", "three", "three", "I", "was", "there"};
System.out.println("largerTab = " + Arrays.toString(largerTab));

String[] result = strings.toArray(largerTab);
System.out.println("result = " + Arrays.toString(result));

System.out.println("Same arrays? " + (result == largerTab));
Collection<String> strings = List.of("one", "two");

String[] zeroLengthTab = {};
String[] result = strings.toArray(zeroLengthTab);

System.out.println("zeroLengthTab = " + Arrays.toString(zeroLengthTab));
System.out.println("result = " + Arrays.toString(result));

③简写

Collection<String> strings = ...;

String[] tabString3 = strings.toArray(String[]::new);

Predicate + removeIf 实现有条件的删除,比如删除null和empty的元素:

Predicate<String> isNull = Objects::isNull;
Predicate<String> isEmpty = String::isEmpty;
Predicate<String> isNullOrEmpty = isNull.or(isEmpty);

Collection<String> strings = new ArrayList<>();
strings.add(null);
strings.add("");
strings.add("one");
strings.add("two");
strings.add("");
strings.add("three");
strings.add(null);

System.out.println("strings = " + strings);
strings.removeIf(isNullOrEmpty);
System.out.println("filtered strings = " + strings);

Iterating

for-each

Collection<String> strings = List.of("one", "two", "three");

for (String element: strings) {
    System.out.println(string);
}

Iterator

Collection<String> strings = List.of("one", "two", "three", "four");
for (Iterator<String> iterator = strings.iterator(); iterator.hasNext();) {
    String element = iterator.next();
    if (element.length() == 3) {
        System.out.println(element);
    }
}

List

the List interface has 2: ArrayList and LinkedList. As you may guess, the first one is built on an internal array, and the second on a doubly-linked list.

Iterating over the elements of an ArrayList is much faster that over the elements of a LinkedList.
There are still cases where a linked list is faster than an array. A doubly-linked list can access its first and last element faster than an ArrayList can. This is the main use case that makes LinkedList better than ArrayList. So if your application needs a Last In, First Out (LIFO, covered later in this tutorial) stack, or a First In, First Out (FIFO, also covered later) waiting queue, then choosing a linked list is probably your best choice.

注意,链表在插入和删除的速度优势已经不在,因为现代硬件、CPU缓存和指针追踪已经很强大。

index

  • add(index, element): inserts the given object at the index, adjusting the index if there are remaining elements
  • get(index): returns the object at the given index
  • set(index, element): replaces the element at the given index with the new element
  • remove(index): removes the element at the given index, adjusting the index of the remaining elements.

The methods indexOf(element) and lastIndexOf(element) return the index of the given element in the list, or -1 if the element is not found.

subList:

List<String> strings = new ArrayList<>(List.of("0", "1", "2", "3", "4", "5"));
System.out.println(strings);
strings.subList(2, 5).clear();
System.out.println(strings);

addAll(int index, Collection collection)

ListIterator

The ListIterator interface extends the regular Iterator that you already know. It adds several methods to it.

  • hasPrevious() and previous(): to iterate in the descending order rather than the ascending order
  • nextIndex() and previousIndex(): to get the index of the element that will be returned by the next next() call, or the next previous() call
  • set(element): to update the last element returned by next() or previous(). If neither of these methods have been called on this iterator then an IllegalStateException is raised.
List<String> numbers = Arrays.asList("one", "two", "three");
for (ListIterator<String> iterator = numbers.listIterator(); iterator.hasNext();) {
    String nextElement = iterator.next();
    if (Objects.equals(nextElement, "two")) {
        iterator.set("2");
    }
}
System.out.println("numbers = " + numbers);

Set

The Set interface does not bring any new method to the Collection interface. The Collections Framework gives you one plain implementation of the Set interface: HashSet. Internally, a HashSet wraps an instance of HashMap.

List<String> strings = List.of("one", "two", "three", "four", "five", "six");
Set<String> set = new HashSet<>();
set.addAll(strings);
set.forEach(System.out::println);

The SortedSet interface adds new methods to Set.

  • first() and last() returns the lowest and the largest elements of the set
  • headSet(toElement) and tailSet(fromElement) returns you subsets containing the elements lower than toElement or greater than fromElement
  • subSet(fromElement, toElement) gives you a subset of the element between fromElement and toElement.
SortedSet<String> strings = new TreeSet<>(Set.of("a", "b", "c", "d", "e", "f"));
SortedSet<String> subSet = strings.subSet("aa", "d");
System.out.println("sub set = " + subSet);

注意,subSet仅仅相当于视图。No copy is made, meaning that any change you make to these subsets will be reflected in the set, and the other way round.

NavigableSet

Some methods are overloaded by NavigableSet.

  • headSet()headSet(), and headSet() may take a further boolean arguments to specify whether the limits (toElement or fromElement) are to be included in the resulting subset.

Other methods have been added.

  • ceiling(element), and floor(element) return the greatest element lesser or equal than, or the lowest element greater or equal than the provided element. If there is no such element then null is returned
  • floor(element), and higher(element) return the greater element lesser than, or the lowest element greater than the provided element. If there is no such element then null is returned.
  • pollFirst(), and pollLast() return and removes the lowest or the greatest element of the set.

Furthermore, NavigableSet also allows you to iterate over its elements in descending order. There are two ways to do this.

  • You can call descendingIterator(): it gives you a regular Iterator that traverses the set in the descending order.
  • You can also call descendingSet(). What you get in return is another NavigableSet that is a view on this set and that makes you think you have the same set, sorted in the reversed order.
NavigableSet<String> sortedStrings = new TreeSet<>(Set.of("a", "b", "c", "d", "e", "f"));
System.out.println("sorted strings = " + sortedStrings);
NavigableSet<String> reversedStrings = sortedStrings.descendingSet();
System.out.println("reversed strings = " + reversedStrings);

Factory Methods

Java SE 9

List<String> stringList = List.of("one", "two", "three");
Set<String> stringSet = Set.of("one", "two", "three");

Java SE 10

Collection<String> strings = Arrays.asList("one", "two", "three");

List<String> list = List.copyOf(strings);
Set<String> set = Set.copyOf(strings);

Arrays

The Collections Framework has a class called Arrays with about 200 methods to handle arrays. Most of them are implementing various algorithms on arrays, like sorting, merging, searching.

Collections

The Collections Framework comes with another factory class: Collections, with a set of method to manipulate collections and their content.

Finding a Sublist in a List

Two methods locate a given sublist in a bigger list:

  • indexOfSublist(List<?> source, List<?> target): returns the first index of the first element of the target list in the source list, or -1 if it does not exist;
  • lastIndexOfSublist(List<?> source, List<?> target): return the last of these indexes.

Changing the Order of the Elements of a List

  • sort() sorts the list in place. This method may take a comparator as an argument. As usual, if no comparator is provided, then the elements of the list must be comparable. If a comparator is provided, then it will be used to compare the elements. Starting with Java SE 8, you should favor the sort() method from the Listinterface.
  • shuffle() randomly shuffles the elements of the provided list. You can provide yout instance of Random if you need a random shuffling that you can repeat.
  • rotate() rotates the elements of the list. After a rotation the element at index 0 will be found at index 1 and so on. The last elements will be moved to the first place of the list. You can combine subList() and rotate() to remove an element at a given index and to insert it in another place in the list.
  • reverse(): reverse the order of the elements of the list.
  • swap(): swaps two elements from the list. This method can take a list as an argument, as well as a plain array.

Stacks and Queues

Stacks are also called LIFO stacks, where LIFO stands for Last In, First Out. Queues are known as FIFO: First In First Out.

These structures are very simple and gives you three main operations.

  • push(element): adds an element to the queue, or the stack
  • pop(): removes an element from the stack, that is, the youngest element added
  • poll(): removes an element from the queue, that is, the oldest element added
  • peek(): allows you to see the element you will get with a pop() or a poll(), but without removing it from the queue of the stack.

Queues and Stacks

  • the Queue interface models a queue;
  • the Deque interface models a double ended queue (thus the name). You can push, pop, poll and peek elements on both the tail and the head of a Deque, making it both a queue and a stack.

Collection没有Stack接口,栈是通过Deque来定义的。

Implementing Queue and Deque

  • ArrayDeque: which implements both. This implementation is backed by an array. The capacity of this class automatically grows as elements are added. So this implementation always accepts new elements.
  • LinkedList: which also implements both. This implementation is backed by a linked list, making the access to its first and last element very efficient. A LinkedList will always accept new elements.
  • PriorityQueue: that only implements Queue. This queue is backed by an array that keeps its elements sorted by their natural order or by an order specified by a Comparator. The head of this queue is always the least element of the queue with respect to the specified ordering. The capacity of this class automatically grows as elements are added.

Maps

implementations:

  • HashMap

  • LinkedHashMap is a HashMap with an internal structure to keep the key-value pairs ordered. Iterating on the keys or the key-value pairs will follow the order in which you have added your key-value pairs.

    这里注意,HashMap是无序的,LinkedHashMap是有序的。

  • IdentityHashMap is a specialized Map that you should only be used in very precise cases. This implementation is not meant to be generally used in application. Instead of using equals() and hashCode() to compare the key objects, this implementation only compares the references to these keys, with an equality operator (==). Use it with caution, only if you are sure this is what you need.

Java SE 9

Map<Integer, String> map = 
    Map.of(
        1, "one", 
        2, "two",
        3, "three"
    );

The Map defines a member interface: Map.Entry to model a key-value pair. This interface defines three methods to access the key and the values:

  • getKey(): to read the key;
  • getValue() and setValue(value): to read and update the value bound to that key.

putIfAbsent(),如果是null,会替换为默认值:

for (String key : map.keySet()) {
    map.putIfAbsent(key, -1);
}

如果value是null,可能会报错,比如:

Map<String, Integer> map = new HashMap<>();

map.put("one", 1);
map.put("two", null);
map.put("three", 3);
map.put("four", null);
map.put("five", 5);

for (int value : map.values()) {  // 这里是int
    System.out.println("value = " + value);  // Integer拆包为int时会报NPE
}

getOrDefault(),如果没有key,返回默认值:

Map<Integer, String> map = new HashMap<>();

map.put(1, "one");
map.put(2, "two");
map.put(3, "three");

List<String> values = new ArrayList<>();
for (int i = 0; i < 5; i++) {
    values.add(map.getOrDefault(key,"UNDEFINED"));
}

System.out.println("values = " + values);

流式写法:

List<String> values =
    IntStream.range(0, 5)
        .mapToObj(key -> map.getOrDefault(key, "UNDEFINED"))
        .collect(Collectors.toList());

System.out.println("values = " + values);

remove(key),remove后返回value,可能为null。

remove(key, value),remove时先判断value存在才移除,返回boolean,true if the key/value pair was removed from the map。

containsKey(key) and containsValue(value) Both methods return true if the map contains the given key or value.

putAll(otherMap) If some keys are present in both maps, then the values of otherMap will erase those of this map.(并集)

  • keySet(): returns an instance of Set, containing the keys defined in the map
  • entrySet(): returns an instance of Set<Map.Entry>, containing the key/value pairs contained in the map
  • values(): returns an instance of Collection, containing the values present in the map.

遍历推荐使用以下方式:

for (Map.Entry<Integer, String> entry : map.entrySet()) {
    System.out.println("entry = " + entry);
}

Lambda Expressions

Map<Integer, String> map = new HashMap<>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");

map.forEach((key, value) -> System.out.println(key + " :: " + value));
Map<Integer, String> map = new HashMap<>();

map.put(1, "one");
map.put(2, "two");
map.put(3, "three");

map.replaceAll((key, value) -> value.toUpperCase());
map.forEach((key, value) -> System.out.println(key + " :: " + value));

compute

The put() methods return the previous value, whereas the compute() methods return the new value.

List<String> strings = List.of("one", "two", "three", "four", "five", "six", "seven");
Map<Integer, List<String>> map = new HashMap<>();
for (String word: strings) {
    int length = word.length();
    if (!map.containsKey(length)) {
        map.put(length, new ArrayList<>());
    }
    map.get(length).add(word);
}

map.forEach((key, value) -> System.out.println(key + " :: " + value));

使用putIfAbsent优化:

for (String word: strings) {
    int length = word.length();
    map.putIfAbsent(length, new ArrayList<>());
    map.get(length).add(word);
}

使用computeIfAbsent优化:

for (String word: strings) {
    int length = word.length();
    map.computeIfAbsent(length, key -> new ArrayList<>())
       .add(word);
}

merge

List<String> strings = List.of("one", "two", "three", "four", "five", "six", "seven");
Map<Integer, String> map = new HashMap<>();
for (String word: strings) {
    int length = word.length();
    map.merge(length, word, 
              (existingValue, newWord) -> existingValue + ", " + newWord);
}

map.forEach((key, value) -> System.out.println(key + " :: " + value));

SortedMap and NavigableMap

SortedMap<Integer, String> map = new TreeMap<>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
map.put(5, "five");
map.put(6, "six");

SortedMap<Integer, String> headMap = map.headMap(3);
headMap.put(0, "zero"); // this line is ok
headMap.put(4, "four"); // this line throws an IllegalArgumentException

Here is the code of the add(element) of the HashSet class:

private transient HashMap<E,Object> map;
private static final Object PRESENT = new Object();

public boolean add(E e) {
    return map.put(e, PRESENT)==null;
}

What you can see is that in fact, a hashset stores your object in a hashmap (the transient keyword is not relevant). Your objects are the keys of this hashmap, and the value is just a placeholder, an object with no significance.

hashset 是用hashmap来存的,所以最好不要更新hashset的值(也就是hashmap的key),否则会有意想不到的Bug。

参考资料:

The Collections Framework https://dev.java/learn/api/collections-framework/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/709134.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

chatgpt赋能python:用Python做中文词云

用Python做中文词云 介绍 中文词云是一种常见的数据可视化方式&#xff0c;通过将文本中出现频率较高的关键词以图形的形式展现出来&#xff0c;让人一眼就能了解文本内容的主题和关键词。在搜索引擎优化&#xff08;SEO&#xff09;方面&#xff0c;中文词云也常被用来帮助分…

【python】使用Antlr4实现识别sql中的表或视图名

前言 先上成果预览图吧 作为一个数据库sql开发者,肯定有很多人和我一样,想要有一个工具,能传入任意sql,解析出sql中的所有表。 我之前有一篇文章【AIO】将任意查询sql转换成带远程数据库DBLINK的sql 中就提到了,使用纯文本硬解析会存在很多不确定因素,比如oracle新版本…

截取屏幕中指定区域的图像pyautogui.screenshot(区域)

【小白从小学Python、C、Java】 【等级考试500强双证书考研】 【Python-数据分析】 截取屏幕中指定区域的图像 pyautogui.screenshot(区域) [太阳]选择题 关于以下代码说法错误的是&#xff1a; import pyautogui print("【执行】pyautogui.screenshot(region(0,0,2…

麦语言入门~001课

麦语言是一种编程语言&#xff0c;它是由麦肯锡公司开发的一种专门用于数据分析和统计建模的语言。麦语言具有类似于R和Python的功能&#xff0c;并提供了一组丰富的数据处理、统计分析和机器学习的工具。麦语言主要用于解决复杂的商业和统计分析问题&#xff0c;并被广泛应用于…

CRM系统能帮助外贸企业提高哪些工作效率?

外贸企业的业务和客户遍布世界各地&#xff0c;更涉及不同的语言和文化。因此&#xff0c;管理客户信息、提高服务质量、扩大市场份额成为了外贸企业亟待解决的问题。针对这些情况&#xff0c;不少企业开始使用CRM客户管理系统。下面说说&#xff0c;外贸企业为什么要用CRM系统…

Spring面试题--Spring的bean的生命周期

这个问题比较困难&#xff0c;设计到了spring的底层&#xff0c;但是通过这个的学习&#xff0c;可以帮助我们了解Spring容器是如何管理和创建bean实例&#xff0c;以及方便调试和解决问题。 BeanDefinition bean的定义信息&#xff0c;Spring容器在进行实例化时&#xff0c;…

11-C++算法01-枚举排序

&#x1f4d6; C算法 在编程中&#xff0c;算法是解决问题的一系列步骤或规则。在C中&#xff0c;提供了丰富的算法库&#xff0c;可以方便地进行各种常见的算法操作。本篇学习笔记将介绍一些常见的排序算法&#xff0c;帮助你理解和应用这些算法。 &#x1f680; 枚举 &…

C语言VS Code 开发环境搭建

文章目录 官方文档安装拓展生成c_cpp_properties.json生成tasks.json生成launch.json测试Debug如何让程序debug完不退出&#xff1f;Windows版本的配置GDB和LLDB的区别 由于之前使用VS Code较少&#xff0c;缺少在VS Code上开发C程序的经验。本篇博文主要记录使用VS Code开发C程…

基于Tars高并发IM系统的设计与实现-基础篇2

基于Tars高并发IM系统的设计与实现-基础篇2 三大指标 高可用 分为服务高可用与存储高可用。 服务高可用 服务高可用要做到高可用必须具备两个特点&#xff1a; 负载均衡可横行扩展 当服务的请求量比较高的时候&#xff0c;一台服务不能满足需求&#xff0c;这时候需要多…

sklearn.preprocessing模块介绍

数据预处理 Binarizer: 二值化 用于将数值特征二值化。它将特征值与给定的阈值进行比较&#xff0c;并将特征值转换为布尔值&#xff08;0 或 1&#xff09;&#xff0c;取决于特征值是否超过阈值 Binarizer(*, threshold0.0, copyTrue)参数&#xff1a; threshold&#xf…

AGI—从GPT和大型语言模型中汲取的经验教训

点击蓝字 关注我们 关注并星标 从此不迷路 计算机视觉研究院 公众号ID&#xff5c;计算机视觉研究院 学习群&#xff5c;扫码在主页获取加入方式 论文地址&#xff1a;https://arxiv.org/pdf/2306.08641.pdf 计算机视觉研究院专栏 Column of Computer Vision Institute 人工智能…

【计算机视觉 | 图像分类】arxiv 计算机视觉关于图像分类的学术速递(6月 29 日论文合集)

文章目录 一、分类|识别相关(12篇)1.1 Pseudo-Bag Mixup Augmentation for Multiple Instance Learning Based Whole Slide Image Classification1.2 Improving Primate Sounds Classification using Binary Presorting for Deep Learning1.3 Challenges of Zero-Shot Recognit…

万物分割SAM家族 越发壮大!HQ-SAM、FastSAM 和 FasterSAM(MobileSAM)

卧剿&#xff0c;6万字&#xff01;30个方向130篇&#xff01;CVPR 2023 最全 AIGC 论文&#xff01;一口气读完。 1、&#xff08;更高质量&#xff09;Segment Anything in High Quality 最近的 Segment Anything Model (SAM) 代表了分割模型的一大飞跃&#xff0c;有强大的零…

从零实现深度学习框架——Seq2Seq机器翻译实战

引言 本着“凡我不能创造的&#xff0c;我就不能理解”的思想&#xff0c;本系列文章会基于纯Python以及NumPy从零创建自己的深度学习框架&#xff0c;该框架类似PyTorch能实现自动求导。 &#x1f4a1;系列文章完整目录&#xff1a; &#x1f449;点此&#x1f448; 要深入理解…

【你哥电力电子】 THE BUCK-BOOST 升降压斩波电路2

BUCK-BOOST电路2 2023年1月30日 nige in Tongji University #elecEngeneer 上链 文章目录 BUCK-BOOST电路26. CCM非理想能量守恒平均分析6.1 CCM非理想大信号平均模型6.2 CCM等效大信号平均模型6.3 CCM的DC电路模型6.4 CCM的小信号线性电路模型6.5 CCM非理想小信号传递函数6.…

【SaaS】多租户系统设计

文章目录 多租户系统设计一、SaaS 的系统分级二、应用程序必须支持多租户三、数据隔离方案3.1、独立应用独立库3.2、同一个应用程序&#xff0c;每个租户一个库3.3、同一个应用程序&#xff0c;同一个数据库3.4、分片多租户 四、我们的模型选择4.1、开发实践4.2、元数据/配置驱…

vue路由传参+案例(使用mock模拟后端数据)

路由传参 跳转路由时&#xff0c;可以给路由对应的组件内传参 声明式导航 /path?参数名值 /path/值 —需要路由对象提前配置 path: ‘/path/:参数名’ 对应的页面组件接收传递过来的值 $route.query.参数名 $route.params.参数名 router/index.js import Vue from vue // 1. …

解析matlab的audioread()输入输出参数

目录 一、API简介 二、实验 1. matlab 2. C语言 一、API简介 链接如下&#xff1a; 读取音频文件 - MATLAB audioread- MathWorks 中国 也可以浏览最新的英文版API说明&#xff1a; 简单说明如下&#xff1a; 1. 读取wav格式的文件&#xff0c;会自动跳过44个字节的文件…

初识React/JSX/组件/state/受控组件

JSX 推荐使用小括号包裹jsx 使用函数创建组件 使用类创建组件 抽离组件 事件绑定 事件对象 有状态和无状态组件/state 抽离事件处理程序 表单元素 受控组件 多表单优化 非受控组件(了解即可)

vhost-net-原理-初始化流程-数据传输流程-vhost-net后端

文章目录 1.vhost net2.vhost-net的初始化流程vhost net设置vhost dev设置vhost vring设置 3.数据收发流程分析3.1 数据发送3.2 数据接收 4ioventfd和irqfd的通知机制4.1ioeventfdqemu侧kvm侧总体效果 4.2irqfdqemu侧kvm侧总体效果 参考&#xff1a; 1.vhost net 传统的virtio…