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

2023-11-11

目录

分隔操作(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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • 通过增加索引之和来生成排序组合的有效方法

    对于启发式算法 我需要一个接一个地评估特定集合的组合 直到达到停止标准 由于它们很多 目前我正在使用以下内存高效迭代器块生成它们 受到 python 的启发 itertools combinations http docs python o
  • 在 VS2017 下使用 Conan 和 CMake 项目进行依赖管理

    我正在尝试使用 CMake 与 VS2017 集成为 C 设置一个开发环境 以便在 Linux x64 下进行编译 为了更好地管理依赖关系 我选择使用 Conan 但我对这个软件还很陌生 我想知道让 VS2017 识别项目依赖关系的最佳方法
  • 从多线程程序中调用 system()

    我们正在开发一个用 C 编写的多线程内存消耗应用程序 我们必须执行大量的 shellscript linux 命令 并获取返回码 读完之后article http www linuxprogrammingblog com threads a
  • System.IO.IOException:由于意外>数据包格式,握手失败?

    有谁知道这意味着什么 System Net WebException 底层连接已关闭 发送时发生意外错误 gt System IO IOException 由于意外 握手失败 数据包格式 在 System Net Security SslS
  • 在 C# 中生成 HMAC-SHA1

    我正在尝试使用 C 来使用 REST API API 创建者提供了以下用于 hmac 创建的伪代码 var key1 sha1 body var key2 key1 SECRET KEY var key3 sha1 key2 var sig
  • 如何尝试/捕获所有异常

    我正在完成由其他人启动的 UWP 应用程序 该应用程序经常崩溃 我总是陷入困境应用程序 at if global System Diagnostics Debugger IsAttached global System Diagnostic
  • 两种类型的回发事件

    1 我发现了两篇文章 每篇文章对两种类型的回发事件的分类都略有不同 一位资源说两种类型的回发事件是Changed事件 其中控件实现 IPostbackDataHandler 当数据在回发之间更改时触发 然后Raised事件 其中控件实现 I
  • 从 Code::Blocks 运行程序时出现空白控制台窗口 [重复]

    这个问题在这里已经有答案了 当我尝试在 Code Blocks 中构建并运行新程序时 控制台窗口弹出空白 我必须单击退出按钮才能停止它 它对我尝试过的任何新项目 包括 Hello world 都执行此操作 奇怪的是 它对于我拥有的任何旧项目
  • C++ 插件的“最适合”动态类型匹配

    我有一个几乎所有东西都是插件的架构 该架构以图形用户界面为基础 其中每个插件都由一个 表面 即用户可以通过其与插件交互的 UI 控件 表示 这些表面也是插件 每当添加新插件时 瘦主机都会自动确定哪个可用表面与其最匹配的 UI 如何在 C 中
  • 预处理后解析 C++ 源文件

    我正在尝试分析c 使用我定制的解析器的文件 写在c 在开始解析之前 我想摆脱所有 define 我希望源文件在预处理后可以编译 所以最好的方法是运行C Preprocessor在文件上 cpp myfile cpp temp cpp or
  • tabcontrol selectedindex 更改事件未被触发 C#

    嘿伙计们 我有一个很小的问题 请参阅下面的代码 this is main load private void Form1 Load object sender EventArgs e tabAddRemoveOperator Selecte
  • asp.net网格分页的SQL查询

    我在用iBatis and SQLServer 使用偏移量和限制进行分页查询的最佳方法是什么 也许我添加该列ROW NUMBER OVER ORDER BY Id AS RowNum 但这只会阻止简单查询的数据访问 在某些情况下 我使用选择
  • 0-1背包算法

    以下 0 1 背包问题是否可解 浮动 正值和 浮动 权重 可以是正数或负数 背包的 浮动 容量 gt 0 我平均有 这是一个相对简单的二进制程序 我建议用蛮力进行修剪 如果任何时候你超过了允许的重量 你不需要尝试其他物品的组合 你可以丢弃整
  • 从 Delphi 调用 C# dll

    我用单一方法编写了 Net 3 5 dll 由Delphi exe调用 不幸的是它不起作用 步骤 1 使用以下代码创建 C 3 5 dll public class MyDllClass public static int MyDllMet
  • 使用 HTMLAgilityPack 从节点的子节点中选择所有

    我有以下代码用于获取 html 页面 将网址设置为绝对 然后将链接设置为 rel nofollow 并在新窗口 选项卡中打开 我的问题是关于将属性添加到 a s string url http www mysite com string s
  • 如何引用解决方案之外的项目?

    我有一个 Visual Studio C 解决方案 其中包含一些项目 其中一个项目需要引用另一个不属于解决方案的项目 一开始我引用了dll
  • C语言声明数组没有初始大小

    编写一个程序来操纵温度详细信息 如下所示 输入要计算的天数 主功能 输入摄氏度温度 输入功能 将温度从摄氏度转换为华氏度 独立功能 查找华氏度的平均温度 我怎样才能在没有数组初始大小的情况下制作这个程序 include
  • 受限 AppDomain 中的代码访问安全异常

    Goal 我需要在权限非常有限的 AppDomain 中运行一些代码 它不应该访问任何花哨或不安全的内容 except对于我在其他地方定义的一些辅助方法 我做了什么 我正在创建一个具有所需基本权限的沙箱 AppDomain 并创建一个运行代
  • 带有私有设置器的 EFCore Base 实体模型属性 - 迁移奇怪的行为

    实体模型继承的类内的私有设置器似乎会导致 EFCore 迁移出现奇怪的问题 考虑以下示例 其中有多个类 Bar and Baz 继承自Foo 跑步时Add Migration多次命令 添加 删除private修饰符 生成的模式在多个方面都是
  • 服务器响应 PASV 命令返回的地址与建立 FTP 连接的地址不同

    System Net WebException 服务器响应 PASV 命令返回的地址与建立 FTP 连接的地址不同 在 System Net FtpWebRequest CheckError 在 System Net FtpWebReque

随机推荐

  • 简单示例中的多平台Avalonia .NET Framework编程基本概念

    目录 介绍 关于Avalonia 本文的目的 本文的组织 示例代码 解释概念 视觉树 Avalonia 工具 逻辑树 附加属性 样式属性 直接属性 有关附加 样式和直接属性的更多信息 绑定 什么是Avalonia UI和WPF中的绑定以及为
  • 如何在Mac电脑上编译Unity项目至iOS simulator (ipad/iphone)

    如何将Unity项目编译成iOS app 并在虚拟的ipad或者iphone上运行呢 大体步骤分为三步 使用Unity生成 xcodeproj 文件 在Xcode中运行 simulator 通过Xcode编译 xcodeproj 文件 并安
  • Selenium Xpath定位唯一文本元素

    Selenium Xpath定位唯一文本元素 问题概述 现有一网页 已知唯一文本元素a 需要定位父级的同级元素b并抓取文本b text 如何实现 给出案例 tr title td style width 60px class 110084
  • 我想问一下猫狗大战中出现Attempted to use a closed Session.怎么解决

    import os import tensorflow as tf from time import time import VGG16 model as model 自己定义的 import utils 定义了我们所用到的功能函数 fro
  • 2021-07-16(Qt实现图片拖拽功能)

    关于如何使用Qt实现简单的图片拖拽及缩放功能 一 代码实现 二 相关函数的解释 三 代码原理解释 一 代码实现 首先直接放出相关代码 可以根据注释进行一定修改 以下为头文件的内容 ifndef MAINWINDOW H define MAI
  • c#之base和this关键字

    如有错误 欢迎补充
  • ROS主从机设置

    ROS支持多机互通 一台主机启动roscore 启动Master节点 多台从机直接可以运行其他节点 本文记录主从机配置 实现多机互通 查看本机IP地址 ifconfig 其中 enp2s0代表有线网卡 lo代表本地回环 wlp5s0代表无线
  • Sublime Text 3中文乱码问题的解决(最有效)

    Sublime Text 3中文乱码问题的解决 最有效 Sublime Text 3是很好的代码编辑器 没有之一 因为她的性感高亮代码配色 更因为它的小巧 但是它默认不支持GBK的编码格式 因此打开GBK的代码文件 如果里面有中文的话 就会
  • UI控件----ProgressBar进度条 实例总结

    ProgressBar提供了可以向用户展示当前任务的进度 完成效果如下 单击增加 减少进度可以调节进度 完成步骤一 layout的xml文件中activity main xml完成代码
  • LRU的实现

    题目内容 实现一个 LRUCache 类 三个接口 LRUCache int capacity 创建一个大小为 capacity 的缓存 get int key 从缓存中获取键为 key 的键值对的 value put int key in
  • 使用Elasticsearch 出现的拒绝连接

    pom 文件 spring elasticsearch jest uris http 192 168 124 142 9201 data elasticsearch cluster name elasticsearch cluster no
  • 应用向国产架构体系化迁移的三大难点及解决方案

    转载本文需注明出处 微信公众号EAWorld 违者必究 李航 国家信创战略背景下 信创产业从党政 金融等领域高速扩展到电信 制造 教育等更广阔的市场 01 信创工作要解决应用向国产架构体系化迁移的三大难点 保障全面落地 伴随近年来信创实践的
  • pandas.errors.ParserError: Error tokenizing data. C error: Expected 17 fields in line 112, saw 18

    pandas errors ParserError Error tokenizing data C error Expected 17 fields in line 112 saw 18 pandas 简介 pandas 读取csv文件 运
  • 数字化时代,如何从战略设计到架构来打造智慧银行?

    导语 随着人工智能 大数据 云计算等技术向纵深发展 数字化转型已成为银行发展的 必答题 调整战略规划和架构重组 加大信息科技投入 推进科技人才队伍建设 持续推出数字化产品 近年来 深化数字化转型 以科技赋能金融服务已成为不少银行的发力点 今
  • python环境变量配置

    python现在的版本 主要是python2和python3两个大版本 这两个版本有很大的不同 当我们在自己电脑上同时安装了python2 x和python3 x版本的解释器的时候 就需要对环境变量的配置进行一定的修改 大概解释一下 我对环
  • 什么是 前端&后端,始端&末端

    前端 后端 前端和后端是指不同的开发领域和技术 前端指的是用户可见的界面 比如网页 移动应用 游戏等 使用的技术包括HTML CSS JavaScript等 后端指的是用户看不见的部分 比如服务器 数据库 业务逻辑等 使用的技术包括Java
  • 数据结构笔记--图

    数据结构笔记 图 图 本章总结 图的概念 基本术语 抽象数据类型 图的存储结构 邻接矩阵表示法 数组 无向图 有向图 有权图 邻接矩阵的优缺点 代码实现 邻接表表示法 链式 结构 无向图 有向图 邻接表的优缺点 邻接矩阵与邻接表的对比 代码
  • 详解spring的IOC控制反转和DI依赖注入

    转载 详解spring的IOC控制反转和DI依赖注入 2018 06 05 15 45 34 jiuqijack 阅读数 2945 文章标签 spring IOC控制反转 DI依赖注入 更多 分类专栏 spring
  • 关于Android的不同分辨率图片适配

    看了几篇相关的博客 根据自己的实际开发 总结了一下 首先要搞清楚 图片的分辨率单位是像素 也就是px 比如72x72的图片 就是长宽都是72px 手机屏幕的分辨率跟图片类似 但是它还有个很重要的指标 dpi 叫做像素密度 代表1英寸长度的屏
  • 【C++】C++11 STL算法(三):分隔操作(Partitioning operations)、排序操作(Sorting operations)

    目录 分隔操作 Partitioning operations 一 is partitioned 1 原型 2 说明 3 官网demo 二 partition 1 原型 2 说明 3 官方demo 三 partition copy 1 原型