From c41768dbbd50a0055298d5ec6318ae7f1d2e4ab3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 11 Sep 2022 01:39:29 -0400 Subject: New testdrive using sqlite db as data storage. Add signature serialization & deserialization. Only link what we need from OpenCV. --- compressed_vector.hpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'compressed_vector.hpp') diff --git a/compressed_vector.hpp b/compressed_vector.hpp index 0173157..780a563 100644 --- a/compressed_vector.hpp +++ b/compressed_vector.hpp @@ -5,8 +5,11 @@ #include #include +#include #include +#include "base64.hpp" + template struct compressed_vector_hash; @@ -31,8 +34,7 @@ public: //assert(v <= M); if (sz % P == 0) v.push_back(0); - set(sz, val); - ++sz; + set(sz++, val); } void pop_back() { @@ -47,12 +49,12 @@ public: T back() const {return get(sz - 1);} T get(size_t i) const { - //assert(i < sz); + assert(i < sz && (i / P) < v.size()); return (T)((v[i / P] >> (i % P * B)) & M); } void set(size_t i, T val) { - //assert(i < sz); + assert(i < sz && (i / P) < v.size()); v[i / P] &= ~(M << (i % P * B)); v[i / P] |= ((uint64_t) val) << (i % P * B); } @@ -71,6 +73,24 @@ public: return sz == other.sz && v == other.v; } + // unsafe stuff! potentially invariant-breaking. only use for data exchanging. + void internal_container_resize(size_t ds) + { + v.resize(ds); + } + size_t internal_container_size() + { + return v.size(); + } + void* internal_data() + { + return v.data(); + } + void internal_set_size(int sz) + { + this->sz = sz; + } + friend struct compressed_vector_hash; }; -- cgit v1.2.3