摘要:
//下一个最大的二次幂inline int nextPowerOfTwo(int x){ x |= (x >> 1); x |= (x >> 2); x |= (x >> 4); x |= (x >> 8); x |= (x >> 16); return x + 1;}//判断是不是2的幂inline bool isPowerOfTwo(int x){ bool result = x > 0 && (x & (x - 1)) == 0; return result;} 阅读全文
posted @ 2013-07-25 11:44
OpenSoucre
阅读(210)
评论(0)
推荐(0)
摘要:
利用模板templateinline void swap(T& a, T& b){ T tmp = a; a = b; b = tmp;}利用宏定义#define SWAP( x , y) ({__typeof__(x) temp = (x);x=y; y = temp;}) 阅读全文
posted @ 2013-07-25 11:31
OpenSoucre
阅读(311)
评论(0)
推荐(0)

浙公网安备 33010602011771号