当前位置: 首页 > 编程日记 > 正文

【C++】C++11 STL算法(三):分隔操作(Partitioning operations)、排序操作(Sorting operations)

目录

  • 分隔操作(Partitioning operations)
        • 一、is_partitioned
          • 1、原型:
          • 2、说明:
          • 3、官网demo
        • 二、partition
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 三、partition_copy
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 四、stable_partition
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 五、partition_point
          • 1、原型;
          • 2、说明:
          • 3、官方demo
  • 排序操作(Sorting operations)
        • 一、is_sorted
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二、is_sorted_until
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 三、sort
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 四、partial_sort
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 五、partial_sort_copy
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 六、stable_sort
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 七、nth_element
          • 1、原型:
          • 2、说明:
          • 3、官方demo

分隔操作(Partitioning operations)

将容器中指定范围内的元素根据特定条件分成两组
头文件:#include <algorithm>

一、is_partitioned

1、原型:
template< class InputIt, class UnaryPredicate >
bool is_partitioned( InputIt first, InputIt last, UnaryPredicate p );
2、说明:

测试是否已经分割好

3、官网demo
#include <algorithm>
#include <array>
#include <iostream>int main()
{std::array<int, 9> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };auto is_even = [](int i){ return i % 2 == 0; };std::cout.setf(std::ios_base::boolalpha);std::cout << std::is_partitioned(v.begin(), v.end(), is_even) << ' ';std::partition(v.begin(), v.end(), is_even);std::cout << std::is_partitioned(v.begin(), v.end(), is_even) << ' ';std::reverse(v.begin(), v.end());std::cout << std::is_partitioned(v.begin(), v.end(), is_even);
}

Output:

false true false

二、partition

1、原型:
template< class ForwardIt, class UnaryPredicate >
ForwardIt partition( ForwardIt first, ForwardIt last, UnaryPredicate p );
2、说明:

将元素分成两组

3、官方demo

快速排序

#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
#include <forward_list>template <class ForwardIt>void quicksort(ForwardIt first, ForwardIt last){if(first == last) return;auto pivot = *std::next(first, std::distance(first,last)/2);ForwardIt middle1 = std::partition(first, last, [pivot](const auto& em){ return em < pivot; });ForwardIt middle2 = std::partition(middle1, last, [pivot](const auto& em){ return !(pivot < em); });quicksort(first, middle1);quicksort(middle2, last);}int main()
{std::vector<int> v = {0,1,2,3,4,5,6,7,8,9};std::cout << "Original vector:\n    ";for(int elem : v) std::cout << elem << ' ';auto it = std::partition(v.begin(), v.end(), [](int i){return i % 2 == 0;});std::cout << "\nPartitioned vector:\n    ";std::copy(std::begin(v), it, std::ostream_iterator<int>(std::cout, " "));std::cout << " * ";std::copy(it, std::end(v), std::ostream_iterator<int>(std::cout, " "));std::forward_list<int> fl = {1, 30, -4, 3, 5, -4, 1, 6, -8, 2, -5, 64, 1, 92};std::cout << "\nUnsorted list:\n    ";for(int n : fl) std::cout << n << ' ';std::cout << '\n';  quicksort(std::begin(fl), std::end(fl));std::cout << "Sorted using quicksort:\n    ";for(int fi : fl) std::cout << fi << ' ';std::cout << '\n';
}

Output:

Original vector:0 1 2 3 4 5 6 7 8 9 
Partitioned vector:0 8 2 6 4  *  5 3 7 1 9 
Unsorted list:1 30 -4 3 5 -4 1 6 -8 2 -5 64 1 92 
Sorted using quicksort:-8 -5 -4 -4 1 1 1 2 3 5 6 30 64 92

三、partition_copy

1、原型:
template< class InputIt, class OutputIt1, class OutputIt2, class UnaryPredicate >
std::pair<OutputIt1, OutputIt2>partition_copy( InputIt first, InputIt last,OutputIt1 d_first_true, OutputIt2 d_first_false,UnaryPredicate p );
2、说明:

将指定范围内的元素安特定条件分成两组,分别复制到d_first_true、d_first_false中。

3、官方demo
#include <iostream>
#include <algorithm>
#include <utility>int main()
{int arr [10] = {1,2,3,4,5,6,7,8,9,10};int true_arr [5] = {0};int false_arr [5] = {0};std::partition_copy(std::begin(arr), std::end(arr), std::begin(true_arr),std::begin(false_arr),[] (int i) {return i > 5;});std::cout << "true_arr: ";for (int x : true_arr) {std::cout << x << ' ';}std::cout << '\n'; std::cout << "false_arr: ";for (int x : false_arr) {std::cout << x << ' ';}std::cout << '\n'; return 0;}

