1.iter_swap
描述:将两个 ForwardIterator 所指的对象对调
源码:
//version 1
template
inline void __iter_swap(ForwardIterator1 a, ForwardIterator2 b, T*) {
T tmp = *a;
*a = *b;
*b = tmp;
}
//version 2
template...
分类:
其他好文 时间:
2014-07-18 21:32:42
阅读次数:
244
Since no order requirement, we can simply swap the target value to the last non-target-value in the array - if the last non-target-value is not behind...
分类:
其他好文 时间:
2014-07-18 17:36:41
阅读次数:
192
第一行所列出的是当前的内存的使用情况
第二行则是swap交换空间的使用情况。
系统中used并不是所有的被使用的内存。因为当Linux将一根文件载入到RAM中,当程序用完这个文件的时候,不需要将它从RAM中移除。如果还有可用的RAM,Linux将会在RAM中缓存这个文件,这样如果一个程序再次访问这个文件,访问速度将会得到大幅度的提升。如果系统的确需要为活动进程提供RAM,那么RAM将不会缓存这...
分类:
其他好文 时间:
2014-07-17 21:11:34
阅读次数:
294
1.如何实现交换两个数的值void swap( int *a,int *b){int tep=*a;//*a其实就是主函数a的值,a是主函数存a数值的地址。*a =*b;*b =tep;}2.如何实现二维数组函数排序void desc( int(* a) [10] ,int i){//这样子就可以再...
分类:
其他好文 时间:
2014-07-16 19:27:27
阅读次数:
166
linux临时增加swap空间:step 1: #dd if=/dev/zero of=/home/swap bs=1024 count=500000 注释:of=/home/swap,放置swap的空间; count的大小就是增加的swap空间的大小,1024就是块大小,这里是1K,所以总共...
分类:
系统相关 时间:
2014-07-16 16:49:57
阅读次数:
255
(1)全排列问题 1 //全排列的两种方法 2 #include 3 using namespace std; 4 5 //方法一,采用swap方法 6 void quanpailie(char * A,int first,int n) 7 { 8 if(A==NULL) 9 {...
分类:
其他好文 时间:
2014-07-16 12:15:27
阅读次数:
224
问题描述题目来源:Topcoder SRM 627 Div2 BubbleSortWithReversals给定待排序数组A,在最多反转K个A的不相交子数组后,对A采用冒泡排序,问最小的swap次数是多少?冒泡排序的伪代码如下:BubbleSort(A): 循环len(A) - 1次: for i ...
分类:
其他好文 时间:
2014-07-14 22:32:28
阅读次数:
576
拷贝控制示例
那么接下来尽情欣赏这个案例吧!!!
/**
* 功能:拷贝控制示例
* 时间:2014年7月14日10:57:39
* 作者:cutter_point
*/
#include
#include
#include
#include
using namespace std;
class Folder;
/**
Message类
*/
class Message
{
fr...
分类:
编程语言 时间:
2014-07-14 17:39:36
阅读次数:
293
交换操作
class HasPtr
{
friend void fun2();
friend void swap(HasPtr&, HasPtr&);
public:
// HasPtr()=default;
HasPtr(const string &s=string()):ps(new string(s)), i(0){}
//对ps指向的stri...
分类:
编程语言 时间:
2014-07-14 17:18:06
阅读次数:
314
目前我开发的一个服务器后台程序存在这么一个问题,由于我的程序要不断的收发消息,并做统计,统计用的是stl的多重map,在统计中会不断的往map里赛数据。但是每次统计后我都会调用clear()去释放内存,但是似乎并不奏效,仍然会有泄漏的现象。查资料,map的clear是将map内容清空,但是内存并不归还给系统,而是缓冲在内存池里以方便下次调用,有人提出,可以新建一个map,将两个map做swap操作...
分类:
其他好文 时间:
2014-07-14 11:15:23
阅读次数:
318