From 94a1189d757f0269ac081ad2d750152e30564986 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 19 Dec 2010 12:19:41 +0100 Subject: Linked common as submodule. --- common | 1 + common/cyclicint.h | 84 ------------------------------------------------------ 2 files changed, 1 insertion(+), 84 deletions(-) create mode 160000 common delete mode 100644 common/cyclicint.h (limited to 'common/cyclicint.h') diff --git a/common b/common new file mode 160000 index 0000000..dd64a35 --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit dd64a35c949738c2c321989d065e0754556823d5 diff --git a/common/cyclicint.h b/common/cyclicint.h deleted file mode 100644 index 7c06877..0000000 --- a/common/cyclicint.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef CYCLICINT_H -#define CYCLICINT_H - -//! Class containing an integer which ranges from 0..N-1. -//! -//! Exceeding the ends will overflow to the other end. Implicit cast to/from int is provided. -template -class CyclicInt { - private: - int value; - - CyclicInt set(int v) { - value = v < N ? v < 0 ? N - -v % N : v : v % N; - return *this; - } - - public: - CyclicInt() { - - } - - CyclicInt(int v) { - set(v); - } - - CyclicInt operator=(int v) { - return set(v); - } - - CyclicInt operator+(CyclicInt v) { - return value + v.value; - } - - CyclicInt operator+(int v) { - return value + v; - } - - CyclicInt operator+=(CyclicInt v) { - return set(value + v.value); - } - - CyclicInt operator++() { - return set(value + 1); - } - - CyclicInt operator++(int) { - int v = value; - set(value + 1); - return v; - } - - CyclicInt operator-() { - return -value; - } - - CyclicInt operator-(CyclicInt v) { - return value - v.value; - } - - CyclicInt operator-(int v) { - return value - v; - } - - CyclicInt operator-=(CyclicInt v) { - return set(value - v.value); - } - - CyclicInt operator--() { - return set(value - 1); - } - - CyclicInt operator--(int) { - int v = value; - set(value - 1); - return v; - } - - operator int() { - return value; - } -}; - - -#endif -- cgit v1.2.3