diff --git a/Makefile b/Makefile index 6f9dbf4..6eb9ee0 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ # -CXX := -g++-7 -CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror -O0 -std=c++14 -fPIC -DUSE_CATCH +CXX := -g++-8 +CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror -O0 -std=c++2a -fPIC -DUSE_CATCH # -DCOMPAT_TLS # ^ Enable this flag if your compiler ABI have issues with thread local storage LDFLAGS := -L/usr/lib -lstdc++ -lm -lpthread @@ -28,7 +28,7 @@ BUILD := build OBJ_DIR := $(BUILD)/objects APP_DIR := $(BUILD)/apps TARGET := tests.cpp -INCLUDE := -Iinclude/ +INCLUDE := -Iinclude/ -I9float/include SRC := \ OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o) diff --git a/include/scatter/scatter.h b/include/scatter/scatter.h index 8cfcddb..40d6612 100644 --- a/include/scatter/scatter.h +++ b/include/scatter/scatter.h @@ -1,14 +1,10 @@ +#pragma once #include -#ifdef COMPILE_TIME - #include "9float.hpp" - using scatter_key_t = ninefloat::Q; - static const scatter_key_t scatter_key_increment = ninefloat::Q::min_increment(); -#else - using scatter_key_t = uint64_t; - static const scatter_key_t scatter_key_increment = 1; -#endif - +#include "9float.hpp" +using scatter_key_t = ninefloat::Q; +static const scatter_key_t scatter_key_increment = ninefloat::Q::min_increment(); #include +#include namespace StorageTree{ @@ -35,7 +31,7 @@ namespace StorageTree{ constexpr T max(T any = 0) { if(any>any+scatter_key_increment) - return any + return any; return max(any+scatter_key_increment); } } @@ -50,26 +46,33 @@ namespace StorageTree{ using root = _impl::subdivision; template> - void update_weights(T& root, uint64_t sub_ratio=1, scatter_key_t begin=0, scatter_key_t end=_impl::max()) + uint64_t total_weight(T& root) { - scatter_key_t address_space = end-begin; - scatter_key_t base = begin - for(int idx=0:idx> + uint64_t total_weight(T& root) + { + return root.weight; + } + + template> + scatter_key_t update_weights(T& root, uint64_t sub_ratio=1, uint64_t total, scatter_key_t begin=0, scatter_key_t ratio=0.5) + { + } template> - void update_weights(T& root, scatter_key_t begin, scatter_key_t end) + scatter_key_t update_weights(T& root, uint64_t sub_ratio=1, uint64_t total, scatter_key_t begin, scatter_key_t end) { this->begin = begin; this->end = end; diff --git a/src/tests.cpp b/src/tests.cpp new file mode 100644 index 0000000..b4b6d14 --- /dev/null +++ b/src/tests.cpp @@ -0,0 +1,7 @@ +#include "scatter/scatter.h" + +int main() +{ + StorageTree::root n; + StorageTree::update_weights(n,1,StorageTree::total_weight(T& root)); +} \ No newline at end of file