2014年5月27日

C++单例模式

摘要: 单例模式是一种常用的软件设计模式。在它的核心结构中只包含一个被称为单例类的特殊类。通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问,从而方便对实例个数的控制并节约系统资源。如果希望在系统中某个类的对象只能存在一个,单例模式是最好的解决方案。#include#include#i... 阅读全文

posted @ 2014-05-27 16:22 berkeleysong 阅读(173) 评论(0) 推荐(0)

MapReduce的模式、算法和用例

摘要: 在这篇文章里总结了几种网上或者论文中常见的MapReduce模式和算法,并系统化的解释了这些技术的不同之处。所有描述性的文字和代码都使用了标准hadoop的MapReduce模型,包括Mappers, Reduces, Combiners, Partitioners,和 sorting。如下图所示。... 阅读全文

posted @ 2014-05-27 13:28 berkeleysong 阅读(369) 评论(0) 推荐(0)

leetcode -- 3sum

摘要: Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文

posted @ 2014-05-27 13:13 berkeleysong 阅读(188) 评论(0) 推荐(0)

重点算法--合并排序

摘要: #includeusing namespace std; void merge(int left,int mid,int right,int a[],int b[]){ int i = 0; int cursor1 = left; int cursor2 = mid +1; while(cu... 阅读全文

posted @ 2014-05-27 11:40 berkeleysong 阅读(213) 评论(0) 推荐(0)

重点算法--快速排序

摘要: #includeusing namespace std;////写出快速排序,归并排序与堆排序int adjustarray(int a[],int left,int right){ int x = a[left]; while(left x && left < right) righ... 阅读全文

posted @ 2014-05-27 10:24 berkeleysong 阅读(166) 评论(0) 推荐(0)

导航