Skip to content

Instantly share code, notes, and snippets.

Avatar

Connor Lane Smith cls

  • Oxford Nanopore Technologies
  • Berkshire, UK
View GitHub Profile
@cls
cls / intern.c
Last active Aug 29, 2015
Interning strings with a prefix tree
View intern.c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char *
intern(const char *s)
{
union tree {
const char *str;
@cls
cls / CovariantIterator.java
Last active Aug 29, 2015
Adaptor for covariant iterators in Java
View CovariantIterator.java
import java.util.Iterator;
public class CovariantIterator<T extends U, U> implements Iterator<U>
{
private Iterator<T> iter;
public CovariantIterator(Iterator<T> it)
{
this.iter = it;
}
@cls
cls / roman.c
Last active Aug 29, 2015
Roman numeral parser
View roman.c
#include <stdio.h>
enum { I, V, X, L, C, D, M, StackSize };
const int values[] = { 1, 5, 10, 50, 100, 500, 1000 };
int
unroman(const char *s)
{
int stack[StackSize];
You can’t perform that action at this time.