Skip to content

Instantly share code, notes, and snippets.

View goldsborough's full-sized avatar
🔨
Fixing things

Peter Goldsborough goldsborough

🔨
Fixing things
View GitHub Profile
@goldsborough
goldsborough / red-black-tree.cpp
Created October 27, 2015 00:32
A Red Black Tree in C++.
template<typename Key, typename Value>
class RedBlackTree
{
public:
using size_t = std::size_t;
RedBlackTree()
: _root(nullptr)
{ }
@goldsborough
goldsborough / stacks-queues.cpp
Created October 27, 2015 21:20
A few stack and queue implementations for revision.
template<typename T>
class ArrayStack
{
public:
using size_t = std::size_t;
static const size_t minimum_capacity;
@goldsborough
goldsborough / unique-pointer.cpp
Created October 27, 2015 23:06
A smart unique-pointer class.
template<typename T>
class UniquePointer
{
public:
using pointer_t = T*;
using const_pointer_t = const T*;
using reference_t = T&;
@goldsborough
goldsborough / shared-pointer.cpp
Created October 27, 2015 23:49
A smart shared-pointer class.
template<typename T>
class SharedPointer
{
public:
using size_t = std::size_t;
using pointer_t = T*;
using const_pointer_t = const T*;
@goldsborough
goldsborough / Trie.hpp
Created November 3, 2015 01:13
An R-way trie.
#ifndef TRIE_HPP
#define TRIE_HPP
#include <algorithm>
#include <array>
#include <stdexcept>
#include <string>
template<
typename Value,
@goldsborough
goldsborough / heap.cpp
Created November 3, 2015 23:19
Some heap practice.
template<typename T>
class MaxHeap
{
public:
using size_t = std::size_t;
static const std::size_t minimum_capacity;
MaxHeap(std::size_t capacity = minimum_capacity)
@goldsborough
goldsborough / SeparateChainingHashTable.cpp
Created November 4, 2015 22:05
A hash-table using separate-chaining.
template<typename Key, typename Value>
class SeparateChainingHashTable
{
public:
using size_t = std::size_t;
using pre_hash_t = std::function<size_t(const Key&)>;
static const size_t minimum_capacity;
@goldsborough
goldsborough / SeparateChainingHashTable.cpp
Created November 4, 2015 22:40
An STLed-up hash table using seperate chaining.
template<typename Key, typename Value>
class SeparateChainingHashTable
{
public:
using size_t = std::size_t;
using pre_hash_t = std::function<size_t(const Key&)>;
static const size_t minimum_capacity;
@goldsborough
goldsborough / RBTree.cpp
Created November 5, 2015 00:56
Red-black Tree <3
template<typename Key, typename Value>
class RBTree
{
public:
using size_t = std::size_t;
RBTree() noexcept
: _root(nullptr)
@goldsborough
goldsborough / dpll.py
Last active November 22, 2021 20:37
The Davis-Putnam-Logemann-Loveland (DPLL) Algorithm.
#!/usr/bin/env python3
# -- coding: utf-8 -*-
"""Module for the Davis-Putnam-Logemann-Loveland (DPLL) Algorithm."""
from __future__ import print_function
from __future__ import unicode_literals
import re
import sys