// constructing sets
#include <iostream>
#include <set>
#include <string.h> bool fncomp (int lhs, int rhs) {return lhs<rhs;} struct classcomp {
bool operator() (const int& lhs, const int& rhs) const
{return lhs<rhs;}
}; int main ()
{
std::set<int> first; // empty set of ints int myints[]= {,,,,};
std::set<int> second (myints,myints+); // range std::set<int> third (second); // a copy of second std::set<int> fourth (second.begin(), second.end()); // iterator ctor. std::set<int,classcomp> fifth(second.begin(), second.end()); // class as Compare std::set<int>::reverse_iterator rit;
for (rit=fifth.rbegin(); rit != fifth.rend(); ++rit)
std::cout << ' ' << *rit; //bool(*fn_pt)(int,int) = fncomp;
//std::set<int,bool(*)(int,int)> sixth (fn_pt); // function pointer as Compare //std::cout<<strcmp("abc", "ab")<<std::endl; return ;
}

c++ class as sort function的更多相关文章

  1. .sort(function(a,b){return a-b});

    var points = [40,100,1,5,25,10]; var b= points.sort(function(a,b){return a-b}); console.log(b); 那个fu ...

  2. [Javascript] Use a custom sort function on an Array in Javascript

    Sorting in Javascript with sort uses lexical sorting by default, which means it will sort in alphabe ...

  3. Interview Sort Function

    QuickSort Java Code: import java.util.*; public class quickSort{ public static void main(String [] a ...

  4. Sort Colors

    Given an array with n objects colored red, white or blue, sort them so that objects of the same colo ...

  5. [LeetCode] Sort Colors 颜色排序

    Given an array with n objects colored red, white or blue, sort them so that objects of the same colo ...

  6. Leetcode 75. Sort Colors

    Given an array with n objects colored red, white or blue, sort them so that objects of the same colo ...

  7. sort()基础知识总结+超简短的英文名排序写法

    结合前些天学的箭头函数我想到一种非常简短的sort排序写法:(这可能是最短的英文名排序方法了) 贴出来大家一起探讨一下: [4,1,2,32].sort((x,y)=>x>y); //[1 ...

  8. js数组的sort排序详解

    <body> <div> sort()对数组排序,不开辟新的内存,对原有数组元素进行调换 </div> <div id="showBox" ...

  9. javascript学习笔记之array.sort

    arrayName.sort()方法: 功能是实现排序(按ascii编码或按数字大小),可无参或有参使用,无参时默认升序排列.有参时可实现升序或降序排列,参数必须是具有返回值的方法,当方法表达式大于0 ...

随机推荐

  1. 类型系统(type system)是一门编程语言最核心也是最基础的部分---编程语言最终的目标,本质上无非是回答两个问题:如何表示信息、如何处理信息

    https://www.cnblogs.com/feng9exe/p/9712059.html 类型系统(type system)是一门编程语言最核心也是最基础的部分.无论该语言基于何种编程范式,都必 ...

  2. ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(四) 添加表情、群聊功能

    休息了两天,还是决定把这个尾巴给收了.本篇是最后一篇,也算是草草收尾吧.今天要加上表情功能和群聊.基本上就差不多了,其他功能,读者可以自行扩展或者优化.至于我写的代码方面,自己也没去重构.好的,我们开 ...

  3. Spring Boot 配置文件详解:Properties和YAML

    一.配置文件的生效顺序,会对值进行覆盖: 1. @TestPropertySource 注解 2. 命令行参数 3. Java系统属性(System.getProperties()) 4. 操作系统环 ...

  4. Android学习笔记_18_Activity生命周期 及 跳转方式

    一.Activity有三个状态: 1.当它在屏幕前台时(位于当前任务堆栈的顶部),它是激活或运行状态.它就是响应用户操作的Activity. 2. 当它上面有另外一个Activity,使它失去了焦点但 ...

  5. webapi是如何绑定参数的(How WebAPI does Parameter Binding)

    原文地址 由于工作原因,要使用ASP.NET WEBAPI(非mvc webapi),前几天时间一直很紧张,所以webapi一直将就用,今天下午好不容易有时间终于看了下,解决了自己一直疑惑的问题,在此 ...

  6. c# 开发可替换的通用序列化库

    开篇继续吹牛.... 其实没有什么可吹的了,哈哈哈哈哈 主要是写一个通用库,既可以直接用,又方便替换,我的序列化都是采用第三方的哈. 我不上完整代码了,只是给大家讲讲过程. 1.写一个序列化的类,我是 ...

  7. Javascript的加载

    最新博客站点:欢迎来访 1. 浏览器加载     (1) 同步加载 在网页中,浏览器加载js文件的方式是通过<script>标签.如下所示: //内嵌脚本 <script type= ...

  8. CF1042C Array Product(贪心,模拟)

    题目描述 You are given an array aa consisting of nn integers. You can perform the following operations w ...

  9. 转载:Spring使用p名称空间配置属性

    这篇博客简明扼要地介绍了Spring中p命名空间的使用,笔者在此转载一下. 原文链接:https://blog.csdn.net/liaomin416100569/article/details/49 ...

  10. 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2

    ◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...