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

【C++】C++11 STL算法(二):修改序列的操作(Modifying sequence operations)

目录

        • 一、copy、copy_if
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二、copy_n
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 三、copy_backward
          • 1、原型:
          • 1、说明:
          • 1、官方demo
        • 四、move
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 五、move_backward
          • 1、源码:
          • 2、说明:
          • 3、官方demo
        • 六、fill
          • 1、原型:
          • 2、说明:
          • 1、官方demo
        • 七、fill_n
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 八、transform
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 九、generate
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十、generate_n
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十一、remove、remove_if
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十二、remove_copy、remove_copy_if
          • 1、原型;
          • 2、说明:
          • 3、官方demo
        • 十三、replace、replace_if
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十四、replace_copy、replace_copy_if
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十五、swap
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十六、swap_ranges
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十七、iter_swap
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十八、reverse
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 十九、reverse_copy
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十、rotate
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十一、rotate_copy
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十二、shuffle、random_shuffle(已弃用)
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十三、unique
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十四、unique_copy
          • 1、原型:
          • 2、说明:
          • 3、官方demo
        • 二十五、shift_left、shift_right (C++20)
        • 二十六sample (C++17)

头文件:#include <algorithm>

一、copy、copy_if

1、原型:
template< class InputIt, class OutputIt >
OutputIt copy( InputIt first, InputIt last, OutputIt d_first );template< class InputIt, class OutputIt, class UnaryPredicate >
OutputIt copy_if( InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred );
2、说明:

将[first, last)复制到d_first指向的位置,d_first不能在[first, last)范围内。

3、官方demo
#include <algorithm>
#include <iostream>
#include <vector>
#include <iterator>
#include <numeric>int main()
{std::vector<int> from_vector(10);std::iota(from_vector.begin(), from_vector.end(), 0);	// std::iota 用顺序递增的值赋值指定范围内的元素。std::vector<int> to_vector;// std::back_inserter函数:配合copy函数,把[a, b)区间的数据插入到string对象的末尾,如果容量不够,动态扩容std::copy(from_vector.begin(), from_vector.end(), std::back_inserter(to_vector));
// or, alternatively,
//  std::vector<int> to_vector(from_vector.size());
//  std::copy(from_vector.begin(), from_vector.end(), to_vector.begin());
// either way is equivalent to
//  std::vector<int> to_vector = from_vector;std::cout << "to_vector contains: ";std::copy(to_vector.begin(), to_vector.end(),std::ostream_iterator<int>(std::cout, " "));std::cout << '\n';
}

Output:

to_vector contains: 0 1 2 3 4 5 6 7 8 9

二、copy_n

1、原型:
template< class InputIt, class Size, class OutputIt >
OutputIt copy_n( InputIt first, Size count, OutputIt result );
2、说明:

将first开始的count个数据复制到result中。

3、官方demo
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>int main()
{std::string in = "1234567890";std::string out;// std::back_inserter函数:配合copy函数,把[a, b)区间的数据插入到string对象的末尾,如果容量不够,动态扩容std::copy_n(in.begin(), 4, std::back_inserter(out));std::cout << out << '\n';
}

Output:

1234

三、copy_backward

1、原型:
template< class BidirIt1, class BidirIt2 >
BidirIt2 copy_backward( BidirIt1 first, BidirIt1 last, BidirIt2 d_last );
1、说明:

将[first, last)以相反的顺序复制(最后一个元素首先复制)到d_last结尾的新地址中,但保留它们的相对顺序。

1、官方demo
#include <algorithm>
#include <iostream>
#include <vector>int main()
{std::vector<int> from_vector;for (int i = 0; i < 10; i++) {from_vector.push_back(i);}std::vector<int> to_vector(15);std::copy_backward(from_vector.begin(), from_vector.end(), to_vector.end());std::cout << "to_vector contains: ";for (auto i: to_vector) {std::cout << i << " ";}}

Output:
to_vector contains: 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9

四、move

1、原型:
template< class InputIt, class OutputIt >
OutputIt move( InputIt first, InputIt last, OutputIt d_first );
2、说明:

将[first, last)移动到d_first开始的新空间内。

3、官方demo

将线程对象(它们本身不可复制)从一个容器移动到另一个容器。

#include <iostream>
#include <vector>
#include <list>
#include <iterator>
#include <thread>
#include <chrono>void f(int n)
{std::this_thread::sleep_for(std::chrono::seconds(n));std::cout << "thread " << n << " ended" << '\n';
}int main() 
{std::vector<std::thread> v;v.emplace_back(f, 1);v.emplace_back(f, 2);v.emplace_back(f, 3);std::list<std::thread> l;// copy() would not compile, because std::thread is noncopyablestd::move(v.begin(), v.end(), std::back_inserter(l)); for (auto& t : l) t.join();
}

Output:

thread 1 ended
thread 2 ended
thread 3 ended

五、move_backward

1、源码:
template< class BidirIt1, class BidirIt2 >
BidirIt2 move_backward( BidirIt1 first, BidirIt1 last, BidirIt2 d_last );
2、说明:

将[first, last)以相反的顺序移动(最后一个元素首先移动)到d_last结尾的新地址中,但保留它们的相对顺序。

3、官方demo
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>int main()
{std::vector<std::string> src{"foo", "bar", "baz"};std::vector<std::string> dest(src.size());std::cout << "src: ";for (const auto &s : src) {std::cout << s << ' ';}   std::cout << "\ndest: ";for (const auto &s : dest) {std::cout << s << ' ';}   std::cout << '\n';std::move_backward(src.begin(), src.end(), dest.end());std::cout << "src: ";                                                       for (const auto &s : src) {std::cout << s << ' ';}   std::cout << "\ndest: ";for (const auto &s : dest) {std::cout << s << ' ';}   std::cout << '\n';
}

Output:

src: foo bar baz 
dest:    
src:    
dest: foo bar baz

六、fill

1、原型:
template< class ForwardIt, class T >
void fill( ForwardIt first, ForwardIt last, const T& value );
2、说明:

将value复制到[first, last)的每一个元素中

1、官方demo
#include <algorithm>
#include <vector>
#include <iostream>int main()
{std::vector<int> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};std::fill(v.begin(), v.end(), -1);for (auto elem : v) {std::cout << elem << " ";}std::cout << "\n";
}

Output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1

七、fill_n

1、原型:
template< class OutputIt, class Size, class T >
OutputIt fill_n( OutputIt first, Size count, const T& value );
2、说明:

将value复制到first开始的count个元素中。

3、官方demo
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>int main()
{std::vector<int> v1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};std::fill_n(v1.begin(), 5, -1);std::copy(begin(v1), end(v1), std::ostream_iterator<int>(std::cout, " "));std::cout << "\n";
}

Output:

-1 -1 -1 -1 -1 5 6 7 8 9

八、transform

1、原型:
template< class InputIt, class OutputIt, class UnaryOperation >
OutputIt transform( InputIt first1, InputIt last1, OutputIt d_first, UnaryOperation unary_op );
2、说明:

将unary_op函数作用到[first, last)中每一个元素,并将结果保存在d_first开始的目标区域

3、官方demo
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>int main()
{std::string s("hello");std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c) -> unsigned char { return std::toupper(c); });std::vector<std::size_t> ordinals;std::transform(s.begin(), s.end(), std::back_inserter(ordinals),[](unsigned char c) -> std::size_t { return c; });std::cout << s << ':';for (auto ord : ordinals) {std::cout << ' ' << ord;}
}

Output:

HELLO: 72 69 76 76 79

九、generate

1、原型:
template< class ForwardIt, class Generator >
void generate( ForwardIt first, ForwardIt last, Generator g );
2、说明:

为[first, last)范围内的每个元素分配由给定功能对象g生成的值。

3、官方demo
#include <algorithm>
#include <iostream>
#include <vector>int f()
{ static int i = 1;return i++;
}int main()
{std::vector<int> v(5);std::generate(v.begin(), v.end(), f);std::cout << "v: ";for (auto iv: v) {std::cout << iv << " ";}std::cout << "\n";// Initialize with default values 0,1,2,3,4 from a lambda function Equivalent to std::iota(v.begin(), v.end(), 0);std::generate(v.begin(), v.end(), [n = 0] () mutable { return n++; });std::cout << "v: ";for (auto iv: v) {std::cout << iv << " ";}std::cout << "\n";
}

Output:

v: 1 2 3 4 5
v: 0 1 2 3 4

十、generate_n

1、原型:
template< class OutputIt, class Size, class Generator >
OutputIt generate_n( OutputIt first, Size count, Generator g );
2、说明:

为first开始count个元素分配由给定功能对象g生成的值。

3、官方demo
#include <random>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>int main()
{std::mt19937 rng; // std::mt19937是一种随机数算法,用法与rand()函数类似;默认构建,种子为固定种子// std::ref 用于包装按引用传递的值std::generate_n(std::ostream_iterator<std::mt19937::result_type>(std::cout, " "), 5, std::ref(rng));std::cout << '\n';
}

Output:

3499211612 581869302 3890346734 3586334585 545404204

十一、remove、remove_if

1、原型:
template< class ForwardIt, class T >
ForwardIt remove( ForwardIt first, ForwardIt last, const T& value );template< class ForwardIt, class UnaryPredicate >
ForwardIt remove_if( ForwardIt first, ForwardIt last, UnaryPredicate p );
2、说明:

删除满足特定条件的元素,删除是通过移动完成的,remove调用后指向新末端,然后再调用容器的erase删除新末端到原来末端的元素。
注意:
不能在std::set、std::map中使用。

3、官方demo
#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>int main()
{std::string str1 = "Text with some   spaces";str1.erase(std::remove(str1.begin(), str1.end(), ' '),str1.end());std::cout << str1 << '\n';std::string str2 = "Text\n with\tsome \t  whitespaces\n\n";str2.erase(std::remove_if(str2.begin(), str2.end(),[](unsigned char x){return std::isspace(x);}),str2.end());std::cout << str2 << '\n';
}

Output:

Textwithsomespaces
Textwithsomewhitespaces

十二、remove_copy、remove_copy_if

1、原型;
template< class InputIt, class OutputIt, class T >
OutputIt remove_copy( InputIt first, InputIt last, OutputIt d_first, const T& value );template< class InputIt, class OutputIt, class UnaryPredicate >
OutputIt remove_copy_if( InputIt first, InputIt last, OutputIt d_first, UnaryPredicate p );
2、说明:

将[first, last)范围内的元素复制到d_first开始的位置,并忽略满足条件的元素

3、官方demo
#include <algorithm>
#include <iterator>
#include <string>
#include <iostream>
int main()
{std::string str = "Text with some   spaces";std::cout << "before: " << str << "\n";std::cout << "after:  ";std::remove_copy(str.begin(), str.end(),std::ostream_iterator<char>(std::cout), ' ');std::cout << '\n';
}

Output:

before: Text with some   spaces
after:  Textwithsomespaces

十三、replace、replace_if

1、原型:
template< class ForwardIt, class T >
void replace( ForwardIt first, ForwardIt last, const T& old_value, const T& new_value );template< class ForwardIt, class UnaryPredicate, class T >
void replace_if( ForwardIt first, ForwardIt last, UnaryPredicate p, const T& new_value );
2、说明:

将满足特定条件的所有值替换为另一个值。

3、官方demo
#include <algorithm>
#include <array>
#include <iostream>
#include <functional>int main()
{std::array<int, 10> s{5, 7, 4, 2, 8, 6, 1, 9, 0, 3};std::replace(s.begin(), s.end(), 8, 88);for (int a : s) {std::cout << a << " ";}std::cout << '\n';std::replace_if(s.begin(), s.end(), std::bind(std::less<int>(), std::placeholders::_1, 5), 55);	// 将小于5的值替换成55for (int a : s) {std::cout << a << " ";}std::cout << '\n';
}

Output:

5 7 4 2 88 6 1 9 0 3
5 7 55 55 88 6 55 9 55 55

十四、replace_copy、replace_copy_if

1、原型:
template< class InputIt, class OutputIt, class T >
OutputIt replace_copy( InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value );template< class InputIt, class OutputIt, class UnaryPredicate, class T >
OutputIt replace_copy_if( InputIt first, InputIt last, OutputIt d_first, UnaryPredicate p, const T& new_value );
2、说明:

将[first, last)范围内满足条件的值替换成新值new_value,并复制到d_first开始的范围内。

3、官方demo
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
#include <functional>int main()
{std::vector<int> v{5, 7, 4, 2, 8, 6, 1, 9, 0, 3};std::replace_copy_if(v.begin(), v.end(),std::ostream_iterator<int>(std::cout, " "),[](int n){return n > 5;}, 99);std::cout << '\n';
}

Output:

5 99 4 2 99 99 1 99 0 3

十五、swap

1、原型:
template< class T >
void swap( T& a, T& b ) noexcept;
2、说明:

交换存储在两个对象中的值。
注意:从c++11开始头文件为<utility>

3、官方demo
#include <algorithm>
#include <iostream>int main()
{int a = 5, b = 3;// beforestd::cout << a << ' ' << b << '\n';std::swap(a,b);// afterstd::cout << a << ' ' << b << '\n';
}

Output:

5 3
3 5

十六、swap_ranges

1、原型:
template< class ForwardIt1, class ForwardIt2 >
ForwardIt2 swap_ranges( ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2 );
2、说明:

将[first1,last1)范围内的元素和first2开始的范围内的元素做交换。