Output:

true_arr: 6 7 8 9 10
false_arr: 1 2 3 4 5

四、stable_partition

1、原型:
template< class BidirIt, class UnaryPredicate >
BidirIt stable_partition( BidirIt first, BidirIt last, UnaryPredicate p );
2、说明:

将元素分为两组,同时保持它们的相对顺序

3、官方demo
#include <iostream>
#include <algorithm>
#include <vector>int main()
{std::vector<int> v{0, 0, 3, 0, 2, 4, 5, 0, 7};std::stable_partition(v.begin(), v.end(), [](int n){return n>0;});for (int n : v) {std::cout << n << ' ';}std::cout << '\n';
}

Output:

3 2 4 5 7 0 0 0 0

五、partition_point

1、原型;
template< class ForwardIt, class UnaryPredicate >
ForwardIt partition_point( ForwardIt first, ForwardIt last, UnaryPredicate p );
2、说明:

返回已经分隔好的分割点的位置(迭代器)

3、官方demo
#include <algorithm>
#include <array>
#include <iostream>
#include <iterator>int main()
{std::array<int, 9> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };auto is_even = [](int i){ return i % 2 == 0; };std::partition(v.begin(), v.end(), is_even);auto p = std::partition_point(v.begin(), v.end(), is_even);std::cout << "Before partition:\n    ";std::copy(v.begin(), p, std::ostream_iterator<int>(std::cout, " "));std::cout << "\nAfter partition:\n    ";std::copy(p, v.end(), std::ostream_iterator<int>(std::cout, " "));
}

Output:
Before partition:
8 2 6 4
After partition:
5 3 7 1 9

排序操作(Sorting operations)

一、is_sorted

1、原型:
template< class ForwardIt >
bool is_sorted( ForwardIt first, ForwardIt last );template< class ForwardIt, class Compare >
bool is_sorted( ForwardIt first, ForwardIt last, Compare comp );
2、说明:

判断指定范围内的元素是否按照升序排列

3、官方demo
#include <iostream>
#include <algorithm>
#include <iterator>
int main() 
{int digits[] = {3, 1, 4, 1, 5};for (auto i : digits) std::cout << i << ' ';std::cout << ": is_sorted: " << std::boolalpha<< std::is_sorted(std::begin(digits), std::end(digits)) << '\n';std::sort(std::begin(digits), std::end(digits));for (auto i : digits) std::cout << i << ' ';std::cout << ": is_sorted: "<< std::is_sorted(std::begin(digits), std::end(digits)) << '\n';
}

Output:
3 1 4 1 5 : is_sorted: false
1 1 3 4 5 : is_sorted: true

二、is_sorted_until

1、原型:
template< class ForwardIt >
ForwardIt is_sorted_until( ForwardIt first, ForwardIt last );template< class ForwardIt, class Compare >
ForwardIt is_sorted_until( ForwardIt first, ForwardIt last, Compare comp );
2、说明:

从first找到已经排序的位置(迭代器)

3、官方demo
#include <iostream>
#include <algorithm>
#include <iterator>
#include <random>int main()
{std::random_device rd;std::mt19937 g(rd());const int N = 6;int nums[N] = {3, 1, 4, 1, 5, 9};const int min_sorted_size = 4;int sorted_size = 0;do {std::shuffle(nums, nums + N, g);int *sorted_end = std::is_sorted_until(nums, nums + N);sorted_size = std::distance(nums, sorted_end);for (auto i : nums) std::cout << i << ' ';std::cout << " : " << sorted_size << " initial sorted elements\n";} while (sorted_size < min_sorted_size);
}

Possible output:

4 1 9 5 1 3  : 1 initial sorted elements
4 5 9 3 1 1  : 3 initial sorted elements
9 3 1 4 5 1  : 1 initial sorted elements
1 3 5 4 1 9  : 3 initial sorted elements
5 9 1 1 3 4  : 2 initial sorted elements
4 9 1 5 1 3  : 2 initial sorted elements
1 1 4 9 5 3  : 4 initial sorted elements

三、sort

1、原型:
template< class RandomIt >
void sort( RandomIt first, RandomIt last );template< class RandomIt, class Compare >
void sort( RandomIt first, RandomIt last, Compare comp );
2、说明:

