国庆假期过半,phxrpc的代码阅读大概要小小告一段落啦。因为这两天还要读工作相关的代码,以及最后几天还有一次短途旅行。
所以非阻塞TCP流可能要留到下一篇了,这一篇只 …
more ...phxrpc使用了协程(ucontext)和IO复用技术(epoll)来实现网络通信。定时器在其中起到了非常重要的作用。下面我们就来分析一下phxrpc的timer.[h|cpp]
中的代码 …
void heapify(vector<int>& vec) {
int n = vec.size();
for (int a = 0, b = 1; b - 1 < n; a = b, b <<= 1) {
nth_element(vec.begin() + a, vec.begin() + b, vec.end());
}
}
You can implement a "heapify" by only four lines of code. And the time complexity is O(n)
.
Linkedin (or other social networks, such as Facebook and G+) use the "social graph information" to show the social relationship between you and other members.
Such as, "You and Mr.Obama share 10 mutual friends" or "You have 1,000 second-degree connections".
This feature is very common for a …
more ...用C++实现一个尽可能通用的sort函数
一个通用的sort函数应该包含以下要点: