本文译自How to sort NSArray with custom
objects。我们开发的每个程序都会使用到一些数据,而这些数据一般被封装在一个自定义的类中。例如一个音乐程序可能会有一个Song类,聊天程序则又一个Friend类,点菜程序会有一个Recipe类等。有时候我们希望在程序中显示的...
分类:
其他好文 时间:
2014-06-29 15:29:25
阅读次数:
342
public class BubbleSortLib { public int[]
Sort(int[] arr) { for (int outer = arr.Length - 1; outer...
分类:
其他好文 时间:
2014-05-28 03:12:37
阅读次数:
223
STL的堆操作STL里面的堆操作一般用到的只有4个:make_heap();、pop_heap();、push_heap();、sort_heap();他们的头文件函数是#include
首先是make_heap();他的函数原型是:void make_heap(first_pointer,end_...
分类:
其他好文 时间:
2014-05-28 02:15:50
阅读次数:
291
1.在PHP编程中, 我们经常会遇到一些直接产生输出的函数,
如passthru(),readfile(), var_dump() 等. 但有时我们想把这些函数的输出导入到文件中,或者先经过处理再输出,
或者把这些函数的输出作为字符串来处理. 这时我们就要用到 Output Buffer(输出缓冲....
分类:
Web程序 时间:
2014-05-27 16:05:43
阅读次数:
328
http://baptiste-wicht.com/posts/2012/04/c11-concurrency-tutorial-advanced-locking-and-condition-variables.htmlstruct
BoundedBuffer { int* buffer; ...
分类:
编程语言 时间:
2014-05-27 16:04:22
阅读次数:
303
<?php
/*--------------------编写自己的缓存类---------------*/
class my_cache{
//定义有关变量
private $cache_time;//缓存有效时间
private $cache_file;//缓存文件保存路径
//初始化类,默认是index.html时间是1
function __construc...
分类:
Web程序 时间:
2014-05-25 21:54:23
阅读次数:
328
为什么需要lambda函数
匿名函数是许多编程语言都支持的概念,有函数体,没有函数名。1958年,lisp首先采用匿名函数,匿名函数最常用的是作为回调函数的值。正因为有这样的需求,c++引入了lambda 函数,你可以在你的源码中内联一个lambda函数,这就使得创建快速的,一次性的函数变得简单了。例如,你可以把lambda函数可在参数中传递给std::sort函数
#include ...
分类:
编程语言 时间:
2014-05-25 21:35:27
阅读次数:
377
/*自我修改* Note: 堆排序(Heap Sort)*/#include using
namespace std;// 输出当前堆的排序状况void PrintArray(int data[], int size){ for (int i=1;
i a[i]) // 符号修改后形成...
分类:
其他好文 时间:
2014-05-25 19:07:25
阅读次数:
227
1.php注释://单行注释,/* */多行注释,/** *
*/文档注释。2.复习:字符串+数字=数字array_shift;数组的第一个,array_pop;数组的最后一个,array_push;数组添加。数组:array_sort:数组的值按升序排列,array_arsort:数组的值按降序排...
分类:
其他好文 时间:
2014-05-25 18:53:22
阅读次数:
237
寻找图中最小连通的路径,图如下:
算法步骤:
1. Sort all the edges in non-decreasing order of their weight.
2. Pick the smallest edge. Check if it forms a cycle with the spanning tree
formed so far. If cycle is n...
分类:
其他好文 时间:
2014-05-25 07:35:59
阅读次数:
301