This file contains hidden or 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 <string> | |
#include <unordered_map> | |
using namespace std; | |
static const unordered_map<int, int> mapA{}; | |
int funcA(int key) { | |
auto f = mapA.find(key); |
This file contains hidden or 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
// A ZeroCopyOutputStream which appends bytes to a string. | |
// It has much a more favorable performance profile than StringOutputStream | |
// outside of Google since STLStringResizeUninitialized() is un-optimized. | |
class LIBPROTOBUF_EXPORT StringOutputStream2 : public ZeroCopyOutputStream { | |
public: | |
explicit StringOutputStream2(); | |
~StringOutputStream2(); | |
// implements ZeroCopyOutputStream --------------------------------- | |
bool Next(void** data, int* size); |
This file contains hidden or 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
use strict; | |
use warnings 'all'; | |
use Tie::File; | |
use Fcntl 'O_RDWR'; | |
my $file = "to-sort.txt"; | |
tie my @nums, 'Tie::File', $file | |
, mode => O_RDWR | |
, recsep => ', ' | |
, memory => 20_000_000 # max 20 MB read buffer |
This file contains hidden or 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
(ns iiit | |
(:import | |
[java.io Writer File OutputStream FileOutputStream BufferedReader BufferedWriter FileReader FileWriter] | |
[java.util Collections]) | |
(:use | |
[clojure stacktrace] | |
[clojure.set :only (union intersection difference)] | |
[clojure.contrib repl-utils trace pprint str-utils (io :only (spit append-spit make-parents delete-file))] | |
[clojure.contrib.shell :only (sh)])) |
This file contains hidden or 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
; MPI kind macros | |
(defmacro BLOCK_LOW [i p n] `(int (/ (* ~i ~n) ~p))) | |
(defmacro BLOCK_HIGH [i p n] `(- (BLOCK_LOW (+ 1 ~i) ~p ~n) 1)) | |
(defmacro BLOCK_SIZE [i p n] `(- (BLOCK_LOW (+ 1 ~i) ~p ~n) (BLOCK_LOW ~i ~p ~n))) | |
(defmacro BLOCK_ONWER [j p n] `(int (/ (- (* (inc ~j) ~p) 1) ~n))) | |
(defn partition-work | |
[p coll] | |
(let [s (seq coll) | |
n (count s)] |
This file contains hidden or 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
import java.util.Random; | |
import java.util.concurrent.*; | |
import lombok.Memoize; | |
public class MemoizeTest { | |
@Memoize | |
public static int test(final int k){ | |
System.out.println("test " + k); | |
return k+2; |
This file contains hidden or 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
/* | |
@lombok.Memoize | |
final Number test(int a, Double b) { | |
return null; | |
} | |
*/ | |
class Test{ | |
@java.lang.SuppressWarnings("all") |
This file contains hidden or 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 com.mxgraph.examples.swing; | |
import javax.swing.JFrame; | |
import com.mxgraph.layout.mxGraphLayout; | |
import com.mxgraph.layout.mxOrganicLayout; | |
import com.mxgraph.swing.mxGraphComponent; | |
import com.mxgraph.view.mxGraph; | |
@SuppressWarnings("serial") |
This file contains hidden or 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
(defn- print-map [m print-one w] | |
(#'clojure.core/print-sequential | |
"{" | |
(fn [e ^java.io.Writer w] | |
(do (print-one (key e) w) (.append w " ") (print-one (val e) w))) | |
", " | |
"}" | |
(seq m) w)) |
This file contains hidden or 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
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
class AProp implements Comparable<AProp>{ | |
private final int a; | |
public AProp(int a){ | |
this.a = a; | |
} | |
@Override | |
public int compareTo(AProp other) { |
NewerOlder