00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _COMPARABLE_H_
00037 #define _COMPARABLE_H_
00038
00039 #define MAX_FORMAT_STRING 128
00040
00041
00042 template <class Key>
00043 class AVL_tree;
00044
00045
00046 template <class Key>
00047 class Comparable {
00048 protected:
00049 Key key;
00050
00051 virtual const char *key_format_string() { return ""; };
00052
00053 friend class AVL_tree<Key>;
00054
00055 public:
00056 Comparable(Key k) : key(k) {};
00057
00058 virtual ~Comparable() {};
00059
00060 Key key_value() const { return key; };
00061
00062
00063 inline bool operator== (Comparable<Key> other) {
00064 return key == other.key_value();
00065 };
00066
00067 inline bool operator< (Comparable<Key> other) {
00068 return key < other.key_value();
00069 };
00070
00071 inline bool operator> (Comparable<Key> other) {
00072 return key > other.key_value();
00073 };
00074
00075 inline bool operator<= (Comparable<Key> other) {
00076 return key <= other.key_value();
00077 };
00078
00079 inline bool operator>= (Comparable<Key> other) {
00080 return key >= other.key_value();
00081 };
00082 };
00083
00084
00085 #endif // _COMPARABLE_H_