Skip to content

Instantly share code, notes, and snippets.

View rosacris's full-sized avatar

Cristian Rosa rosacris

View GitHub Profile
@rosacris
rosacris / MyModule.ex
Created October 19, 2016 19:44
Access behaviour hack
defmodule MyModule do
@behaviour Access
defstruct x: 0, y: 1
## Delegate Access callbacks to Map module
defdelegate fetch(a, b), to: Map
defdelegate get(a, b, c), to: Map
defdelegate get_and_update(a, b, c), to: Map
defdelegate pop(a, b), to: Map
@rosacris
rosacris / lib.rs
Created February 1, 2016 18:02
Parallel qsort
use std::cmp::Ordering;
use std::fmt::Debug;
extern crate scoped_pool;
use scoped_pool::Pool;
/// An insertion sort for small slices
#[inline]
fn insertion_sort<T>(arr: &mut [T], left: usize, right: usize) where T: Ord {