升序排列
注意:
相等元素的顺序不能保证被保留。

3、官方demo
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>int main()
{std::array<int, 10> s = {5, 7, 4, 2, 8, 6, 1, 9, 0, 3}; // 使用默认操作符排序std::sort(s.begin(), s.end());for (auto a : s) {std::cout << a << " ";}   std::cout << '\n';// 使用标准库比较函数对象排序std::sort(s.begin(), s.end(), std::greater<int>());for (auto a : s) {std::cout << a << " ";}   std::cout << '\n';// 使用自定义函数对象排序struct {bool operator()(int a, int b) const{   return a < b;}   } customLess;std::sort(s.begin(), s.end(), customLess);for (auto a : s) {std::cout << a << " ";}   std::cout << '\n';// 使用lambda表达式排序 std::sort(s.begin(), s.end(), [](int a, int b) {return a > b;   });for (auto a : s) {std::cout << a << " ";} std::cout << '\n';
}

Output:

0 1 2 3 4 5 6 7 8 9 
9 8 7 6 5 4 3 2 1 0 
0 1 2 3 4 5 6 7 8 9 
9 8 7 6 5 4 3 2 1 0

四、partial_sort

1、原型:
template< class RandomIt >
void partial_sort( RandomIt first, RandomIt middle, RandomIt last );template< class RandomIt, class Compare >
void partial_sort( RandomIt first, RandomIt middle, RandomIt last, Compare comp );
2、说明:

在[first, last)范围内找到前middle-first个最小的元素并排序。后面的元素不保证顺序。
注意:
相等元素的顺序不能保证被保留。

3、官方demo
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>int main()
{std::array<int, 10> s{5, 7, 4, 2, 8, 6, 1, 9, 0, 3};std::partial_sort(s.begin(), s.begin() + 3, s.end());for (int a : s) {std::cout << a << " ";} 
}

Possible output:

0 1 2 7 8 6 5 9 4 3

五、partial_sort_copy

1、原型:
template< class InputIt, class RandomIt >
RandomIt partial_sort_copy( InputIt first, InputIt last,RandomIt d_first, RandomIt d_last );template< class InputIt, class RandomIt, class Compare >
RandomIt partial_sort_copy( InputIt first, InputIt last,RandomIt d_first, RandomIt d_last,Compare comp );
2、说明:

将最多d_last-d_first个元素排列处理。保存到d_first开始的范围内

3、官方demo
#include <algorithm>
#include <vector>
#include <functional>
#include <iostream>int main()
{std::vector<int> v0{4, 2, 5, 1, 3};std::vector<int> v1{10, 11, 12};std::vector<int> v2{10, 11, 12, 13, 14, 15, 16};std::vector<int>::iterator it;it = std::partial_sort_copy(v0.begin(), v0.end(), v1.begin(), v1.end());std::cout << "Writing to the smaller vector in ascending order gives: ";for (int a : v1) {std::cout << a << " ";}std::cout << '\n';if(it == v1.end())std::cout << "The return value is the end iterator\n";it = std::partial_sort_copy(v0.begin(), v0.end(), v2.begin(), v2.end(), std::greater<int>());std::cout << "Writing to the larger vector in descending order gives: ";for (int a : v2) {std::cout << a << " ";}std::cout << '\n' << "The return value is the iterator to " << *it << '\n';
}

Output:

Writing to the smaller vector in ascending order gives: 1 2 3
The return value is the end iterator
Writing to the larger vector in descending order gives: 5 4 3 2 1 15 16
The return value is the iterator to 15

六、stable_sort

1、原型:
template< class RandomIt >
void stable_sort( RandomIt first, RandomIt last );template< class RandomIt, class Compare >
void stable_sort( RandomIt first, RandomIt last, Compare comp );
2、说明:

升序排列,同时保存相等的元素按原来顺序排列。

3、官方demo
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>struct Employee
{int age;std::string name;  // Does not participate in comparisons
};bool operator<(const Employee & lhs, const Employee & rhs)
{return lhs.age < rhs.age;
}int main()
{std::vector<Employee> v ={ {108, "Zaphod"},{32, "Arthur"},{108, "Ford"},};  std::stable_sort(v.begin(), v.end());for (const Employee & e : v)std::cout << e.age << ", " << e.name << '\n';
}

Output:

32, Arthur
108, Zaphod
108, Ford

