// Utility where you record has both key and value (not Key and index) #pragma once #include #include #include #include #include #include #define KEY_SIZE 10 #define VALUE_SIZE 90 typedef struct k_t{ char key[KEY_SIZE]; void operator=(const k_t &rhs){; memcpy(&key, &rhs.key, KEY_SIZE); } } k_t; typedef struct value_t{ char value[VALUE_SIZE]; void operator=(const value_t &rhs){; memcpy(&value, &rhs.value, VALUE_SIZE); } } value_t; typedef struct record{ k_t k; value_t v; record(k_t _k, value_t _v){ k = _k; v = _v; } bool operator<(const record &rhs){ int n; n = memcmp(k.key, rhs.k.key, KEY_SIZE); if(n<0) return true; else return false; } void operator=(const record &rhs){ k = rhs.k; v = rhs.v; } bool operator>(const record &rhs){ int n; n = memcmp(k.key, rhs.k.key, KEY_SIZE); if(n>0) return true; else return false; } record(){} } record_t; /** struct indexed_key{ k_t k; size_t r_index; bool operator<(const indexed_key &rhs) const{ int n; n = memcmp(k.key, rhs.k.key, KEY_SIZE); if(n>0) return false; else if (n<0) return true; else { return r_index < rhs.r_index; } } bool operator>(const indexed_key &rhs) const{ int n; n = memcmp(k.key, rhs.k.key, KEY_SIZE); if(n>0) return true; else if (n<0) return false; else { return r_index > rhs.r_index; } } indexed_key(k_t _k, size_t _r_index){ k = _k; r_index = _r_index; } indexed_key() { r_index = 0; } }; typedef struct in_record { indexed_key ki; size_t v_index; bool operator<(const in_record &rhs) const { return ki < rhs.ki; } bool operator>(const in_record &rhs) const { return ki > rhs.ki; } void operator=(const in_record &rhs) { ki.k = rhs.ki.k; ki.r_index = rhs.ki.r_index; v_index = rhs.v_index; } in_record(k_t _k, size_t _v_index, size_t _r_index) { ki.k = _k; ki.r_index = _r_index; v_index = _v_index; } in_record() { ki.r_index = 0; v_index = 0; } } in_record_t; */