Skip to content

Instantly share code, notes, and snippets.

View jsancio's full-sized avatar

José Armando García Sancio jsancio

View GitHub Profile
extern crate collections;
use collections::TrieMap;
fn main() {
let workers = vec!(
("Jack", vec!((0000, 200), (500, 1200))),
("Jackie", vec!((0000, 600), (800, 1300))),
("Marty", vec!((400, 600), (1100, 1600), (1700, 2359))),
("Ronald", vec!((600, 1200), (1300, 1800), (1900, 2359))),
@jsancio
jsancio / rust_path_length.rs
Created November 25, 2014 20:55
Rust ref and boxes
extern crate core;
use core::cmp::min;
enum Tree {
EmptyTree,
BranchTree(int, Box<Tree>, Box<Tree>)
}
fn path_length(tree: &Tree, first: int, second: int) -> int {
@jsancio
jsancio / ScopeExit
Created December 2, 2014 19:48
Rust Scope Exit
#![feature(unsafe_destructor)]
use std::io;
fn main() {
match test_scope() {
Ok(_) => println!("Main: test scope succeeded"),
Err(err) => panic!("Main: file error: {}", err),
};
}
class BatchAccumulator {
// ...
private Long append(int epoch, List<T> records, boolean isAtomic) {
if (epoch != this.epoch) {
return Long.MAX_VALUE;
}
ObjectSerializationCache serializationCache = new ObjectSerializationCache();
int batchSize = 0;
for (T record : records) {