七、nth_element

1、原型:
template< class RandomIt >
void nth_element( RandomIt first, RandomIt nth, RandomIt last );template< class RandomIt, class Compare >
void nth_element( RandomIt first, RandomIt nth, RandomIt last,Compare comp );
2、说明:

nth之前的元素全都小于nth之后的元素,但是这两部分没有排序

3、官方demo
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>int main()
{std::vector<int> v{5, 6, 4, 3, 2, 6, 7, 9, 3};std::nth_element(v.begin(), v.begin() + v.size()/2, v.end());for (auto a : v) {std::cout << a << " ";}   std::cout << "The median is " << v[v.size()/2] << '\n';std::nth_element(v.begin(), v.begin()+1, v.end(), std::greater<int>());std::cout << "The second largest element is " << v[1] << '\n';
}

Output:

The median is 5
The second largest element is 7

相关文章:

浪潮发布重磅产品“元脑”,专注AI全栈能力输出

整理 | 一一出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;4月16日&#xff0c;以“智慧凝聚”为题的IPF2019浪潮云数据中心合作伙伴大会在上海举办。大会重点聚焦浪潮“智慧计算”战略&#xff0c;以AI计算力和创新力&#xff0c;联接、承载、赋能合作伙伴。为了布…

React+Redux+中间件

MVVM是Model-View-ViewModel的缩写。mvvm是一种设计思想。Model 层代表数据模型&#xff0c;也可以在Model中定义数据修改和操作的业务逻辑&#xff1b;View 代表UI 组件&#xff0c;它负责将数据模型转化成UI 展现出来&#xff0c;ViewModel 是一个同步View 和 Model的对象。在…

ピエタ~幸せの青い鳥~相关

先打全所有升级补丁 不然没有end4 补丁下载页 4个end出现方法 只看律视角 选项任意→end1 只看愛视角 选项任意→end2 检查一下 这两个流程的CG是否收全了 开启唯视角以后有些CG是找不回的 只看唯视角 选项任意→end3 只看唯视角 最后一个选项选“唯” 此后只要律或愛的视角开…

【C++】C++11 STL算法(四):二分查找法(Binary search operations)、合并操作

目录一、lower_bound1、原型&#xff1a;2、说明&#xff1a;3、官方demo二、upper_bound1、原型&#xff1a;2、说明&#xff1a;3、官方demo三、binary_search1、原型&#xff1a;2、说明&#xff1a;3、官方demo四、equal_range1、原型&#xff1a;2、说明&#xff1a;3、官…

腾讯开源分布式NoSQL存储系统DCache | 技术头条

作者 | 山宝银&#xff0c;腾讯后台高级工程师&#xff0c;专注于分布式 NoSQL 存储领域的技术研发工作&#xff0c;参与腾讯多个自研存储系统的开发&#xff0c;在分布式系统、高可用与高性能服务等领域有较丰富的经验。来源 | 腾讯技术博客当你在电商平台秒杀商品或者在社交网…

老司机带你学爬虫——Python爬虫技术分享

什么是“爬虫”&#xff1f; 简单来说&#xff0c;写一个从web上获取需要数据并按规定格式存储的程序就叫爬虫&#xff1b; 爬虫理论上步骤很简单&#xff0c;第一步获取html源码&#xff0c;第二步分析html并拿到数据。但实际操作&#xff0c;老麻烦了~ 用Python写“爬虫”有哪…

[转载]分享WCF聊天程序--WCFChat

http://www.cnblogs.com/gaoweipeng/archive/2009/09/04/1560260.html 无意中在一个国外的站点下到了一个利用WCF实现聊天的程序&#xff0c;作者是&#xff1a;Nikola Paljetak。研究了一下&#xff0c;自己做了测试和部分修改&#xff0c;感觉还不错&#xff0c;分享给大家。…

【C++】C++11 STL算法(五):设置操作(Set operations)、堆操作(Heap operations)

目录设置操作(Set operations)一、includes1、原型&#xff1a;2、说明&#xff1a;3、官方demo二、set_difference1、原型&#xff1a;2、说明&#xff1a;3、官方demo三、set_intersection1、原型&#xff1a;2、说明&#xff1a;3、官方demo四、set_symmetric_difference1、…

63万张!旷视发布最大物体检测数据集Objects365 | 技术头条

