# HG changeset patch # User Teemu Piippo # Date 1469016477 -10800 # Node ID e8d58327cd7f815bcbedbf1d06c8f059d127b0f9 # Parent b9993733952acddda0cfbe2b2f32c574b591274e Restyled geometry.h diff -r b9993733952a -r e8d58327cd7f sources/geometry.h --- a/sources/geometry.h Wed Jul 20 15:07:03 2016 +0300 +++ b/sources/geometry.h Wed Jul 20 15:07:57 2016 +0300 @@ -30,90 +30,91 @@ #pragma once #include "basics.h" + BEGIN_ZFC_NAMESPACE + struct Position { int x; int y; - Position (int x, int y) : - x (x), - y (y) {} + Position(int x, int y) : + x(x), + y(y) {} Position() : - x (0), - y (0) {} + x(0), + y(0) {} - bool operator< (const Position& other) const + bool operator<(const Position& other) const { if (y != other.y) return y < other.y; - - return x < other.x; + else + return x < other.x; } - bool operator> (const Position& other) const + bool operator>(const Position& other) const { if (y != other.y) return y > other.y; - - return x > other.x; + else + return x > other.x; } - bool operator== (const Position& other) const + bool operator==(const Position& other) const { return y == other.y and x == other.x; } - bool operator!= (const Position& other) const + bool operator!=(const Position& other) const { - return not operator== (other); + return not operator==(other); } - bool operator<= (const Position& other) const + bool operator<=(const Position& other) const { - return not operator> (other); + return not operator>(other); } - bool operator>= (const Position& other) const + bool operator>=(const Position& other) const { - return not operator< (other); + return not operator<(other); } }; -// ------------------------------------------------------------------------------------------------- struct Size { int width; int height; - Size (int width, int height) : - width (width), - height (height) {} + Size(int width, int height) : + width(width), + height(height) {} Size() : - width (0), - height (0) {} + width(0), + height(0) {} - auto area() const -> int + int area() const { return width * height; } }; -// ------------------------------------------------------------------------------------------------- struct Rectangle : Position, Size { - Rectangle (int x, int y, int width, int height) : - Position (x, y), - Size (width, height) {} + Rectangle(int x, int y, int width, int height) : + Position(x, y), + Size(width, height) {} Rectangle() : Position(), Size() {} }; + END_ZFC_NAMESPACE