这里记录下堆的相关操作。
op 1:
'''
@ data: the heap array
@ p : index of parent item
@ n : number of data
@@ Swap p and it's son items, make p the largest of them
'''
def swapForMaxHeap(data, n, p):
l...
分类:
其他好文 时间:
2014-07-13 17:07:15
阅读次数:
223
1 #include 2 #include 3 #include 4 using namespace std; 5 6 void swap(int *a, int *b){ 7 int tmp; 8 tmp = *a; 9 *a = *b;10 *b = tmp;...
分类:
其他好文 时间:
2014-07-13 13:11:27
阅读次数:
190
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-07-12 20:39:17
阅读次数:
225
1.配置环境说明 spark:5台zybo板,192.168.1.1master,其它4台为slave hadoop:192.168.1.1(外接SanDisk ) 2.单节点hadoop测试: 如果出现内存不足情况如下: 查看当前虚拟内存容量: free -m cd /mnt mkdir swap...
分类:
其他好文 时间:
2014-07-11 11:38:44
阅读次数:
407
可能有童鞋不知道PerfMon插件是干啥的,这里简要说一下:
在做负载测试时,我们要时刻关注服务器的CPU,MEM……的使用情况,但是JMeter本身对这些信息是不做收集的,这个时候PerfMon就应运而生了。没错,他就是用来收集被压服务器的各种性能指标,例如: CPU, Memory, Swap, Disks I/O and Networks I/O ……
进入正题:
环境...
分类:
其他好文 时间:
2014-07-10 21:09:11
阅读次数:
327
经验:当std::swap对你的类型效率不高时,提供一个swap成员函数,并确定这个函数不抛出异常
示例:
stl里的swap算法
namespace std{
template
void swap(T &a, T &b){
T temp(a);
a = b;
b = temp;
}
}
//“pimpl手法”(pointer to implementation) --> 文件间的编译依存度
class WidgetImpl{
public:
//...
pr...
分类:
编程语言 时间:
2014-07-10 19:35:50
阅读次数:
240
C++函数模版与类模版。template void SwapFunction(T &first, T &second){}//函数模版template //类模版class CTemplate{public: void SWap(T &first, T &second){ }};#include.....
分类:
编程语言 时间:
2014-07-09 16:50:30
阅读次数:
210
[LeetCode]Swap Nodes in Pairs...
分类:
其他好文 时间:
2014-07-08 20:40:15
阅读次数:
161
题目
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant spac...
分类:
其他好文 时间:
2014-07-08 13:46:26
阅读次数:
205
近期在使用阿里和腾讯的云服务器,由于只是测试用所以只租用了廉价512的内存,在编译gcc时遇到错误,表面上看只是编译错误,并且原因不明,纠结了几次之后猜测应该是由于系统资源不足导致的,所以尝试增加系统的swap分区,这里需要检查两个地方一、修改swappiness1.查看你的系统里面的swappin...
分类:
其他好文 时间:
2014-07-05 22:34:24
阅读次数:
396