Skip to content

Instantly share code, notes, and snippets.

@HauptJ
Created November 15, 2025 23:52
Show Gist options
  • Select an option

  • Save HauptJ/52327fa860d6cd41186006698e1b5a6b to your computer and use it in GitHub Desktop.

Select an option

Save HauptJ/52327fa860d6cd41186006698e1b5a6b to your computer and use it in GitHub Desktop.
MyStringMap.h StringMap / HashMap QuadraticProving Implementation in Progress
//
// Created by josh on 11/15/2025.
//
#ifndef MYSTRINGMAP_H
#define MYSTRINGMAP_H
#include "abstractstringmap.h"
#include <string>
#include <utility>
#include <vector>
#include <iostream>
using namespace std;
template <typename T>
class MyStringMap : public AbstractStringMap<T> {
enum EntryType {ACTIVE, EMPTY, DELETED};
struct Entry {
string m_key;
T m_value;
EntryType m_type;
Entry(const string& key, const T& value, const EntryType type = EMPTY)
: m_key(key), m_value(value), m_type(type) {};
Entry(string key, const T& value, const EntryType type = EMPTY)
: m_key(std::move(key)), m_value(value), m_type(type) {};
~Entry() = default;
};
unsigned int m_size;
unsigned int m_capacity;
vector<Entry> m_entries;
bool isActive(int currPos) const {
return m_entries[currPos].m_type == ACTIVE;
}
bool isEmpty(int currPos) const {
return m_entries[currPos].m_type == EMPTY;
}
bool isDeleted(int currPos) const {
return m_entries[currPos].m_type == DELETED;
}
public:
MyStringMap() : m_size(0), m_capacity(10) {};
int size() const override {;
return m_size;
}
bool isEmpty() const override {
return m_size == 0;
}
void clear() override {
//m_entries.clear();
m_size = 0;
for ( Entry & entry: m_entries ) {
entry.m_type = EMPTY;
}
}
};
#endif //MYSTRINGMAP_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment