Skip to content

Instantly share code, notes, and snippets.

View pallas's full-sized avatar

Derrick Lyndon Pallas pallas

View GitHub Profile
@pallas
pallas / minkowski_distance.cc
Last active January 12, 2023 16:24
Minkowski distance function
// All rights reserved,
// Derrick Pallas
// License: zlib
#include <cmath>
#include <cstdlib>
#include <limits>
#include <vector>
template <typename fp_type>
@pallas
pallas / minkowski_question_mark.cc
Last active December 17, 2015 06:28
Minkowski question mark function
// All rights reserved,
// Derrick Pallas
// License: zlib
#include <cmath>
#include <cstdlib>
template <typename fp_type>
fp_type minkowski_question_mark(const fp_type fp) {
float a0 = floor(fp);
@pallas
pallas / intrusive_queue.hh
Last active August 29, 2015 13:57
C++ intrusive queue
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef INTRUSIVE_QUEUE_H
#define INTRUSIVE_QUEUE_H
#include <cassert>
#include <cstddef>
@pallas
pallas / intrusive_stack.hh
Last active March 26, 2020 03:11
C++ intrusive stack
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef INTRUSIVE_STACK_H
#define INTRUSIVE_STACK_H
#include <cassert>
#include <cstddef>
@pallas
pallas / countable.hh
Last active August 29, 2015 13:57
C++ reference counter base, with hook
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef COUNTABLE_H
#define COUNTABLE_H
#include <cassert>
template <class T>
@pallas
pallas / Makefile
Last active August 23, 2017 20:54
Basic Makefile template
default: all
DEBUG ?= -g -ggdb -DDEBUG
ifeq ($(DEBUG),)
override DEBUG := -DNDEBUG
endif
override LDFLAGS += -lstdc++
override CFLAGS += $(DEBUG) -MD -MP
override CXXFLAGS += $(DEBUG) -MD -MP
@pallas
pallas / container_of.hh
Last active November 22, 2016 04:05
C++ member-to-object for classes with standard layout
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef CONTAINER_OF
#define CONTAINER_OF
#include <cstddef>
template <class T, typename M>
@pallas
pallas / intrusive_order.hh
Last active August 29, 2015 13:58
C++ intrusive ordered queue + fast tail inserts
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef INTRUSIVE_ORDER_H
#define INTRUSIVE_ORDER_H
#include <cassert>
#include <cstddef>
#include <algorithm>
@pallas
pallas / intrusive_tree.hh
Last active October 29, 2022 18:26
C++ intrusive red-black tree
// All rights reserved,
// Derrick Pallas
// License: zlib
#ifndef INTRUSIVE_TREE_H
#define INTRUSIVE_TREE_H
#include <cassert>
#include <cstddef>
#include <algorithm>
@pallas
pallas / keybase.md
Last active May 7, 2020 19:30
Keybase proof

Keybase proof

I hereby claim:

  • I am pallas on github.
  • I am pallas (https://keybase.io/pallas) on keybase.
  • I have a public key ASCsQ6NtBDpKhw9f2MArRunk8lTLxLjfIFaFVpzO79Pqtwo

To claim this, I am signing this object: