include/Tree/Comparable.hpp

Go to the documentation of this file.
00001 
00002 #ifndef hpp_CPP_Comparator_CPP_hpp
00003 #define hpp_CPP_Comparator_CPP_hpp
00004 
00005 #include "../Types/Types.hpp"
00006 
00007 namespace Comparator
00008 {
00010     enum CompareType
00011     {
00012         Less    = -1,
00013         Equal   =  0,
00014         Greater =  1 
00015     };
00016 
00018     struct DefaultComparator
00019     {
00020         template <typename T>
00021             inline static bool LessThan(const T & a, const T & b) { return (bool)(a < b); }
00022         template <typename T>
00023             inline static bool Equal(const T & a, const T & b) { return (bool)(a == b); }
00024     };
00025 
00041     template <class KeyType, class Policy = DefaultComparator>
00042     class Comparable 
00043     {
00044     public:
00045         typedef CompareType Result;
00046 
00047         // Interface
00048     public:
00050         inline Result Compare(const KeyType & _key) const { return Policy::Equal(_key, key) ? Equal : (Policy::LessThan(_key, key) ? Less : Greater);   }
00051         
00053         inline KeyType Key() const { return Key; }
00054 
00055         // Constructors
00056     public:
00058         Comparable(KeyType  _key) : key(_key) {}
00059 
00060     private:
00062         KeyType  key;
00063     };
00064 }
00065 
00066 #endif 

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is