10 2015 档案

摘要:int foo(int n){ if (n < 1){ return 0; } int result = 0; for(int i = 1, factor = 1; i <= n; (factor += (pow(10.0, i))), ++i){ ... 阅读全文
posted @ 2015-10-29 18:26 wu_overflow 阅读(1786) 评论(0) 推荐(0)
摘要:templateT parallelAccumulate(Iterator first, Iterator last, T init){ size_t const length = std::distance(first, last); if (length == 0){ ... 阅读全文
posted @ 2015-10-24 18:44 wu_overflow 阅读(213) 评论(0) 推荐(0)
摘要:templatestruct AccumulateBlock{ T operator()(Iterator first, Iterator last) { return std::accumulate(first, last, T()); }};class Threa... 阅读全文
posted @ 2015-10-24 17:57 wu_overflow 阅读(152) 评论(0) 推荐(0)
摘要:while(static_cast(std::cin.get()) != '\n') { //若读取的字符串不是换行符,则将其放回流内。 std::cin.unget(); cin >> input; // ... } 阅读全文
posted @ 2015-10-20 20:15 wu_overflow 阅读(495) 评论(0) 推荐(0)
摘要:在知乎上看到一个问题,说自己的函数分明是对的,输入少量数据验证表明也是对的,可是当数据量达到一定规模的时候,程序会变得特别特别的慢,不知为什么。后来发现是因为他把函数声明和数组声明都写在 main 函数里了,声明在 main 函数中的变量都是分配在栈上的,因此当数据过多的时候,就会出现栈溢出的情况。... 阅读全文
posted @ 2015-10-20 18:51 wu_overflow 阅读(261) 评论(0) 推荐(0)
摘要:templatestruct Sorter{ struct ChunkToSort { std::list data; std::promise> promise; }; ThreadSafeStack chun... 阅读全文
posted @ 2015-10-17 11:11 wu_overflow 阅读(233) 评论(0) 推荐(0)
摘要:templateclass ThreadSafeStack{private: std::stack data; mutable std::mutex m;public: ThreadSafeStack() = default; ThreadSafeStack(con... 阅读全文
posted @ 2015-10-16 14:24 wu_overflow 阅读(336) 评论(0) 推荐(0)
摘要:templateclass LockFreeStack{private: struct Node; struct CountedNode { int externalCount = 0; Node* ptr = nullp... 阅读全文
posted @ 2015-10-05 02:39 wu_overflow 阅读(207) 评论(0) 推荐(0)
摘要:constexpr size_t maxHazardPointers = 100;struct HazardPointer{ std::atomic id; std::atomic pointer;};array hazardPointers;class Hazard... 阅读全文
posted @ 2015-10-03 16:18 wu_overflow 阅读(695) 评论(1) 推荐(0)

点击右上角即可分享
微信分享提示