编辑 | 琥珀来源 | AI科技大本营&#xff08;id&#xff1a;rgznai100&#xff09;昨日&#xff0c;在旷视科技联合北京智源人工智能研究院举办的发布会上&#xff0c;旷视研究院发布了物体检测数据集 Objects365&#xff0c;包含 63 万张图像数量&#xff0c;365 个类别数量&a…

(一)Android Studio 安装部署 华丽躲坑

叨叨两句先 小宇之前一直做前后端开发&#xff0c;只是略懂JS&#xff0c;未接触过Java和Android 近期工作任务也是兴趣使然&#xff0c;开始琢磨DJI二次开发 DJI是我最服气的无人机厂商&#xff0c;无人机稳定性极强&#xff0c;性价比狂高&#xff0c;还给了极度丰富的二次开…

linux 环境配置 安装jdk

一. 下载jdk5.0 for linux 到sun的主页 http://java.sun.com/j2se/1.5.0/download.jsp 下载jdk安装文件jdk-1_5_0_05-linux-i586.bin 二. 解压安装jdk 在shell终端下进入jdk-1_5_0_05-linux-i586.bin文件所在目录&#xff0c;执行命令 ./jdk-1_5_0_05-linux-i586.bin 这时会出现…

【C++】C++11 STL算法(六):最小/最大操作(Minimum/maximum operations)、比较运算(Comparison operations)

目录最小/最大操作(Minimum/maximum operations)一、max1、原型&#xff1a;2、说明&#xff1a;3、官方demo二、max_element1、原型&#xff1a;2、说明&#xff1a;3、官方demo三、min1、原型&#xff1a;2、说明&#xff1a;3、官方demo四、min_element1、原型&#xff1a;2…

springboot之定时任务

定时线程 说到定时任务&#xff0c;通常会想到JDK自带的定时线程来执行&#xff0c;定时任务。 回顾一下定时线程池。 public static ScheduledExecutorService newScheduledThreadPool(int var0) {return new ScheduledThreadPoolExecutor(var0);}public static ScheduledExec…

10只机器狗拉卡车!井然有序,毫不费力 | 极客头条

整理 | 琥珀出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;看来&#xff0c;这家娱乐网友多年的机器人公司终于要开始实现商用化了&#xff01;最先备受期待的是它的网红机器狗 SpotMini。今日凌晨&#xff0c;据多家外媒报道&#xff0c;波士顿动力 (Boston Dynami…

linux下查看nginx,apache,mysql,php的编译参数

有时候nginx&#xff0c;apache&#xff0c;mysql&#xff0c;php编译完了想看看编译参数可以用以下方法 nginx编译参数&#xff1a; #/usr/local/nginx/sbin/nginx -V nginx version: nginx/0.6.32 built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42) configure arguments: --us…

【C++】C++11 STL算法(七):排列操作(Permutation operations)、数值操作(Numeric operations)

排列操作&#xff08;Permutation operations&#xff09; 一、is_permutation 1、原型&#xff1a; template< class ForwardIt1, class ForwardIt2 > bool is_permutation( ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2 );template< class ForwardIt…

码书:入门中文NLP必备干货:5分钟看懂“结巴”分词(Jieba)

导读&#xff1a;近年来&#xff0c;随着NLP技术的日益成熟&#xff0c;开源实现的分词工具越来越多&#xff0c;如Ansj、盘古分词等。在本文中&#xff0c;我们选取了Jieba进行介绍和案例展示&#xff0c;主要基于以下考虑&#xff1a;社区活跃。截止本文发布前&#xff0c;Ji…

《你必须掌握的Entity Framework 6.x与Core 2.0》正式出版感想

前言 借书正式出版之际&#xff0c;完整回顾下从写博客到写书整个历程&#xff0c;也算是对自己近三年在技术上的一个总结&#xff0c;整个历程可通过三个万万没想到来概括&#xff0c;请耐心阅读。 写博、写书完整历程回顾 从2013年12月注册博客园账号&#xff0c;注册博客园账…

JSF实现“Hello World!”

我们编写一个在页面上显示是“Hello World! ”&#xff0c;我们至少需要编写一个Page对象和一个对应模板文件&#xff08;tml&#xff09;。 第一步&#xff0c;Page对象编写 在Tapestry5中Page是与一个页面对应的POJO对象&#xff0c;它不需要继承Tapestry框架的任何基类或实现…

《权力的游戏》最终季上线!谁是你最喜爱的演员?这里有一份Python教程 | 附源码...

译者 | 刘畅编辑 | 琥珀出品 | AI科技大本营&#xff08;id&#xff1a;rgznai100&#xff09;《权力的游戏》最终季已于近日开播&#xff0c;对于全世界翘首以待的粉丝们来说&#xff0c;其最大的魅力就在于“无法预知的人物命运”。那些在魔幻时代的洪流中不断沉浮的人们&…

【C++】C++11 STL算法(八):对未初始化内存的操作(Operations on uninitialized memory)、C库(C library)

对未初始化内存的操作&#xff08;Operations on uninitialized memory&#xff09; 一、uninitialized_copy 1、原型&#xff1a; template< class InputIt, class ForwardIt > ForwardIt uninitialized_copy( InputIt first, InputIt last, ForwardIt d_first );2、…

OSPF高级设置实现全网互通

OSPF(开放式最短路径优先)是对链路状态路由协议的一种实现&#xff0c;隶属内部网关协议&#xff08;IGP&#xff09;&#xff0c;故运作于自治系统内部(AS)。采用戴克斯特拉算法&#xff08;Dijkstras algorithm&#xff09;被用来计算最短路径树。“Cost”作为路由度量值。链…

学习PHP ?

学PHP的决定真的是好的吗&#xff1f; 不怕又再错一次了吗&#xff1f; 已经是最后的一年半上学时间了.... 真的不愿再走之前那条失败的路&#xff0c;不愿&#xff0c;真的不愿&#xff1b; 这年半无论如何都要把一样技术搞精了 一年半的时间&#xff0c;对我来讲够了....只看…

【数据库】sqlite中的限制:数据库大小、表数、列数、行数、参数个数、连接数等

目录一、参考网址二、详解1、查看、设置sqlite限制命令.limit2、SQLite中的限制汇总1&#xff09;字符串或BLOB的最大长度2&#xff09;最大列数3&#xff09;SQL语句的最大长度4&#xff09;联接中的最大表数5&#xff09;表达式树的最大深度6&#xff09;函数的最大参数个数7…

flutter中的生命周期

前言 和其他的视图框架比如android的Activity一样&#xff0c;flutter中的视图Widget也存在生命周期&#xff0c;生命周期的回调函数提现在了State上面。理解flutter的生命周期&#xff0c;对我们写出一个合理的控件至关重要。组件State的生命周期整理如下图所示&#xff1a; 大…

小鱼易连获腾讯数亿C轮投资,云视频布局产业互联网

4 月 18 日&#xff0c;小鱼易连在北京举行 “鱼腾视界 产业互联” 战略合作暨融资发布会上&#xff0c;正式宣布获得 C 轮融资&#xff0c;由腾讯领投。融得的资金将全面用于小鱼易连云视频系统在产业互联网领域的落地&#xff0c;打通企业、政府、个人三者之间的柔性生态全产…

异步IO一定更好吗?

http://cnodejs.org/blog/?p1015续&#xff1a;异步IO一定更好吗&#xff1f;我之前的一篇文章《异步IO一定更好吗&#xff1f;》中举了一个很变态的例子&#xff0c;用以说明在单碟机械式硬盘上异步IO反而可能降低性能的问题&#xff0c;大家的讨论很热烈。前天的NodeParty杭…

谈谈Python那些不为人知的冷知识(二)

本文转载自Python的编程时光&#xff08;ID:Python-Time&#xff09;小明在日常Code中遇到一些好玩&#xff0c;冷门的事情&#xff0c;通常都会记录下来。从上一篇的分享来看&#xff0c;仍然有不少 Pythoner 对这些冷知识存在盲区&#xff0c;所以今天迎来第二篇。如果上篇你…

前端每日实战:45# 视频演示如何用纯 CSS 创作一个菱形 loader 动画

效果预览 按下右侧的“点击预览”按钮可以在当前页面预览&#xff0c;点击链接可以全屏预览。 https://codepen.io/comehope/pen/eKzjqK 可交互视频教程 此视频是可以交互的&#xff0c;你可以随时暂停视频&#xff0c;编辑视频中的代码。 请用 chrome, safari, edge 打开观看。…

【数据库】SQLite和MySQL之间的对比和选择

目录1、各自特定2、使用场景3、选择哪个1、各自特定 SQLite &#xff1a;独立、简单&#xff08;零配置&#xff09;&#xff1b;适用于为单个应用程序和设备提供本地数据存储。 MySQL&#xff1a;可伸缩、高并发性&#xff1b;适用于客户端/服务器模式企业数据的共享数据存储…