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
#Add those lines to lib/system.nim: | |
iterator pairs*[T](it: iterator(): T {.inline.}): tuple[key: int, val: T] {.inline.} = | |
## iterates over each item of it. Yields ``(index, item)`` pairs. | |
var i = 0 | |
for v in it: | |
yield (i, v) | |
inc(i) | |
iterator mpairs*[T](it: iterator(): T {.inline.}): tuple[key: int, val: var T] {.inline.} = |
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 "splay.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <limits.h> | |
//===== Splay Node =====// | |
typedef struct splay_node_t { | |
struct splay_node_t * left; |
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 "avl.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
static inline int max( int a, int b ) { | |
return a < b ? b : a; | |
} |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <math.h> | |
typedef void (*sort_func)( double *, size_t ); | |
static double * init_array( size_t 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
function initListAndMatrix (numElements) | |
local l, pos = {}, {} | |
for i = 1, numElements do | |
l[i] = i | |
pos[i] = {} | |
for j = 1, numElements do pos[i][j] = 0 end | |
end | |
return l, pos | |
end |
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
// Type-safe varargs with C++11 variadic templates. | |
// | |
// Andreas Fredriksson <deplinenoise at gmail dott com> | |
// minor changes from: | |
// Thomas Hume <thomas dot hume at labri dot fr> | |
// | |
// This code is in the public domain. | |
#include <stdio.h> | |
#include <stdarg.h> |