3、官方demo
#include <algorithm>
#include <list>
#include <vector>
#include <iostream>
int main()
{std::vector<int> v = {1, 2, 3, 4, 5};std::list<int> l = {-1, -2, -3, -4, -5};std::swap_ranges(v.begin(), v.begin()+3, l.begin());for(int n : v)std::cout << n << ' ';std::cout << '\n';for(int n : l)std::cout << n << ' ';std::cout << '\n';
}

Output:

-1 -2 -3 4 5
1 2 3 -4 -5

十七、iter_swap

1、原型:
template< class ForwardIt1, class ForwardIt2 >
void iter_swap( ForwardIt1 a, ForwardIt2 b );
2、说明:

交换两个迭代器指向的元素

3、官方demo
// 选择排序
#include <random>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>template<class ForwardIt>
void selection_sort(ForwardIt begin, ForwardIt end)
{for (ForwardIt i = begin; i != end; ++i)std::iter_swap(i, std::min_element(i, end));
}int main()
{std::random_device rd;std::mt19937 gen(rd());std::uniform_int_distribution<> dist(-10, 10);std::vector<int> v;generate_n(back_inserter(v), 20, bind(dist, gen));std::cout << "Before sort: ";for(auto e : v) std::cout << e << " ";selection_sort(v.begin(), v.end());std::cout << "\nAfter sort: ";for(auto e : v) std::cout << e << " ";std::cout << '\n';
}

Output:

Before sort: -7 6 2 4 -1 6 -9 -1 2 -5 10 -9 -5 -3 -5 -3 6 6 1 8
After sort: -9 -9 -7 -5 -5 -5 -3 -3 -1 -1 1 2 2 4 6 6 6 6 8 10

十八、reverse

1、原型:
template< class BidirIt >
void reverse( BidirIt first, BidirIt last );
2、说明:

将[first, last)范围内元素的顺序反转。

3、官方demo
#include <vector>
#include <iostream>
#include <iterator>
#include <algorithm>int main()
{std::vector<int> v{1,2,3};std::reverse(std::begin(v), std::end(v));for(auto e : v) std::cout << e;std::cout << '\n';int a[] = {4, 5, 6, 7};std::reverse(std::begin(a), std::end(a));for(auto e : a) std::cout << e;
}

Output:

321
7654

十九、reverse_copy

1、原型:
template< class BidirIt, class OutputIt >
OutputIt reverse_copy( BidirIt first, BidirIt last, OutputIt d_first );
2、说明:

将[first, last)范围内元素的顺序反转,并复制到d_first开始的范围内。

3、官方demo
#include <vector>
#include <iostream>
#include <algorithm>int main()
{std::vector<int> v({1,2,3});for (const auto& value : v) {std::cout << value << " ";}std::cout << '\n';std::vector<int> destination(3);std::reverse_copy(std::begin(v), std::end(v), std::begin(destination));for (const auto& value : destination) {std::cout << value << " ";}std::cout << '\n';
}

Output:

1 2 3 
3 2 1

二十、rotate

1、原型:
template< class ForwardIt >
ForwardIt rotate( ForwardIt first, ForwardIt n_first, ForwardIt last );
2、说明:

循环移动,将[first, n_first)+[n_first, last),变成[n_first, last)+[first, n_first);

3、官方demo
#include <vector>
#include <iostream>
#include <algorithm>int main()
{std::vector<int> v{2, 4, 2, 0, 5, 10, 7, 3, 7, 1}; std::cout << "before sort:      ";for (int n: v)std::cout << n << ' ';std::cout << '\n';// 插入排序for (auto i = v.begin(); i != v.end(); ++i) {std::rotate(std::upper_bound(v.begin(), i, *i), i, i+1);}std::cout << "after sort:       ";for (int n: v)std::cout << n << ' ';std::cout << '\n';// simple rotation to the leftstd::rotate(v.begin(), v.begin() + 1, v.end());std::cout << "simple rotate left  : ";for (int n: v)std::cout << n << ' ';std::cout << '\n';// simple rotation to the rightstd::rotate(v.rbegin(), v.rbegin() + 1, v.rend());std::cout << "simple rotate right : ";for (int n: v)std::cout << n << ' ';std::cout << '\n';}

Output:

before sort:      2 4 2 0 5 10 7 3 7 1 
after sort:       0 1 2 2 3 4 5 7 7 10 
simple rotate left : 1 2 2 3 4 5 7 7 10 0
simple rotate right: 0 1 2 2 3 4 5 7 7 10

二十一、rotate_copy

1、原型:
template< class ForwardIt, class OutputIt >
OutputIt rotate_copy( ForwardIt first, ForwardIt n_first, ForwardIt last, OutputIt d_first );
2、说明:

循环移动后复制到d_first开始的范围内,将[first, n_first)+[n_first, last),变成[n_first, last)+[first, n_first);

3、官方demo
#include <algorithm>
#include <vector>
#include <iostream>int main()
{std::vector<int> src = {1, 2, 3, 4, 5}; auto pivot = std::find(src.begin(), src.end(), 3); std::vector<int> dest(src.size());                                          std::rotate_copy(src.begin(), pivot, src.end(), dest.begin());for (const auto &i : dest) {std::cout << i << ' ';}   std::cout << '\n';
}

Output:

3 4 5 1 2

二十二、shuffle、random_shuffle(已弃用)

1、原型:
template< class RandomIt, class URBG >
void shuffle( RandomIt first, RandomIt last, URBG&& g );
2、说明:

对[first,last)范围内的元素随机排序

3、官方demo
#include <random>
#include <algorithm>
#include <iterator>
#include <iostream>int main()
{std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};std::random_device rd;std::mt19937 g(rd());std::shuffle(v.begin(), v.end(), g);std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " "));std::cout << "\n";
}

