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
--- | |
BasedOnStyle: LLVM | |
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: Align | |
AlignArrayOfStructures: None | |
AlignConsecutiveAssignments: | |
Enabled: false | |
AcrossEmptyLines: false | |
AcrossComments: false | |
AlignCompound: false |
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 <windows.h> | |
#include <processsnapshot.h> | |
VOID MyStackWalk(HANDLE hThread) | |
{ | |
// TODO: make it intel-friendly too | |
STACKFRAME64 sfStackFrame{}; | |
sfStackFrame.AddrPC.Offset = context.Rip; | |
sfStackFrame.AddrFrame.Offset = context.Rbp; | |
sfStackFrame.AddrStack.Offset = context.Rsp; |
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 <tuple> | |
#include <type_traits> | |
// Type trait to see if calling a function with given arguments | |
// causes a narrowing conversion for any parameter. Implementation | |
// currently only tested with C linkage functions (e.g. Windows API functions). | |
namespace detail | |
{ | |
template <typename...> |
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
#ifndef HASHMAP_HH | |
#define HASHMAP_HH 1 | |
#include <memory> | |
#include <utility> | |
#include <functional> | |
#include <vector> | |
#include "hash_policy.hh" | |
template < |
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
#lang racket | |
(define eval-mcl | |
(lambda (line [env '()]) | |
(let* ([atom? (lambda (a) (or (number? a) (boolean? a)))] | |
[evaluated-pair? (lambda (ls) (pair? (eval-mcl ls env)))] | |
[evaluated-atom? (lambda (a) (atom? (eval-mcl a env)))] | |
[zip (lambda (ls1 ls2) (map cons ls1 ls2))]) | |
(match line | |
[`(quote ,a) 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
#lang racket | |
;; Node: Number, Node | Null, Node | Null | |
(struct node (x left right) #:transparent) | |
;; height: Node | Null -> Number | |
(define height | |
(lambda (tree) | |
(if (null? tree) | |
-1 |
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
#ifndef HASH_POLICY_HH | |
#define HASH_POLICY_HH 1 | |
#include <string> | |
template <typename KeyType> | |
struct SimpleHashPolicy { | |
static const unsigned int hash(const KeyType k, const unsigned int tableSize) { | |
return k % tableSize; | |
} |
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
#lang racket | |
;; MTF: List[Any] | |
(struct mtf-list (list) #:transparent) | |
;; Examples: | |
;; (mtf 1 2 3) -> (mtf-list '(1 2 3)) | |
;; (mtf 1) -> (mtf-list '(1)) | |
;; (mtf) -> (mtf-list '()) | |
(define-syntax mtf |
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
#lang racket | |
;; Node: Number, Node | Null, Node | Null | |
(struct node (x left right) #:transparent) | |
;; bst-add: Node | Null -> Node | |
(define bst-add | |
(lambda (tree v) | |
(if (null? tree) | |
; Add the root node to an empty tree. |