Skip to content

Instantly share code, notes, and snippets.

@matovitch
matovitch / menu.elm
Last active September 12, 2016 17:53
import Html as H
import Html.Attributes as HA
import Html.App as App
main : Program Never
main =
App.program
{
init = init,
view = view,
#include <iostream>
#include <string>
#include <memory>
template <typename T>
union Uninitialized
{
Uninitialized() : _initialized() {}
~Uninitialized() {}
#ifndef __TOPOSORT_H__
#define __TOPOSORT_H__
#include <unordered_set>
#include <functional>
#include <memory>
#include <vector>
#include "RobinHoodHashtable.hpp"
@matovitch
matovitch / pickset.hpp
Last active April 6, 2022 17:33
container with O(1) insertion, deletion, and pick random
#include <vector>
#include <random>
#include <cstddef>
#include <functional>
#include <unordered_set>
template <typename T, typename H = std::hash<T> >
struct Hasher
{
std::size_t operator()(const T* const pt) const
mode ASSEMBLER
{
"iadd" => TKN_IADD;
"isub" => TKN_ISUB;
"imul" => TKN_IMUL;
"idiv" => TKN_IDIV;
"imod" => TKN_IMOD;
"ineg" => TKN_INEG;
#include "visitor.hpp"
#include <iostream>
class OtherTypeAsteroid;
class ExplodingAsteroid;
class ApolloSpacecraft;
class OthersSpacecraft;
class SpaceShip {};
class Asteroid : public Visitor<ApolloSpacecraft, OthersSpacecraft>{};
#ifndef __VISITOR_HPP__
#define __VISITOR_HPP__
template<typename... Types>
struct Visitor;
template<typename... Visitors>
struct Visitable;
template<typename T>
#include <ctime>
#include <cstddef>
#include <algorithm>
#include <iostream>
#include "kmeans.hpp"
static const std::size_t nPoints = 50000;
static const std::size_t nClusters = 100;
struct Point
#ifndef __KMEANS_H__
#define __KMEANS_H__
#include <ctime>
#include <vector>
#include <limits>
#include <cstddef>
namespace kmeans
{
#include <queue>
#include <cstdlib>
#include <iostream>
static const int n_log2 = 3; //length of the array log2
static const int n = 1 << n_log2; //length of the array
static const int ker = 3; //length of the kernel
int abs(int x)
{