Skip to content

Instantly share code, notes, and snippets.

View ijklr's full-sized avatar

shaun yi cheng ijklr

View GitHub Profile
@ijklr
ijklr / copy.cpp
Created July 9, 2016 02:14
C++ STL std::copy benchmark
#include <iostream>
#include <random>
#include <chrono>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <ostream>
#include <cstring>
@ijklr
ijklr / lzw.cpp
Created April 6, 2016 21:10
lzw c++11
#include <iostream>
#include <unordered_map>
#include <fstream>
#include <cstdint>
#include <string>
using namespace std;
union ben{
uint16_t num;
char c[2];
@ijklr
ijklr / lzw.cpp
Created March 31, 2016 17:39
To compile: g++ -std=c++11 lzw.cpp
#include <deque>
#include <iostream>
#include <unordered_map>
#include <fstream>
#include <cstdint>
#include <thread>
#include <string>
#include <cstring>
using namespace std;
@ijklr
ijklr / dfs.cpp
Created January 19, 2016 02:31
Depth First Search in C++. To compile: g++ -std=c++11 dfs.cpp
//Title: Depth first search in C++
//Author: Shaun Cheng
//Date: 1/18/2016
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <stack>
using namespace std;
@ijklr
ijklr / StackHash.cpp
Created January 14, 2016 15:56
A very rudimentary C++ implementation of hashmap, allocated on the stack.
//This program is a simple demonstration of the speed difference between standard hashmap from C++ STL library vs. my simple hashmap allocated on the stack. My version is severely limited in for general use, but it is faster and can be run on Arduino devices, whereas there's no STL available for the arduino.
//To compile: g++ -std=c++11 StackHash.cpp
#include <iostream>
#include <unordered_set>
#include <ctime>
using namespace std;
//This default hash assumes T can be converted to int implicitly.
//The user can define how to map T to int with template specializations.