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
import java.util.Arrays | |
// Three-way radix quicksort aka Multi-key quicksort | |
// | |
// Fast Algorithms for Sorting and Searching Strings | |
// http://www.cs.princeton.edu/~rs/strings/paper.pdf | |
object RadixQuicksort { | |
def sort(arr: Array[String]) = |
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
import java.util.Arrays | |
// BurstSort | |
// Cache-Conscious Sorting of Large Sets of Strings with Dynamic Tries | |
// http://goanna.cs.rmit.edu.au/~jz/fulltext/alenex03.pdf | |
class BurstLeaf(initSize: Int) { | |
var size: Int = 0 |
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 <stdio.h> | |
#include <immintrin.h> | |
#include <stdint.h> | |
int intersectionSize(int* a, const int alen, int* b, const int blen) { | |
int ai = 0, bi = 0, size = 0; | |
while (ai < alen && bi < blen) { | |
int av = a[ai]; | |
int bv = b[bi]; | |
size += ((av == bv) ? 1 : 0); |
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
// size = (1 << 25), time = 800 ms | |
// size = (1 << 25) - 1999, time = 400 ms ??? | |
// size = (1 << 24), time = 700 ms | |
val size = 1 << 25 | |
val randos = new util.Random() | |
val arr = Array.fill(size)(randos.nextInt) | |
java.util.Arrays.sort(arr) |
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
/** Idiosyncratic dictionary mapping strings to ints specialized for english | |
* words and other short alphanumeric strings. Long strigns are packed into | |
* one continuous char array, short alphanumeric strings are inlined into the | |
* structure that normally points into the array of long strings. This has the | |
* effect that strings shorter than 9 characters need only 12 bytes per mapping | |
* and lookup causes only one cache miss. | |
* | |
* Warning: Might contains subtle and not-so-soubtle errors. | |
*/ | |
class StringIntDictionary { |
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 <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <immintrin.h> | |
#include "sys/param.h" | |
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
<?php | |
class A { | |
public $somePropertyWithReasonablyLongName = 1; | |
} | |
class B { | |
public $somePropertyWithReasonablyLongName = 1; | |
} |
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
val boardStr = """ | |
53 7 | | |
6 195 | | |
98 6 | | |
8 6 3| | |
4 8 3 1| | |
7 2 6| | |
6 28 | | |
419 5| | |
8 79| |
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
$size = 512*1024; | |
$keys = range(1, $size); | |
//shuffle($keys); | |
$arr = []; | |
foreach ($keys as $k) { | |
$arr[$k] = $k; | |
} | |
$s = microtime(1); |
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
try { | |
throw new Exception("E2") | |
} catch { | |
case ex: Exception if ex.getMessage == "E1" => | |
println("caught E1") | |
case ex: Exception if ex.getMessage == "E2" => | |
println("caught E2") | |
} |