// 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. ACM-ICPC(11/8)

    URAL 1005 给定一些石头的重量,要求分成两个部分最相近.二进制暴力枚举. #include <bits/stdc++.h> using namespace std; ]; int ...

  2. 昨天刚看了Handler和HandlerThread这个东西,不明白为什么要用这么复杂的东西,而且Handler直接post的话好像还不是子线程运行。那我再开发的时候直接用Thread行不行?两个有什么区别?

    Handler就是android中一个机制,主要是考虑到线程安全的! Handler是可以实现线程间通信的,LZ知道Android的UI线程不安全的吧,也就是说不可以在UI线程以外的其他线程对UI进行 ...

  3. POJ 3461 Oulipo 【KMP统计子串数】

    传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  4. ASP.NET Web API 自定义MediaType实现jsonp跨域调用

    代码来自<ASP.NET Web API 2 框架揭秘>一书. 直接上代码: /// <summary> /// 自定义jsonp MediaType /// </sum ...

  5. 【Oracle】三个配置文件tnsnames-listener-sqlnet介绍【转】

    转自:博客园-oracle: listener.ora .sqlnet.ora .tnsnames.ora的配置及例子 介绍三个配置文件 1)listener.ora 2)sqlnet.ora 3)t ...

  6. Angularjs实例2

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  7. Oracle 序列的创建删除插入

    今天学习的是序列的创建蟹盖和删除插入 创建: create Sequence Seq_name increment by n     ----序列变化的程度,默认为1,可以为负数表示递减 start ...

  8. c# 分析SQL语句中的表操作

    最近写了很多方向的总结和demo.基本包含了工作中的很多方面,毕竟c#已经高度封装并且提供了很多类库.前面已经总结了博文.最近2天突然感觉前面的SQL分析阻组件的确麻烦,也注意看了下.为了方便大家学习 ...

  9. jquery mobile 移动web(6)

    jquery mobile 针对移动端设备的事件类型. 1.touch 事件. tap 快速触摸屏幕并且离开,类似一种完整的点击操作. taphold 触摸屏幕并保持一段时间. swipe 在1秒内水 ...

  10. D - 湫湫系列故事——减肥记II

    虽然制定了减肥食谱,但是湫湫显然克制不住吃货的本能,根本没有按照食谱行动! 于是,结果显而易见… 但是没有什么能难倒高智商美女湫湫的,她决定另寻对策——吃没关系,咱吃进去再运动运动消耗掉不就好了? 湫 ...