This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"strings" | |
) | |
const ( | |
None = iota |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ISO/IEC 9988:1999 grammar (ISO C) */ | |
%token ID TYPEDEF_NAME INT_CST STRING_CST SIZEOF ; | |
%token ARROW INC DEC ; | |
%token LSHIFT RSHIFT ; | |
%token LE GE ; | |
%token EQ NE ; | |
%token ANDAND OROR ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unordered_map> | |
#include <string> | |
#include <iostream> | |
void sorted(const std::string &a, const std::string &order) { | |
std::unordered_map<char, unsigned int> count; | |
for (auto c : a) | |
++count[c]; | |
for (auto c: order) { | |
for (auto i = count[c]; i > 0; --i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++/clang++ -pthread --std=c++11 delay-call.cc -o delay-call | |
#include <iostream> | |
#include <functional> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <chrono> | |
#include <queue> | |
#include <ctime> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"container/stack" | |
"flag" | |
"fmt" | |
gio "graph/io" | |
"io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <memory> | |
#include <vector> | |
#include <algorithm> | |
#include <array> | |
struct data { | |
data(char c) { std::fill(begin(blk), end(blk), c); } | |
std::array<char, (1 << 20)> blk; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"container/deque" | |
"fmt" | |
gio "graph/io" | |
"io" | |
"math" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <utility> | |
template <typename T> constexpr size_t align_to(size_t n) { | |
return (n + alignof(T) - 1) & -alignof(T); | |
} | |
template <typename T> constexpr size_t skip(size_t n) { | |
return align_to<T>(n) + sizeof(T); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <deque> | |
#include <mutex> | |
#include <condition_variable> | |
struct queue { | |
void put(int x) { | |
std::unique_lock<std::mutex> guard(lock); | |
q.push_back(x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"sync/atomic" | |
"time" | |
) | |
var pool *sync.Pool |
OlderNewer