今天在Code4App上看了一个GCD倒计时的Demo,觉得不错代码贴出来备用-(void)startTime{ __block int timeout =
30; //倒计时时间 dispatch_queue_t queue = dispatch_get_global_queue(DI...
分类:
其他好文 时间:
2014-06-13 06:15:01
阅读次数:
208
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(delayInSeconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ code to
be executed after ...
分类:
其他好文 时间:
2014-06-13 00:49:06
阅读次数:
271
当集合或数组内的对象需要排序时,会利用Collections.sort或Arrays.sort来进行排序,通常会implement
Comparable,来实现自定义排序,透过回传值来表示排序的大小。
分类:
编程语言 时间:
2014-06-12 19:33:37
阅读次数:
239
水题#include #include #include using namespace
std;int main(){ int n,m; cin >> n >> m; int cnt = 0, sum = 0;
for(int i = 0 ; i > a; i...
分类:
其他好文 时间:
2014-06-10 16:38:18
阅读次数:
226
3.1Describe how you could use a single array to
implement three stacks.Flexible
Divisions的方案,当某个栈满了之后,需要把相邻的栈调整好,这是一个递归的过程。每个stack有一些属性,所以不妨将每个stack封闭...
分类:
其他好文 时间:
2014-06-10 16:27:38
阅读次数:
234
bool Topo()
{
int sum = 0;
while(1)
{
queue Q;
for(int i = 1; i <= n; i++)
if(!in[i])
Q.push(i);
sum += Q.size();
if(sum == n)
return true;
if(!Q.size())
return false;
whi...
分类:
其他好文 时间:
2014-06-10 13:29:29
阅读次数:
236
今天终于决定使用STL提供的priority_queue,发现还挺好用,虽然很多人都称他效率不够高,但是使用起来很方便。下面就总结一下它的一般用法:模板原型:priority_queueT:存放容器的元素类型Sequence:实现优先级队列的底层容器,默认是vectorCompare:用于实现优先级...
分类:
其他好文 时间:
2014-06-10 11:36:53
阅读次数:
201
Graph coloring is the problem of assigning a color to each vertex of an undirected graph such that no two adjacent vertices have the same color. We implement the greedy algorithm from Scalable parallel graph coloring algorithms. The algorithm iteratively f...
分类:
其他好文 时间:
2014-06-10 07:10:19
阅读次数:
260
题目
Implement int sqrt(int x).
Compute and return the square root of x.
方法一
使用二分查找,注意int的边界问题,使用除法。
public int sqrt(int x) {
if (x <= 1) {
return x;
...
分类:
其他好文 时间:
2014-06-10 06:49:45
阅读次数:
274
mmc
io的读写从mmc_queue_thread()的获取queue里面的request开始。先列出调用栈,看下大概的调用顺序,
下面的内容主要阐述这些函数如何工作。host->ops->request() //
sdhci_request()mmc_start_request()mmc_sta...
分类:
其他好文 时间:
2014-06-08 19:09:05
阅读次数:
304