Possible output:

8 6 10 4 2 3 7 1 9 5

二十三、unique

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

删除指定范围内连续重复的元素。使用时,先排序,再删除重复元素(这里的删除只是将新序列移动到前面),最后使用erase做真正删除动作。

3、官方demo
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>int main() 
{// 删除重复的元素std::vector<int> v{1,2,3,1,2,3,3,4,5,4,5,6,7};std::sort(v.begin(), v.end()); // 1 1 2 2 3 3 3 4 4 5 5 6 7 auto last = std::unique(v.begin(), v.end());// v now holds {1 2 3 4 5 6 7 x x x x x x}, where 'x' is indeterminatev.erase(last, v.end()); for (int i : v)std::cout << i << " ";std::cout << "\n";
}

Output:

1 2 3 4 5 6 7

二十四、unique_copy

1、原型:
template< class InputIt, class OutputIt >
OutputIt unique_copy( InputIt first, InputIt last, OutputIt d_first );template< class InputIt, class OutputIt, class BinaryPredicate >
OutputIt unique_copy( InputIt first, InputIt last, OutputIt d_first, BinaryPredicate p );
2、说明:

将[first,last)范围内,剔除重复项后复制到d_first开始的范围内。

3、官方demo
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>int main()
{std::string s1 = "The      string    with many       spaces!";std::cout << "before: " << s1 << '\n';std::string s2;std::unique_copy(s1.begin(), s1.end(), std::back_inserter(s2),[](char c1, char c2){ return c1 == ' ' && c2 == ' '; });std::cout << "after:  " << s2 << '\n';
}

Output:

before: The      string    with many       spaces!
after:  The string with many spaces!

二十五、shift_left、shift_right (C++20)

这两个算法是C++20以后才有的新算法,暂时不学

二十六sample (C++17)

这个算法是C++17以后才有的新算法,暂时不学

相关文章:

ECharts测量图,功率图

/*** 测量图&#xff0c;功率图1&#xff0c;仪表盘*/ mainpage.prototype.initEcharsGLT1 function(oneJZ){ //if(myChartGLT1 null && myChartGLT1 ! "" && myChartGLT1 ! undefined) {myChartGLT1.dispose(); //每次加载之前清除之前的echar…

北京智源人工智能研究院启动“智源学者计划”,与旷视发布首个智源联合实验室

4月16日&#xff0c;北京智源人工智能研究院与中国人工智能领军企业旷视召开“智源学者计划暨联合实验室发布会”。北京市科委副主任张光连&#xff0c;海淀区委常委、副区长李俊杰&#xff0c;以及来自科技部、北京市科委、海淀区人民政府、朝阳区人民政府、中关村管委会&…

配置隧道模式的IPSec.×××

一、拓扑及IP配置 二、配置清单 R1#show run Building configuration... Current configuration : 1449 bytes ! upgrade fpd auto version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 …

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

目录分隔操作&#xff08;Partitioning operations&#xff09;一、is_partitioned1、原型&#xff1a;2、说明&#xff1a;3、官网demo二、partition1、原型&#xff1a;2、说明&#xff1a;3、官方demo三、partition_copy1、原型&#xff1a;2、说明&#xff1a;3、官方demo四…

浪潮发布重磅产品“元脑”,专注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;打通企业、政府、个人三者之间的柔性生态全产…