00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_MAPENTRY_H_
00019 #define _DECAF_UTIL_MAPENTRY_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 namespace decaf {
00024 namespace util {
00025
00026 template<typename K, typename V>
00027 class MapEntry {
00028 private:
00029
00030 K key;
00031 V value;
00032
00033 public:
00034
00035 MapEntry() : key(), value() {
00036 }
00037
00038 MapEntry(const MapEntry& other) : key(other.getKey()), value(other.getValue()) {
00039 }
00040
00041 MapEntry(const K& key, const V& value) : key(key), value(value) {
00042 }
00043
00044 MapEntry& operator= (const MapEntry& other) {
00045 this->key = other.getKey();
00046 this->value = other.getValue();
00047
00048 return *this;
00049 }
00050
00051 virtual ~MapEntry() {};
00052
00053 virtual void setKey(K key) {
00054 this->key = key;
00055 }
00056
00057 virtual K& getKey() {
00058 return this->key;
00059 }
00060
00061 virtual const K& getKey() const {
00062 return this->key;
00063 }
00064
00065 virtual void setValue(const V& value) {
00066 this->value = value;
00067 }
00068
00069 virtual V& getValue() {
00070 return this->value;
00071 }
00072
00073 virtual const V& getValue() const {
00074 return this->value;
00075 }
00076
00077 virtual bool equals(const MapEntry<K, V>& entry) const {
00078 if (this == &entry) {
00079 return true;
00080 }
00081
00082 if (!(this->key == entry.getKey())) {
00083 return false;
00084 }
00085
00086 if (!(this->value == entry.getValue())) {
00087 return false;
00088 }
00089
00090 return true;
00091 }
00092
00093 virtual bool operator==(const MapEntry<K, V>& other) const {
00094 return this->equals(other);
00095 }
00096 };
00097
00098 }}
00099
00100 #endif