aboutsummaryrefslogtreecommitdiff
path: root/pair.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-22 14:39:34 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-22 14:39:34 +0100
commita608b90f8c146430803871e20d043b60a278248b (patch)
tree194e6e80cd5403cc64d1e4915f9be45a462d3918 /pair.h
parentstrbuf (diff)
downloadcalp-a608b90f8c146430803871e20d043b60a278248b.tar.gz
calp-a608b90f8c146430803871e20d043b60a278248b.tar.xz
rest
Diffstat (limited to 'pair.h')
-rw-r--r--pair.h46
1 files changed, 45 insertions, 1 deletions
diff --git a/pair.h b/pair.h
index 1862a72d..b6755d6f 100644
--- a/pair.h
+++ b/pair.h
@@ -10,8 +10,52 @@ template<class T, class V> struct pair {
T* key;
V* val;
- pair () { }
+ pair () {
+ key = new T;
+ val = new V;
+ }
pair (pair<T,V>& other);
+
+ T& operator= (const T& other) {
+ delete this->key;
+ delete this->val;
+
+ *this->key = *other.key;
+ *this->val = *other.val;
+
+ return this;
+ }
+
+ pair* resolve (pair* other) {
+ if (this == NULL) return other;
+ return this;
+#if 0
+/*
+ * Resolves a collision in some form of structure (probably a hash-map
+ * or a trie). If dest is NULL just return new_. Otherwise mutates dest
+ * to have the correct form, and returns it. Destroying new_ in the
+ * process.
+ */
+ if (dest == NULL) return new_;
+
+ if (strbuf_cmp(dest->key, new_->key) != 0) {
+ ERR("Can't resolve between these two types");
+ return NULL;
+ }
+
+ /* This destroys new_->val. */
+ // APPEND(LLIST(content_set)) (&dest->val, &new_->val);
+ dest->val->append(new_->val);
+
+ // FREE(strbuf)(&new_->key);
+ // delete new_->key;
+ delete new_;
+ // free(new_);
+
+ return dest;
+#endif
+ }
+
};
#if 0