diff options
Diffstat (limited to 'example')
26 files changed, 4961 insertions, 0 deletions
diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 0000000..3033e2e --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,56 @@ +SUBDIRS = multi_type_vector + +AM_CPPFLAGS = -I$(top_srcdir)/include -DNDEBUG + +EXTRA_PROGRAMS = \ + flat-segment-tree \ + flat-segment-tree-itrs \ + multi-type-matrix \ + packed-trie-map \ + packed-trie-state-custom \ + packed-trie-state-int \ + point-quad-tree \ + segment-tree \ + trie-map \ + rtree-simple \ + rtree-erase \ + rtree-medium \ + rtree-medium-bulkload + +flat_segment_tree_SOURCES = flat_segment_tree.cpp +flat_segment_tree_itrs_SOURCES = flat_segment_tree_itrs.cpp +multi_type_matrix_SOURCES = multi_type_matrix.cpp +packed_trie_map_SOURCES = packed_trie_map.cpp +packed_trie_state_custom_SOURCES = packed_trie_state_custom.cpp +packed_trie_state_int_SOURCES = packed_trie_state_int.cpp +point_quad_tree_SOURCES = point_quad_tree.cpp +segment_tree_SOURCES = segment_tree.cpp +trie_map_SOURCES = trie_map.cpp +rtree_simple_SOURCES = rtree_simple.cpp +rtree_erase_SOURCES = rtree_erase.cpp +rtree_medium_SOURCES = rtree_medium.cpp +rtree_medium_bulkload_SOURCES = rtree_medium_bulkload.cpp + +TESTS = \ + flat-segment-tree \ + flat-segment-tree-itrs \ + multi-type-matrix \ + packed-trie-map \ + packed-trie-state-custom \ + packed-trie-state-int \ + point-quad-tree \ + segment-tree \ + trie-map \ + rtree-simple \ + rtree-erase \ + rtree-medium \ + rtree-medium-bulkload + +TEST_ARTIFACTS = \ + *.svg \ + us-presidents.bin \ + cities.bin + +clean-local: + rm -f $(TESTS) $(TEST_ARTIFACTS) + diff --git a/example/Makefile.in b/example/Makefile.in new file mode 100644 index 0000000..7e800ef --- /dev/null +++ b/example/Makefile.in @@ -0,0 +1,1335 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +EXTRA_PROGRAMS = flat-segment-tree$(EXEEXT) \ + flat-segment-tree-itrs$(EXEEXT) multi-type-matrix$(EXEEXT) \ + packed-trie-map$(EXEEXT) packed-trie-state-custom$(EXEEXT) \ + packed-trie-state-int$(EXEEXT) point-quad-tree$(EXEEXT) \ + segment-tree$(EXEEXT) trie-map$(EXEEXT) rtree-simple$(EXEEXT) \ + rtree-erase$(EXEEXT) rtree-medium$(EXEEXT) \ + rtree-medium-bulkload$(EXEEXT) +TESTS = flat-segment-tree$(EXEEXT) flat-segment-tree-itrs$(EXEEXT) \ + multi-type-matrix$(EXEEXT) packed-trie-map$(EXEEXT) \ + packed-trie-state-custom$(EXEEXT) \ + packed-trie-state-int$(EXEEXT) point-quad-tree$(EXEEXT) \ + segment-tree$(EXEEXT) trie-map$(EXEEXT) rtree-simple$(EXEEXT) \ + rtree-erase$(EXEEXT) rtree-medium$(EXEEXT) \ + rtree-medium-bulkload$(EXEEXT) +subdir = example +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_17.m4 \ + $(top_srcdir)/m4/m4_ax_valgrind_check.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am_flat_segment_tree_OBJECTS = flat_segment_tree.$(OBJEXT) +flat_segment_tree_OBJECTS = $(am_flat_segment_tree_OBJECTS) +flat_segment_tree_LDADD = $(LDADD) +am_flat_segment_tree_itrs_OBJECTS = flat_segment_tree_itrs.$(OBJEXT) +flat_segment_tree_itrs_OBJECTS = $(am_flat_segment_tree_itrs_OBJECTS) +flat_segment_tree_itrs_LDADD = $(LDADD) +am_multi_type_matrix_OBJECTS = multi_type_matrix.$(OBJEXT) +multi_type_matrix_OBJECTS = $(am_multi_type_matrix_OBJECTS) +multi_type_matrix_LDADD = $(LDADD) +am_packed_trie_map_OBJECTS = packed_trie_map.$(OBJEXT) +packed_trie_map_OBJECTS = $(am_packed_trie_map_OBJECTS) +packed_trie_map_LDADD = $(LDADD) +am_packed_trie_state_custom_OBJECTS = \ + packed_trie_state_custom.$(OBJEXT) +packed_trie_state_custom_OBJECTS = \ + $(am_packed_trie_state_custom_OBJECTS) +packed_trie_state_custom_LDADD = $(LDADD) +am_packed_trie_state_int_OBJECTS = packed_trie_state_int.$(OBJEXT) +packed_trie_state_int_OBJECTS = $(am_packed_trie_state_int_OBJECTS) +packed_trie_state_int_LDADD = $(LDADD) +am_point_quad_tree_OBJECTS = point_quad_tree.$(OBJEXT) +point_quad_tree_OBJECTS = $(am_point_quad_tree_OBJECTS) +point_quad_tree_LDADD = $(LDADD) +am_rtree_erase_OBJECTS = rtree_erase.$(OBJEXT) +rtree_erase_OBJECTS = $(am_rtree_erase_OBJECTS) +rtree_erase_LDADD = $(LDADD) +am_rtree_medium_OBJECTS = rtree_medium.$(OBJEXT) +rtree_medium_OBJECTS = $(am_rtree_medium_OBJECTS) +rtree_medium_LDADD = $(LDADD) +am_rtree_medium_bulkload_OBJECTS = rtree_medium_bulkload.$(OBJEXT) +rtree_medium_bulkload_OBJECTS = $(am_rtree_medium_bulkload_OBJECTS) +rtree_medium_bulkload_LDADD = $(LDADD) +am_rtree_simple_OBJECTS = rtree_simple.$(OBJEXT) +rtree_simple_OBJECTS = $(am_rtree_simple_OBJECTS) +rtree_simple_LDADD = $(LDADD) +am_segment_tree_OBJECTS = segment_tree.$(OBJEXT) +segment_tree_OBJECTS = $(am_segment_tree_OBJECTS) +segment_tree_LDADD = $(LDADD) +am_trie_map_OBJECTS = trie_map.$(OBJEXT) +trie_map_OBJECTS = $(am_trie_map_OBJECTS) +trie_map_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/flat_segment_tree.Po \ + ./$(DEPDIR)/flat_segment_tree_itrs.Po \ + ./$(DEPDIR)/multi_type_matrix.Po \ + ./$(DEPDIR)/packed_trie_map.Po \ + ./$(DEPDIR)/packed_trie_state_custom.Po \ + ./$(DEPDIR)/packed_trie_state_int.Po \ + ./$(DEPDIR)/point_quad_tree.Po ./$(DEPDIR)/rtree_erase.Po \ + ./$(DEPDIR)/rtree_medium.Po \ + ./$(DEPDIR)/rtree_medium_bulkload.Po \ + ./$(DEPDIR)/rtree_simple.Po ./$(DEPDIR)/segment_tree.Po \ + ./$(DEPDIR)/trie_map.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(flat_segment_tree_SOURCES) \ + $(flat_segment_tree_itrs_SOURCES) $(multi_type_matrix_SOURCES) \ + $(packed_trie_map_SOURCES) $(packed_trie_state_custom_SOURCES) \ + $(packed_trie_state_int_SOURCES) $(point_quad_tree_SOURCES) \ + $(rtree_erase_SOURCES) $(rtree_medium_SOURCES) \ + $(rtree_medium_bulkload_SOURCES) $(rtree_simple_SOURCES) \ + $(segment_tree_SOURCES) $(trie_map_SOURCES) +DIST_SOURCES = $(flat_segment_tree_SOURCES) \ + $(flat_segment_tree_itrs_SOURCES) $(multi_type_matrix_SOURCES) \ + $(packed_trie_map_SOURCES) $(packed_trie_state_custom_SOURCES) \ + $(packed_trie_state_int_SOURCES) $(point_quad_tree_SOURCES) \ + $(rtree_erase_SOURCES) $(rtree_medium_SOURCES) \ + $(rtree_medium_bulkload_SOURCES) $(rtree_simple_SOURCES) \ + $(segment_tree_SOURCES) $(trie_map_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + check recheck distdir distdir-am +am__extra_recursive_targets = check-valgrind-recursive \ + check-valgrind-memcheck-recursive \ + check-valgrind-helgrind-recursive check-valgrind-drd-recursive \ + check-valgrind-sgcheck-recursive +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +API_VERSION = @API_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_NODEBUG = @CPPFLAGS_NODEBUG@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXXFLAGS_UNITTESTS = @CXXFLAGS_UNITTESTS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOXYGEN = @DOXYGEN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ENABLE_VALGRIND_drd = @ENABLE_VALGRIND_drd@ +ENABLE_VALGRIND_helgrind = @ENABLE_VALGRIND_helgrind@ +ENABLE_VALGRIND_memcheck = @ENABLE_VALGRIND_memcheck@ +ENABLE_VALGRIND_sgcheck = @ENABLE_VALGRIND_sgcheck@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +EXPECT = @EXPECT@ +GDB = @GDB@ +HAVE_CXX17 = @HAVE_CXX17@ +INCDIR = @INCDIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MISCDIR = @MISCDIR@ +MKDIR_P = @MKDIR_P@ +OBJDIR = @OBJDIR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +QUICKCHECKDIR = @QUICKCHECKDIR@ +RUNTEST_BIN = @RUNTEST_BIN@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINX = @SPHINX@ +STRIP = @STRIP@ +VALGRIND = @VALGRIND@ +VALGRIND_ENABLED = @VALGRIND_ENABLED@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +valgrind_enabled_tools = @valgrind_enabled_tools@ +valgrind_tools = @valgrind_tools@ +SUBDIRS = multi_type_vector +AM_CPPFLAGS = -I$(top_srcdir)/include -DNDEBUG +flat_segment_tree_SOURCES = flat_segment_tree.cpp +flat_segment_tree_itrs_SOURCES = flat_segment_tree_itrs.cpp +multi_type_matrix_SOURCES = multi_type_matrix.cpp +packed_trie_map_SOURCES = packed_trie_map.cpp +packed_trie_state_custom_SOURCES = packed_trie_state_custom.cpp +packed_trie_state_int_SOURCES = packed_trie_state_int.cpp +point_quad_tree_SOURCES = point_quad_tree.cpp +segment_tree_SOURCES = segment_tree.cpp +trie_map_SOURCES = trie_map.cpp +rtree_simple_SOURCES = rtree_simple.cpp +rtree_erase_SOURCES = rtree_erase.cpp +rtree_medium_SOURCES = rtree_medium.cpp +rtree_medium_bulkload_SOURCES = rtree_medium_bulkload.cpp +TEST_ARTIFACTS = \ + *.svg \ + us-presidents.bin \ + cities.bin + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cpp .log .o .obj .test .test$(EXEEXT) .trs +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign example/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +flat-segment-tree$(EXEEXT): $(flat_segment_tree_OBJECTS) $(flat_segment_tree_DEPENDENCIES) $(EXTRA_flat_segment_tree_DEPENDENCIES) + @rm -f flat-segment-tree$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(flat_segment_tree_OBJECTS) $(flat_segment_tree_LDADD) $(LIBS) + +flat-segment-tree-itrs$(EXEEXT): $(flat_segment_tree_itrs_OBJECTS) $(flat_segment_tree_itrs_DEPENDENCIES) $(EXTRA_flat_segment_tree_itrs_DEPENDENCIES) + @rm -f flat-segment-tree-itrs$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(flat_segment_tree_itrs_OBJECTS) $(flat_segment_tree_itrs_LDADD) $(LIBS) + +multi-type-matrix$(EXEEXT): $(multi_type_matrix_OBJECTS) $(multi_type_matrix_DEPENDENCIES) $(EXTRA_multi_type_matrix_DEPENDENCIES) + @rm -f multi-type-matrix$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(multi_type_matrix_OBJECTS) $(multi_type_matrix_LDADD) $(LIBS) + +packed-trie-map$(EXEEXT): $(packed_trie_map_OBJECTS) $(packed_trie_map_DEPENDENCIES) $(EXTRA_packed_trie_map_DEPENDENCIES) + @rm -f packed-trie-map$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(packed_trie_map_OBJECTS) $(packed_trie_map_LDADD) $(LIBS) + +packed-trie-state-custom$(EXEEXT): $(packed_trie_state_custom_OBJECTS) $(packed_trie_state_custom_DEPENDENCIES) $(EXTRA_packed_trie_state_custom_DEPENDENCIES) + @rm -f packed-trie-state-custom$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(packed_trie_state_custom_OBJECTS) $(packed_trie_state_custom_LDADD) $(LIBS) + +packed-trie-state-int$(EXEEXT): $(packed_trie_state_int_OBJECTS) $(packed_trie_state_int_DEPENDENCIES) $(EXTRA_packed_trie_state_int_DEPENDENCIES) + @rm -f packed-trie-state-int$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(packed_trie_state_int_OBJECTS) $(packed_trie_state_int_LDADD) $(LIBS) + +point-quad-tree$(EXEEXT): $(point_quad_tree_OBJECTS) $(point_quad_tree_DEPENDENCIES) $(EXTRA_point_quad_tree_DEPENDENCIES) + @rm -f point-quad-tree$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(point_quad_tree_OBJECTS) $(point_quad_tree_LDADD) $(LIBS) + +rtree-erase$(EXEEXT): $(rtree_erase_OBJECTS) $(rtree_erase_DEPENDENCIES) $(EXTRA_rtree_erase_DEPENDENCIES) + @rm -f rtree-erase$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(rtree_erase_OBJECTS) $(rtree_erase_LDADD) $(LIBS) + +rtree-medium$(EXEEXT): $(rtree_medium_OBJECTS) $(rtree_medium_DEPENDENCIES) $(EXTRA_rtree_medium_DEPENDENCIES) + @rm -f rtree-medium$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(rtree_medium_OBJECTS) $(rtree_medium_LDADD) $(LIBS) + +rtree-medium-bulkload$(EXEEXT): $(rtree_medium_bulkload_OBJECTS) $(rtree_medium_bulkload_DEPENDENCIES) $(EXTRA_rtree_medium_bulkload_DEPENDENCIES) + @rm -f rtree-medium-bulkload$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(rtree_medium_bulkload_OBJECTS) $(rtree_medium_bulkload_LDADD) $(LIBS) + +rtree-simple$(EXEEXT): $(rtree_simple_OBJECTS) $(rtree_simple_DEPENDENCIES) $(EXTRA_rtree_simple_DEPENDENCIES) + @rm -f rtree-simple$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(rtree_simple_OBJECTS) $(rtree_simple_LDADD) $(LIBS) + +segment-tree$(EXEEXT): $(segment_tree_OBJECTS) $(segment_tree_DEPENDENCIES) $(EXTRA_segment_tree_DEPENDENCIES) + @rm -f segment-tree$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(segment_tree_OBJECTS) $(segment_tree_LDADD) $(LIBS) + +trie-map$(EXEEXT): $(trie_map_OBJECTS) $(trie_map_DEPENDENCIES) $(EXTRA_trie_map_DEPENDENCIES) + @rm -f trie-map$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(trie_map_OBJECTS) $(trie_map_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flat_segment_tree.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flat_segment_tree_itrs.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_type_matrix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packed_trie_map.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packed_trie_state_custom.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packed_trie_state_int.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point_quad_tree.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtree_erase.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtree_medium.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtree_medium_bulkload.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtree_simple.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/segment_tree.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trie_map.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" +check-valgrind-local: +check-valgrind-memcheck-local: +check-valgrind-helgrind-local: +check-valgrind-drd-local: +check-valgrind-sgcheck-local: + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +flat-segment-tree.log: flat-segment-tree$(EXEEXT) + @p='flat-segment-tree$(EXEEXT)'; \ + b='flat-segment-tree'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +flat-segment-tree-itrs.log: flat-segment-tree-itrs$(EXEEXT) + @p='flat-segment-tree-itrs$(EXEEXT)'; \ + b='flat-segment-tree-itrs'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +multi-type-matrix.log: multi-type-matrix$(EXEEXT) + @p='multi-type-matrix$(EXEEXT)'; \ + b='multi-type-matrix'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +packed-trie-map.log: packed-trie-map$(EXEEXT) + @p='packed-trie-map$(EXEEXT)'; \ + b='packed-trie-map'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +packed-trie-state-custom.log: packed-trie-state-custom$(EXEEXT) + @p='packed-trie-state-custom$(EXEEXT)'; \ + b='packed-trie-state-custom'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +packed-trie-state-int.log: packed-trie-state-int$(EXEEXT) + @p='packed-trie-state-int$(EXEEXT)'; \ + b='packed-trie-state-int'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +point-quad-tree.log: point-quad-tree$(EXEEXT) + @p='point-quad-tree$(EXEEXT)'; \ + b='point-quad-tree'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +segment-tree.log: segment-tree$(EXEEXT) + @p='segment-tree$(EXEEXT)'; \ + b='segment-tree'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +trie-map.log: trie-map$(EXEEXT) + @p='trie-map$(EXEEXT)'; \ + b='trie-map'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +rtree-simple.log: rtree-simple$(EXEEXT) + @p='rtree-simple$(EXEEXT)'; \ + b='rtree-simple'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +rtree-erase.log: rtree-erase$(EXEEXT) + @p='rtree-erase$(EXEEXT)'; \ + b='rtree-erase'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +rtree-medium.log: rtree-medium$(EXEEXT) + @p='rtree-medium$(EXEEXT)'; \ + b='rtree-medium'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +rtree-medium-bulkload.log: rtree-medium-bulkload$(EXEEXT) + @p='rtree-medium-bulkload$(EXEEXT)'; \ + b='rtree-medium-bulkload'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +check-valgrind: check-valgrind-recursive + +check-valgrind-am: check-valgrind-local + +check-valgrind-drd: check-valgrind-drd-recursive + +check-valgrind-drd-am: check-valgrind-drd-local + +check-valgrind-helgrind: check-valgrind-helgrind-recursive + +check-valgrind-helgrind-am: check-valgrind-helgrind-local + +check-valgrind-memcheck: check-valgrind-memcheck-recursive + +check-valgrind-memcheck-am: check-valgrind-memcheck-local + +check-valgrind-sgcheck: check-valgrind-sgcheck-recursive + +check-valgrind-sgcheck-am: check-valgrind-sgcheck-local + +clean: clean-recursive + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/flat_segment_tree.Po + -rm -f ./$(DEPDIR)/flat_segment_tree_itrs.Po + -rm -f ./$(DEPDIR)/multi_type_matrix.Po + -rm -f ./$(DEPDIR)/packed_trie_map.Po + -rm -f ./$(DEPDIR)/packed_trie_state_custom.Po + -rm -f ./$(DEPDIR)/packed_trie_state_int.Po + -rm -f ./$(DEPDIR)/point_quad_tree.Po + -rm -f ./$(DEPDIR)/rtree_erase.Po + -rm -f ./$(DEPDIR)/rtree_medium.Po + -rm -f ./$(DEPDIR)/rtree_medium_bulkload.Po + -rm -f ./$(DEPDIR)/rtree_simple.Po + -rm -f ./$(DEPDIR)/segment_tree.Po + -rm -f ./$(DEPDIR)/trie_map.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/flat_segment_tree.Po + -rm -f ./$(DEPDIR)/flat_segment_tree_itrs.Po + -rm -f ./$(DEPDIR)/multi_type_matrix.Po + -rm -f ./$(DEPDIR)/packed_trie_map.Po + -rm -f ./$(DEPDIR)/packed_trie_state_custom.Po + -rm -f ./$(DEPDIR)/packed_trie_state_int.Po + -rm -f ./$(DEPDIR)/point_quad_tree.Po + -rm -f ./$(DEPDIR)/rtree_erase.Po + -rm -f ./$(DEPDIR)/rtree_medium.Po + -rm -f ./$(DEPDIR)/rtree_medium_bulkload.Po + -rm -f ./$(DEPDIR)/rtree_simple.Po + -rm -f ./$(DEPDIR)/segment_tree.Po + -rm -f ./$(DEPDIR)/trie_map.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(am__recursive_targets) check-am install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-TESTS check-am check-valgrind-am \ + check-valgrind-drd-am check-valgrind-drd-local \ + check-valgrind-helgrind-am check-valgrind-helgrind-local \ + check-valgrind-local check-valgrind-memcheck-am \ + check-valgrind-memcheck-local check-valgrind-sgcheck-am \ + check-valgrind-sgcheck-local clean clean-generic clean-local \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am recheck tags tags-am \ + uninstall uninstall-am + +.PRECIOUS: Makefile + + +clean-local: + rm -f $(TESTS) $(TEST_ARTIFACTS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/example/flat_segment_tree.cpp b/example/flat_segment_tree.cpp new file mode 100644 index 0000000..deb96bb --- /dev/null +++ b/example/flat_segment_tree.cpp @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/flat_segment_tree.hpp> +#include <iostream> + +int main() try +{ + //!code-start: type + using fst_type = mdds::flat_segment_tree<long, int>; + //!code-end: type + + //!code-start: instance + // Define the begin and end points of the whole segment, and the default + // value. + fst_type db(0, 500, 0); + //!code-end: instance + + //!code-start: insert-1 + db.insert_front(10, 20, 10); + db.insert_back(50, 70, 15); + //!code-end: insert-1 + + //!code-start: insert-2 + db.insert_back(60, 65, 5); + //!code-end: insert-2 + + //!code-start: linear-search + // Perform linear search. This doesn't require the tree to be built ahead + // of time. + if (auto it = db.search(15); it != db.end()) + { + auto segment = it.to_segment(); + std::cout << "The value at 15 is " << segment->value + << ", and this segment spans from " << segment->start << " to " + << segment->end << std::endl; + } + //!code-end: linear-search + + //!code-start: tree-search + // Don't forget to build tree before calling search_tree(). + db.build_tree(); + + // Perform tree search. Tree search is generally a lot faster than linear + // search, but requires the tree to be built ahead of time. + if (auto it = db.search_tree(62); it != db.end()) + { + auto segment = it.to_segment(); + std::cout << "The value at 62 is " << segment->value + << ", and this segment spans from " << segment->start << " to " + << segment->end << std::endl; + } + //!code-end: tree-search +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/flat_segment_tree_itrs.cpp b/example/flat_segment_tree_itrs.cpp new file mode 100644 index 0000000..5a1b385 --- /dev/null +++ b/example/flat_segment_tree_itrs.cpp @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/flat_segment_tree.hpp> +#include <iostream> + +using fst_type = mdds::flat_segment_tree<long, int>; + +void iterate_nodes(const fst_type& db) +{ + //!code-start: iterate-nodes + for (auto it = db.begin(); it != db.end(); ++it) + { + std::cout << "key: " << it->first << "; value: " << it->second << std::endl; + } + //!code-end: iterate-nodes +} + +void loop_nodes(const fst_type& db) +{ + //!code-start: loop-nodes + for (const auto& node : db) + { + std::cout << "key: " << node.first << "; value: " << node.second << std::endl; + } + //!code-end: loop-nodes +} + +void iterate_segments(const fst_type& db) +{ + //!code-start: iterate-segments + for (auto it = db.begin_segment(); it != db.end_segment(); ++it) + { + std::cout << "start: " << it->start << "; end: " << it->end << "; value: " << it->value << std::endl; + } + //!code-end: iterate-segments +} + +void loop_segments(const fst_type& db) +{ + //!code-start: loop-segments + for (const auto& segment : db.segment_range()) + { + std::cout << "start: " << segment.start << "; end: " << segment.end << "; value: " << segment.value << std::endl; + } + //!code-end: loop-segments +} + +int main() +{ + fst_type db(0, 500, 0); + + db.insert_front(10, 20, 10); + db.insert_back(50, 70, 15); + db.insert_back(60, 65, 5); + + iterate_nodes(db); + loop_nodes(db); + iterate_segments(db); + loop_segments(db); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_matrix.cpp b/example/multi_type_matrix.cpp new file mode 100644 index 0000000..4901f0d --- /dev/null +++ b/example/multi_type_matrix.cpp @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/multi_type_matrix.hpp> +#include <vector> + +typedef mdds::multi_type_matrix<mdds::mtm::std_string_traits> mtm_type; + +int main() try +{ + // Create a 3x3 matrix with empty elements. + mtm_type mx(3, 3); + + // Store values of four different types. + mx.set(0, 0, 1.1); // numeric value (double) + mx.set(1, 0, std::string("text")); // string value + mx.set(0, 1, true); // boolean value + mx.set(1, 1, int(12)); // integer value + + std::vector<double> values = { + 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9 + }; + + // Set values for all elements in one step. + mx.set(0, 0, values.begin(), values.end()); + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/Makefile.am b/example/multi_type_vector/Makefile.am new file mode 100644 index 0000000..64dc5d7 --- /dev/null +++ b/example/multi_type_vector/Makefile.am @@ -0,0 +1,37 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include -DNDEBUG + +EXTRA_PROGRAMS = \ + mtv-collection \ + basic \ + custom-value-types \ + custom-value-types-custom-store \ + debug-trace \ + element-block1 \ + standard-custom-store \ + event1 \ + pos-hint + +mtv_collection_SOURCES = mtv_collection.cpp +basic_SOURCES = basic.cpp +custom_value_types_SOURCES = custom_value_types.cpp +custom_value_types_custom_store_SOURCES = custom_value_types_custom_store.cpp +debug_trace_SOURCES = debug_trace.cpp +element_block1_SOURCES = element_block1.cpp +standard_custom_store_SOURCES = standard_custom_store.cpp +event1_SOURCES = event1.cpp +pos_hint_SOURCES = pos_hint.cpp + +TESTS = \ + mtv-collection \ + basic \ + custom-value-types \ + custom-value-types-custom-store \ + debug-trace \ + element-block1 \ + standard-custom-store \ + event1 \ + pos-hint + +clean-local: + rm -f $(TESTS) diff --git a/example/multi_type_vector/Makefile.in b/example/multi_type_vector/Makefile.in new file mode 100644 index 0000000..4dc2132 --- /dev/null +++ b/example/multi_type_vector/Makefile.in @@ -0,0 +1,1129 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +EXTRA_PROGRAMS = mtv-collection$(EXEEXT) basic$(EXEEXT) \ + custom-value-types$(EXEEXT) \ + custom-value-types-custom-store$(EXEEXT) debug-trace$(EXEEXT) \ + element-block1$(EXEEXT) standard-custom-store$(EXEEXT) \ + event1$(EXEEXT) pos-hint$(EXEEXT) +TESTS = mtv-collection$(EXEEXT) basic$(EXEEXT) \ + custom-value-types$(EXEEXT) \ + custom-value-types-custom-store$(EXEEXT) debug-trace$(EXEEXT) \ + element-block1$(EXEEXT) standard-custom-store$(EXEEXT) \ + event1$(EXEEXT) pos-hint$(EXEEXT) +subdir = example/multi_type_vector +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_cxx_compile_stdcxx_17.m4 \ + $(top_srcdir)/m4/m4_ax_valgrind_check.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am_basic_OBJECTS = basic.$(OBJEXT) +basic_OBJECTS = $(am_basic_OBJECTS) +basic_LDADD = $(LDADD) +am_custom_value_types_OBJECTS = custom_value_types.$(OBJEXT) +custom_value_types_OBJECTS = $(am_custom_value_types_OBJECTS) +custom_value_types_LDADD = $(LDADD) +am_custom_value_types_custom_store_OBJECTS = \ + custom_value_types_custom_store.$(OBJEXT) +custom_value_types_custom_store_OBJECTS = \ + $(am_custom_value_types_custom_store_OBJECTS) +custom_value_types_custom_store_LDADD = $(LDADD) +am_debug_trace_OBJECTS = debug_trace.$(OBJEXT) +debug_trace_OBJECTS = $(am_debug_trace_OBJECTS) +debug_trace_LDADD = $(LDADD) +am_element_block1_OBJECTS = element_block1.$(OBJEXT) +element_block1_OBJECTS = $(am_element_block1_OBJECTS) +element_block1_LDADD = $(LDADD) +am_event1_OBJECTS = event1.$(OBJEXT) +event1_OBJECTS = $(am_event1_OBJECTS) +event1_LDADD = $(LDADD) +am_mtv_collection_OBJECTS = mtv_collection.$(OBJEXT) +mtv_collection_OBJECTS = $(am_mtv_collection_OBJECTS) +mtv_collection_LDADD = $(LDADD) +am_pos_hint_OBJECTS = pos_hint.$(OBJEXT) +pos_hint_OBJECTS = $(am_pos_hint_OBJECTS) +pos_hint_LDADD = $(LDADD) +am_standard_custom_store_OBJECTS = standard_custom_store.$(OBJEXT) +standard_custom_store_OBJECTS = $(am_standard_custom_store_OBJECTS) +standard_custom_store_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/basic.Po \ + ./$(DEPDIR)/custom_value_types.Po \ + ./$(DEPDIR)/custom_value_types_custom_store.Po \ + ./$(DEPDIR)/debug_trace.Po ./$(DEPDIR)/element_block1.Po \ + ./$(DEPDIR)/event1.Po ./$(DEPDIR)/mtv_collection.Po \ + ./$(DEPDIR)/pos_hint.Po ./$(DEPDIR)/standard_custom_store.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(basic_SOURCES) $(custom_value_types_SOURCES) \ + $(custom_value_types_custom_store_SOURCES) \ + $(debug_trace_SOURCES) $(element_block1_SOURCES) \ + $(event1_SOURCES) $(mtv_collection_SOURCES) \ + $(pos_hint_SOURCES) $(standard_custom_store_SOURCES) +DIST_SOURCES = $(basic_SOURCES) $(custom_value_types_SOURCES) \ + $(custom_value_types_custom_store_SOURCES) \ + $(debug_trace_SOURCES) $(element_block1_SOURCES) \ + $(event1_SOURCES) $(mtv_collection_SOURCES) \ + $(pos_hint_SOURCES) $(standard_custom_store_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__extra_recursive_targets = check-valgrind-recursive \ + check-valgrind-memcheck-recursive \ + check-valgrind-helgrind-recursive check-valgrind-drd-recursive \ + check-valgrind-sgcheck-recursive +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +API_VERSION = @API_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_NODEBUG = @CPPFLAGS_NODEBUG@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXXFLAGS_UNITTESTS = @CXXFLAGS_UNITTESTS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOXYGEN = @DOXYGEN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ENABLE_VALGRIND_drd = @ENABLE_VALGRIND_drd@ +ENABLE_VALGRIND_helgrind = @ENABLE_VALGRIND_helgrind@ +ENABLE_VALGRIND_memcheck = @ENABLE_VALGRIND_memcheck@ +ENABLE_VALGRIND_sgcheck = @ENABLE_VALGRIND_sgcheck@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +EXPECT = @EXPECT@ +GDB = @GDB@ +HAVE_CXX17 = @HAVE_CXX17@ +INCDIR = @INCDIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MISCDIR = @MISCDIR@ +MKDIR_P = @MKDIR_P@ +OBJDIR = @OBJDIR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +QUICKCHECKDIR = @QUICKCHECKDIR@ +RUNTEST_BIN = @RUNTEST_BIN@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINX = @SPHINX@ +STRIP = @STRIP@ +VALGRIND = @VALGRIND@ +VALGRIND_ENABLED = @VALGRIND_ENABLED@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +valgrind_enabled_tools = @valgrind_enabled_tools@ +valgrind_tools = @valgrind_tools@ +AM_CPPFLAGS = -I$(top_srcdir)/include -DNDEBUG +mtv_collection_SOURCES = mtv_collection.cpp +basic_SOURCES = basic.cpp +custom_value_types_SOURCES = custom_value_types.cpp +custom_value_types_custom_store_SOURCES = custom_value_types_custom_store.cpp +debug_trace_SOURCES = debug_trace.cpp +element_block1_SOURCES = element_block1.cpp +standard_custom_store_SOURCES = standard_custom_store.cpp +event1_SOURCES = event1.cpp +pos_hint_SOURCES = pos_hint.cpp +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .log .o .obj .test .test$(EXEEXT) .trs +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/multi_type_vector/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign example/multi_type_vector/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +basic$(EXEEXT): $(basic_OBJECTS) $(basic_DEPENDENCIES) $(EXTRA_basic_DEPENDENCIES) + @rm -f basic$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(basic_OBJECTS) $(basic_LDADD) $(LIBS) + +custom-value-types$(EXEEXT): $(custom_value_types_OBJECTS) $(custom_value_types_DEPENDENCIES) $(EXTRA_custom_value_types_DEPENDENCIES) + @rm -f custom-value-types$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(custom_value_types_OBJECTS) $(custom_value_types_LDADD) $(LIBS) + +custom-value-types-custom-store$(EXEEXT): $(custom_value_types_custom_store_OBJECTS) $(custom_value_types_custom_store_DEPENDENCIES) $(EXTRA_custom_value_types_custom_store_DEPENDENCIES) + @rm -f custom-value-types-custom-store$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(custom_value_types_custom_store_OBJECTS) $(custom_value_types_custom_store_LDADD) $(LIBS) + +debug-trace$(EXEEXT): $(debug_trace_OBJECTS) $(debug_trace_DEPENDENCIES) $(EXTRA_debug_trace_DEPENDENCIES) + @rm -f debug-trace$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(debug_trace_OBJECTS) $(debug_trace_LDADD) $(LIBS) + +element-block1$(EXEEXT): $(element_block1_OBJECTS) $(element_block1_DEPENDENCIES) $(EXTRA_element_block1_DEPENDENCIES) + @rm -f element-block1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(element_block1_OBJECTS) $(element_block1_LDADD) $(LIBS) + +event1$(EXEEXT): $(event1_OBJECTS) $(event1_DEPENDENCIES) $(EXTRA_event1_DEPENDENCIES) + @rm -f event1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(event1_OBJECTS) $(event1_LDADD) $(LIBS) + +mtv-collection$(EXEEXT): $(mtv_collection_OBJECTS) $(mtv_collection_DEPENDENCIES) $(EXTRA_mtv_collection_DEPENDENCIES) + @rm -f mtv-collection$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(mtv_collection_OBJECTS) $(mtv_collection_LDADD) $(LIBS) + +pos-hint$(EXEEXT): $(pos_hint_OBJECTS) $(pos_hint_DEPENDENCIES) $(EXTRA_pos_hint_DEPENDENCIES) + @rm -f pos-hint$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(pos_hint_OBJECTS) $(pos_hint_LDADD) $(LIBS) + +standard-custom-store$(EXEEXT): $(standard_custom_store_OBJECTS) $(standard_custom_store_DEPENDENCIES) $(EXTRA_standard_custom_store_DEPENDENCIES) + @rm -f standard-custom-store$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(standard_custom_store_OBJECTS) $(standard_custom_store_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/custom_value_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/custom_value_types_custom_store.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug_trace.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/element_block1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtv_collection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pos_hint.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/standard_custom_store.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +check-valgrind-local: +check-valgrind-memcheck-local: +check-valgrind-helgrind-local: +check-valgrind-drd-local: +check-valgrind-sgcheck-local: + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +mtv-collection.log: mtv-collection$(EXEEXT) + @p='mtv-collection$(EXEEXT)'; \ + b='mtv-collection'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +basic.log: basic$(EXEEXT) + @p='basic$(EXEEXT)'; \ + b='basic'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +custom-value-types.log: custom-value-types$(EXEEXT) + @p='custom-value-types$(EXEEXT)'; \ + b='custom-value-types'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +custom-value-types-custom-store.log: custom-value-types-custom-store$(EXEEXT) + @p='custom-value-types-custom-store$(EXEEXT)'; \ + b='custom-value-types-custom-store'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +debug-trace.log: debug-trace$(EXEEXT) + @p='debug-trace$(EXEEXT)'; \ + b='debug-trace'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +element-block1.log: element-block1$(EXEEXT) + @p='element-block1$(EXEEXT)'; \ + b='element-block1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +standard-custom-store.log: standard-custom-store$(EXEEXT) + @p='standard-custom-store$(EXEEXT)'; \ + b='standard-custom-store'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +event1.log: event1$(EXEEXT) + @p='event1$(EXEEXT)'; \ + b='event1'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +pos-hint.log: pos-hint$(EXEEXT) + @p='pos-hint$(EXEEXT)'; \ + b='pos-hint'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +check-valgrind: check-valgrind-am + +check-valgrind-am: check-valgrind-local + +check-valgrind-drd: check-valgrind-drd-am + +check-valgrind-drd-am: check-valgrind-drd-local + +check-valgrind-helgrind: check-valgrind-helgrind-am + +check-valgrind-helgrind-am: check-valgrind-helgrind-local + +check-valgrind-memcheck: check-valgrind-memcheck-am + +check-valgrind-memcheck-am: check-valgrind-memcheck-local + +check-valgrind-sgcheck: check-valgrind-sgcheck-am + +check-valgrind-sgcheck-am: check-valgrind-sgcheck-local + +clean: clean-am + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/basic.Po + -rm -f ./$(DEPDIR)/custom_value_types.Po + -rm -f ./$(DEPDIR)/custom_value_types_custom_store.Po + -rm -f ./$(DEPDIR)/debug_trace.Po + -rm -f ./$(DEPDIR)/element_block1.Po + -rm -f ./$(DEPDIR)/event1.Po + -rm -f ./$(DEPDIR)/mtv_collection.Po + -rm -f ./$(DEPDIR)/pos_hint.Po + -rm -f ./$(DEPDIR)/standard_custom_store.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/basic.Po + -rm -f ./$(DEPDIR)/custom_value_types.Po + -rm -f ./$(DEPDIR)/custom_value_types_custom_store.Po + -rm -f ./$(DEPDIR)/debug_trace.Po + -rm -f ./$(DEPDIR)/element_block1.Po + -rm -f ./$(DEPDIR)/event1.Po + -rm -f ./$(DEPDIR)/mtv_collection.Po + -rm -f ./$(DEPDIR)/pos_hint.Po + -rm -f ./$(DEPDIR)/standard_custom_store.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ + check-am check-valgrind-am check-valgrind-drd-am \ + check-valgrind-drd-local check-valgrind-helgrind-am \ + check-valgrind-helgrind-local check-valgrind-local \ + check-valgrind-memcheck-am check-valgrind-memcheck-local \ + check-valgrind-sgcheck-am check-valgrind-sgcheck-local clean \ + clean-generic clean-local cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + recheck tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +clean-local: + rm -f $(TESTS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/example/multi_type_vector/basic.cpp b/example/multi_type_vector/basic.cpp new file mode 100644 index 0000000..75324e8 --- /dev/null +++ b/example/multi_type_vector/basic.cpp @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start +#include <mdds/multi_type_vector.hpp> +#include <iostream> +#include <vector> +#include <string> + +using std::cout; +using std::endl; + +using mtv_type = mdds::multi_type_vector<mdds::mtv::standard_element_blocks_traits>; + +template<typename BlockT> +void print_block(const mtv_type::value_type& v) +{ + for (const auto& elem : BlockT::range(*v.data)) + { + cout << " * " << elem << endl; + } +} + +int main() try +{ + mtv_type con(20); // Initialized with 20 empty elements. + + // Set values individually. + con.set(0, 1.1); + con.set(1, 1.2); + con.set(2, 1.3); + + // Set a sequence of values in one step. + std::vector<double> vals = { 10.1, 10.2, 10.3, 10.4, 10.5 }; + con.set(3, vals.begin(), vals.end()); + + // Set string values. + con.set<std::string>(10, "Andy"); + con.set<std::string>(11, "Bruce"); + con.set<std::string>(12, "Charlie"); + + // Iterate through all blocks and print all elements. + for (const auto& v : con) + { + switch (v.type) + { + case mdds::mtv::element_type_double: + { + cout << "numeric block of size " << v.size << endl; + print_block<mdds::mtv::double_element_block>(v); + break; + } + case mdds::mtv::element_type_string: + { + cout << "string block of size " << v.size << endl; + print_block<mdds::mtv::string_element_block>(v); + break; + } + case mdds::mtv::element_type_empty: + cout << "empty block of size " << v.size << endl; + cout << " - no data - " << endl; + default: + ; + } + } + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} +//!code-end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/custom_value_types.cpp b/example/multi_type_vector/custom_value_types.cpp new file mode 100644 index 0000000..3ee3c1b --- /dev/null +++ b/example/multi_type_vector/custom_value_types.cpp @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2022 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start: header +#include <mdds/multi_type_vector.hpp> +//!code-end: header + +#include <iostream> + +//!code-start: element-types +constexpr mdds::mtv::element_t custom_value1_type = mdds::mtv::element_type_user_start; +constexpr mdds::mtv::element_t custom_value2_type = mdds::mtv::element_type_user_start + 1; +constexpr mdds::mtv::element_t custom_value3_type = mdds::mtv::element_type_user_start + 2; +//!code-end: element-types + +//!code-start: custom-values +struct custom_value1 {}; +struct custom_value2 {}; + +using custom_value1_block = mdds::mtv::default_element_block<custom_value1_type, custom_value1>; +using custom_value2_block = mdds::mtv::default_element_block<custom_value2_type, custom_value2>; +//!code-end: custom-values + +//!code-start: custom-values-macro +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value1, custom_value1_type, custom_value1{}, custom_value1_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value2, custom_value2_type, custom_value2{}, custom_value2_block) +//!code-end: custom-values-macro + +//!code-start: custom-value-ns +namespace ns { + +struct custom_value3 {}; + +using custom_value3_block = mdds::mtv::default_element_block<custom_value3_type, custom_value3>; + +// This macro MUST be in the same namespace as that of the value type, in order for +// argument-dependent lookup to work properly during overload resolution. +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value3, custom_value2_type, custom_value3{}, custom_value3_block) + +} // namespace ns +//!code-end: custom-value-ns + +//!code-start: trait +struct my_custom_traits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs< + custom_value1_block, custom_value2_block, ns::custom_value3_block>; +}; +//!code-end: trait + +//!code-start: mtv-type +using mtv_type = mdds::multi_type_vector<my_custom_traits>; +//!code-end: mtv-type + +int main() try +{ + //!code-start: main + mtv_type con{}; // initialize it as empty container. + + // Push three values of different types to the end. + con.push_back(custom_value1{}); + con.push_back(custom_value2{}); + con.push_back(ns::custom_value3{}); + + auto v1 = con.get<custom_value1>(0); + auto v2 = con.get<custom_value2>(1); + auto v3 = con.get<ns::custom_value3>(2); + + std::cout << "is this custom_value1? " << std::is_same_v<decltype(v1), custom_value1> << std::endl; + std::cout << "is this custom_value2? " << std::is_same_v<decltype(v2), custom_value2> << std::endl; + std::cout << "is this ns::custom_value3? " << std::is_same_v<decltype(v3), ns::custom_value3> << std::endl; + //!code-end: main + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/example/multi_type_vector/custom_value_types_custom_store.cpp b/example/multi_type_vector/custom_value_types_custom_store.cpp new file mode 100644 index 0000000..7128684 --- /dev/null +++ b/example/multi_type_vector/custom_value_types_custom_store.cpp @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2022 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/multi_type_vector.hpp> + +#include <iostream> +#include <vector> +#include <deque> + +constexpr mdds::mtv::element_t custom_value1_type = mdds::mtv::element_type_user_start; +constexpr mdds::mtv::element_t custom_value2_type = mdds::mtv::element_type_user_start + 1; +constexpr mdds::mtv::element_t custom_value3_type = mdds::mtv::element_type_user_start + 2; + +struct custom_value1 {}; +struct custom_value2 {}; + +//!code-start: blocks-1-2 +using custom_value1_block = mdds::mtv::default_element_block< + custom_value1_type, custom_value1, std::vector>; + +using custom_value2_block = mdds::mtv::default_element_block< + custom_value2_type, custom_value2, std::deque>; +//!code-end: blocks-1-2 + +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value1, custom_value1_type, custom_value1{}, custom_value1_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value2, custom_value2_type, custom_value2{}, custom_value2_block) + +namespace ns { + +struct custom_value3 {}; + +//!code-start: block-3 +// This implicitly uses mdds::mtv::delayed_delete_vector. +using custom_value3_block = mdds::mtv::default_element_block< + custom_value3_type, custom_value3>; +//!code-end: block-3 + +// This macro MUST be in the same namespace as that of the value type, in order for +// argument-dependent lookup to work properly during overload resolution. +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(custom_value3, custom_value2_type, custom_value3{}, custom_value3_block) + +} // namespace ns + +struct my_custom_traits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs< + custom_value1_block, custom_value2_block, ns::custom_value3_block>; +}; + +using mtv_type = mdds::multi_type_vector<my_custom_traits>; + +int main() try +{ + //!code-start: main + std::cout << "custom_value1 stored in std::vector? " + << std::is_same_v<custom_value1_block::store_type, std::vector<custom_value1>> + << std::endl; + + std::cout << "custom_value2 stored in std::deque? " + << std::is_same_v<custom_value2_block::store_type, std::deque<custom_value2>> + << std::endl; + + std::cout << "ns::custom_value3 stored in delayed_delete_vector? " + << std::is_same_v<ns::custom_value3_block::store_type, mdds::mtv::delayed_delete_vector<ns::custom_value3>> + << std::endl; + //!code-end: main + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/example/multi_type_vector/debug_trace.cpp b/example/multi_type_vector/debug_trace.cpp new file mode 100644 index 0000000..6036a4a --- /dev/null +++ b/example/multi_type_vector/debug_trace.cpp @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2022 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start: header +#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1 +#include <mdds/multi_type_vector/soa/main.hpp> + +#include <iostream> +//!code-end: header + +//!code-start: types +namespace mtv = mdds::mtv; + +struct mtv_traits : public mtv::standard_element_blocks_traits +{ + static void trace(const mtv::trace_method_properties_t& props) + { + std::cout << "function:" << std::endl + << " name: " << props.function_name << std::endl + << " args: " << props.function_args << std::endl; + } +}; + +using mtv_type = mtv::soa::multi_type_vector<mtv_traits>; +//!code-end: types + +int main() try +{ + //!code-start: main + mtv_type db(10); + db.set<int32_t>(0, 12); + db.set<int8_t>(2, 34); + db.set<int16_t>(4, 56); + //!code-end: main + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/example/multi_type_vector/element_block1.cpp b/example/multi_type_vector/element_block1.cpp new file mode 100644 index 0000000..0f198c2 --- /dev/null +++ b/example/multi_type_vector/element_block1.cpp @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start +#include <mdds/multi_type_vector.hpp> +#include <iostream> + +using std::cout; +using std::endl; +using mdds::mtv::double_element_block; +using mdds::mtv::string_element_block; + +using mtv_type = mdds::multi_type_vector<mdds::mtv::standard_element_blocks_traits>; + +int main() try +{ + mtv_type db; // starts with an empty container. + + db.push_back(1.1); + db.push_back(1.2); + db.push_back(1.3); + db.push_back(1.4); + db.push_back(1.5); + + db.push_back(std::string("A")); + db.push_back(std::string("B")); + db.push_back(std::string("C")); + db.push_back(std::string("D")); + db.push_back(std::string("E")); + + // At this point, you have 2 blocks in the container. + cout << "block size: " << db.block_size() << endl; + cout << "--" << endl; + + // Get an iterator that points to the first block in the primary array. + mtv_type::const_iterator it = db.begin(); + + // Get a pointer to the raw array of the numeric element block using the + // 'data' method. + const double* p = double_element_block::data(*it->data); + + // Print the elements from this raw array pointer. + for (const double* p_end = p + it->size; p != p_end; ++p) + cout << *p << endl; + + cout << "--" << endl; + + ++it; // move to the next block, which is a string block. + + // Get a pointer to the raw array of the string element block. + const std::string* pz = string_element_block::data(*it->data); + + // Print out the string elements. + for (const std::string* pz_end = pz + it->size; pz != pz_end; ++pz) + cout << *pz << endl; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} +//!code-end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/event1.cpp b/example/multi_type_vector/event1.cpp new file mode 100644 index 0000000..44b8f28 --- /dev/null +++ b/example/multi_type_vector/event1.cpp @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start +#include <mdds/multi_type_vector.hpp> +#include <iostream> + +using std::cout; +using std::endl; + +class event_hdl +{ +public: + void element_block_acquired(mdds::mtv::base_element_block* block) + { + (void)block; + cout << " * element block acquired" << endl; + } + + void element_block_released(mdds::mtv::base_element_block* block) + { + (void)block; + cout << " * element block released" << endl; + } +}; + +struct trait : mdds::mtv::standard_element_blocks_traits +{ + using event_func = event_hdl; +}; + +using mtv_type = mdds::multi_type_vector<trait>; + +int main() try +{ + mtv_type db; // starts with an empty container. + + cout << "inserting string 'foo'..." << endl; + db.push_back(std::string("foo")); // creates a new string element block. + + cout << "inserting string 'bah'..." << endl; + db.push_back(std::string("bah")); // appends to an existing string block. + + cout << "inserting int 100..." << endl; + db.push_back(int(100)); // creates a new int element block. + + cout << "emptying the container..." << endl; + db.clear(); // releases both the string and int element blocks. + + cout << "exiting program..." << endl; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} +//!code-end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/mtv_collection.cpp b/example/multi_type_vector/mtv_collection.cpp new file mode 100644 index 0000000..6752539 --- /dev/null +++ b/example/multi_type_vector/mtv_collection.cpp @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/multi_type_vector.hpp> +#include <mdds/multi_type_vector/collection.hpp> + +#include <vector> +#include <iostream> + +void example1() +{ + //!code-start: declare + using mtv_type = mdds::multi_type_vector<mdds::mtv::standard_element_blocks_traits>; + using collection_type = mdds::mtv::collection<mtv_type>; + + std::vector<mtv_type> columns(5); + //!code-end: declare + + //!code-start: header-row + // Populate the header row. + const char* headers[] = { "ID", "Make", "Model", "Year", "Color" }; + size_t i = 0; + for (const char* v : headers) + columns[i++].push_back<std::string>(v); + //!code-end: header-row + + //!code-start: column-1 + // Fill column 1. + int c1_values[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; + + for (int v : c1_values) + columns[0].push_back(v); + //!code-end: column-1 + + //!code-start: column-2 + // Fill column 2. + const char* c2_values[] = + { + "Nissan", "Mercedes-Benz", "Nissan", "Suzuki", "Saab", "Subaru", "GMC", "Mercedes-Benz", "Toyota", "Nissan", + "Mazda", "Dodge", "Ford", "Bentley", "GMC", "Audi", "GMC", "Mercury", "Pontiac", "BMW", + }; + + for (const char* v : c2_values) + columns[1].push_back<std::string>(v); + //!code-end: column-2 + + //!code-start: column-3 + // Fill column 3. + const char* c3_values[] = + { + "Frontier", "W201", "Frontier", "Equator", "9-5", "Tribeca", "Yukon XL 2500", "E-Class", "Camry Hybrid", "Frontier", + "MX-5", "Ram Van 1500", "Edge", "Azure", "Sonoma Club Coupe", "S4", "3500 Club Coupe", "Villager", "Sunbird", "3 Series", + }; + + for (const char* v : c3_values) + columns[2].push_back<std::string>(v); + //!code-end: column-3 + + //!code-start: column-4 + // Fill column 4. Replace -1 with "unknown". + int32_t c4_values[] = + { + 1998, 1986, 2009, -1, -1, 2008, 2009, 2008, 2010, 2001, + 2008, 2000, -1, 2009, 1998, 2013, 1994, 2000, 1990, 1993, + }; + + for (int32_t v : c4_values) + { + if (v < 0) + // Insert a string value "unknown". + columns[3].push_back<std::string>("unknown"); + else + columns[3].push_back(v); + } + //!code-end: column-4 + + //!code-start: column-5 + // Fill column 5 + const char* c5_values[] = + { + "Turquoise", "Fuscia", "Teal", "Fuscia", "Green", "Khaki", "Pink", "Goldenrod", "Turquoise", "Yellow", + "Orange", "Goldenrod", "Fuscia", "Goldenrod", "Mauv", "Crimson", "Turquoise", "Teal", "Indigo", "LKhaki", + }; + + for (const char* v : c5_values) + columns[4].push_back<std::string>(v); + //!code-end: column-5 + + //!code-start: wrap + // Wrap the columns with the 'collection'... + collection_type rows(columns.begin(), columns.end()); + //!code-end: wrap + + //!code-start: traverse-row + // Traverse the tabular data in row-wise direction. + for (const auto& cell : rows) + { + if (cell.index > 0) + // Insert a column separator before each cell except for the ones in the first column. + std::cout << " | "; + + switch (cell.type) + { + // In this example, we use two element types only. + case mdds::mtv::element_type_int32: + std::cout << cell.get<mdds::mtv::int32_element_block>(); + break; + case mdds::mtv::element_type_string: + std::cout << cell.get<mdds::mtv::string_element_block>(); + break; + default: + std::cout << "???"; // The default case should not hit in this example. + } + + if (cell.index == 4) + // We are in the last column. Insert a line break. + std::cout << std::endl; + } + //!code-end: traverse-row + + //!code-start: limit-range + rows.set_collection_range(1, 2); // only columns 2 and 3. + rows.set_element_range(1, 10); // only rows 2 through 11. + //!code-end: limit-range + + std::cout << "--" << std::endl; + + //!code-start: traverse-row-range + for (const auto& cell : rows) + { + if (cell.index > 1) + // Insert a column separator before each cell except for the ones in the first column. + std::cout << " | "; + + switch (cell.type) + { + // In this example, we use two element types only. + case mdds::mtv::element_type_int32: + std::cout << cell.get<mdds::mtv::int32_element_block>(); + break; + case mdds::mtv::element_type_string: + std::cout << cell.get<mdds::mtv::string_element_block>(); + break; + default: + std::cout << "???"; // The default case should not hit in this example. + } + + if (cell.index == 2) + // We are in the last column. Insert a line break. + std::cout << std::endl; + } + //!code-end: traverse-row-range +} + +int main() try +{ + example1(); + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/pos_hint.cpp b/example/multi_type_vector/pos_hint.cpp new file mode 100644 index 0000000..aaae4c1 --- /dev/null +++ b/example/multi_type_vector/pos_hint.cpp @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/multi_type_vector.hpp> + +#include <iostream> +#include <string> +#include <chrono> + +namespace { + +class stack_printer +{ +public: + explicit stack_printer(const char* msg) : + m_msg(msg) + { + std::cout << m_msg << ": --begin" << std::endl; + m_start_time = get_time(); + } + + ~stack_printer() + { + double end_time = get_time(); + std::cout << m_msg << ": --end (duration: " << (end_time-m_start_time) << " sec)" << std::endl; + } + + void print_time(int line) const + { + double end_time = get_time(); + std::cout << m_msg << ": --(" << line << ") (duration: " << (end_time-m_start_time) << " sec)" << std::endl; + } + +private: + double get_time() const + { + unsigned long usec_since_epoch = + std::chrono::duration_cast<std::chrono::microseconds>( + std::chrono::system_clock::now().time_since_epoch()).count(); + + return usec_since_epoch / 1000000.0; + } + + std::string m_msg; + double m_start_time; +}; + +} + +void run_no_position_hint() +{ + stack_printer __stack_printer__("::run_no_position_hint"); + + //!code-start: no-pos-hint + using mtv_type = mdds::multi_type_vector<mdds::mtv::standard_element_blocks_traits>; + + size_t size = 50000; + + // Initialize the container with one empty block of size 50000. + mtv_type db(size); + + // Set non-empty value at every other logical position from top down. + for (size_t i = 0; i < size; ++i) + { + if (i % 2) + db.set<double>(i, 1.0); + } + //!code-end: no-pos-hint +} + +void run_with_position_hint() +{ + stack_printer __stack_printer__("::run_with_position_hint"); + + //!code-start: pos-hint + using mtv_type = mdds::multi_type_vector<mdds::mtv::standard_element_blocks_traits>; + + size_t size = 50000; + + // Initialize the container with one empty block of size 50000. + mtv_type db(size); + mtv_type::iterator pos = db.begin(); + + // Set non-empty value at every other logical position from top down. + for (size_t i = 0; i < size; ++i) + { + if (i % 2) + // Pass the position hint as the first argument, and receive a new + // one returned from the method for the next call. + pos = db.set<double>(pos, i, 1.0); + } + //!code-end: pos-hint +} + +int main() try +{ + run_no_position_hint(); + run_with_position_hint(); + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/multi_type_vector/standard_custom_store.cpp b/example/multi_type_vector/standard_custom_store.cpp new file mode 100644 index 0000000..2e66a50 --- /dev/null +++ b/example/multi_type_vector/standard_custom_store.cpp @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2022 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +//!code-start: header +#include <mdds/multi_type_vector/types.hpp> +#include <mdds/multi_type_vector/macro.hpp> + +#include <deque> +//!code-end: header + +#include <iostream> + +//!code-start: block-defs +// Define element ID's for the standard element types. +constexpr mdds::mtv::element_t my_doube_type_id = mdds::mtv::element_type_user_start; +constexpr mdds::mtv::element_t my_int32_type_id = mdds::mtv::element_type_user_start + 1; + +// Define the block types. +using my_double_block = mdds::mtv::default_element_block<my_doube_type_id, double, std::deque>; +using my_int32_block = mdds::mtv::default_element_block<my_int32_type_id, std::int32_t, std::deque>; + +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(double, my_doube_type_id, 0.0, my_double_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(std::int32_t, my_int32_type_id, 0, my_int32_block) +//!code-end: block-defs + +//!code-start: mtv-header +#define MDDS_MTV_USE_STANDARD_ELEMENT_BLOCKS 0 +#include <mdds/multi_type_vector/soa/main.hpp> +//!code-end: mtv-header + +//!code-start: mtv-def +struct my_custom_traits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs<my_double_block, my_int32_block>; +}; + +using mtv_type = mdds::mtv::soa::multi_type_vector<my_custom_traits>; +//!code-end: mtv-def + +int main() try +{ + //!code-start: main + mtv_type con(20); // Initialized with 20 empty elements. + + con.set<std::int32_t>(0, 234); + con.set<double>(1, 425.1); + //!code-end: main + + //!code-start: main-block-type + std::cout << "my_double_block: is std::deque its store type? " + << std::is_same_v<my_double_block::store_type, std::deque<double>> + << std::endl; + std::cout << "my_int32_block: is std::deque its store type? " + << std::is_same_v<my_int32_block::store_type, std::deque<std::int32_t>> + << std::endl; + //!code-end: main-block-type + + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/example/packed_trie_map.cpp b/example/packed_trie_map.cpp new file mode 100644 index 0000000..0111e46 --- /dev/null +++ b/example/packed_trie_map.cpp @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/global.hpp> // for MDDS_ASCII and MDDS_N_ELEMENTS +#include <mdds/trie_map.hpp> +#include <iostream> + +using std::cout; +using std::endl; + +int main() +{ + using trie_map_type = mdds::packed_trie_map<mdds::trie::std_string_traits, int>; + + // Entries must be known prior to creating the instance, and they must be + // sorted by the key in ascending order. + trie_map_type::entry entries[] = + { + { MDDS_ASCII("Apex"), 42214 }, + { MDDS_ASCII("Asheville"), 87236 }, + { MDDS_ASCII("Burlington"), 51510 }, + { MDDS_ASCII("Cary"), 151088 }, + { MDDS_ASCII("Chapel Hill"), 59635 }, + { MDDS_ASCII("Charlotte"), 792862 }, + { MDDS_ASCII("Concord"), 83506 }, + { MDDS_ASCII("Durham"), 245475 }, + { MDDS_ASCII("Fayetteville"), 204408 }, + { MDDS_ASCII("Gastonia"), 73209 }, + { MDDS_ASCII("Goldsboro"), 36306 }, + { MDDS_ASCII("Greensboro"), 279639 }, + { MDDS_ASCII("Greenville"), 89130 }, + { MDDS_ASCII("Hickory"), 40361 }, + { MDDS_ASCII("High Point"), 107741 }, + { MDDS_ASCII("Huntersville"), 50458 }, + { MDDS_ASCII("Jacksonville"), 69079 }, + { MDDS_ASCII("Kannapolis"), 44359 }, + { MDDS_ASCII("Raleigh"), 431746 }, + { MDDS_ASCII("Rocky Mount"), 56954 }, + { MDDS_ASCII("Wilmington"), 112067 }, + { MDDS_ASCII("Wilson"), 49628 }, + { MDDS_ASCII("Winston-Salem"), 236441 }, + }; + + // Cities in North Carolina and their populations in 2013. + trie_map_type nc_cities(entries, MDDS_N_ELEMENTS(entries)); + + cout << "Cities that start with 'Cha' and their populations:" << endl; + auto results = nc_cities.prefix_search("Cha"); + for (const auto& kv : results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + cout << "Cities that start with 'W' and their populations:" << endl; + results = nc_cities.prefix_search("W"); + for (const auto& kv : results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + cout << "Cities that start with 'C' and their populations:" << endl; + results = nc_cities.prefix_search("C"); + for (const auto& kv : results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + // Individual search. + auto it = nc_cities.find("Wilmington"); + cout << "Population of Wilmington: " << it->second << endl; + + // You get an end position iterator when the container doesn't have the + // specified key. + it = nc_cities.find("Asheboro"); + + cout << "Population of Asheboro: "; + + if (it == nc_cities.end()) + cout << "not found"; + else + cout << it->second; + + cout << endl; + + return EXIT_SUCCESS; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/packed_trie_state_custom.cpp b/example/packed_trie_state_custom.cpp new file mode 100644 index 0000000..666074e --- /dev/null +++ b/example/packed_trie_state_custom.cpp @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <iostream> +#include <fstream> +#include <mdds/trie_map.hpp> + +using std::cout; +using std::endl; + +enum affiliated_party_t : uint8_t +{ + unaffiliated = 0, + federalist, + democratic_republican, + democratic, + whig, + republican, + national_union, + republican_national_union, +}; + +struct us_president +{ + uint16_t year; + affiliated_party_t party; +}; + +std::ostream& operator<< (std::ostream& os, affiliated_party_t v) +{ + static const char* names[] = { + "Unaffiliated", + "Federalist", + "Democratic Republican", + "Democratic", + "Whig", + "Republican", + "National Union", + "Republican / National Union", + }; + + os << names[v]; + return os; +} + +bool operator== (const us_president& left, const us_president& right) +{ + return left.year == right.year && left.party == right.party; +} + +struct us_president_serializer +{ + union bin_buffer + { + char buffer[2]; + uint16_t i16; + affiliated_party_t party; + }; + + static constexpr bool variable_size = false; + static constexpr size_t value_size = 3; + + static void write(std::ostream& os, const us_president& v) + { + bin_buffer buf; + + // Write the year value first. + buf.i16 = v.year; + os.write(buf.buffer, 2); + + // Write the affiliated party value. + buf.party = v.party; + os.write(buf.buffer, 1); + } + + static void read(std::istream& is, size_t /*n*/, us_president& v) + { + // For a fixed-size value type, this should equal the defined value size. + assert(n == 3); + + bin_buffer buf; + + // Read the year value. + is.read(buf.buffer, 2); + v.year = buf.i16; + + // Read the affiliated party value. + is.read(buf.buffer, 1); + v.party = buf.party; + } +}; + +int main() try +{ + + using map_type = mdds::packed_trie_map<mdds::trie::std_string_traits, us_president>; + + // source: https://en.wikipedia.org/wiki/List_of_presidents_of_the_United_States + // + // The entries must be sorted by the keys. + + std::vector<map_type::entry> entries = + { + { MDDS_ASCII("Abraham Lincoln"), { 1861, republican_national_union } }, + { MDDS_ASCII("Andrew Jackson"), { 1829, democratic } }, + { MDDS_ASCII("Andrew Johnson"), { 1865, national_union } }, + { MDDS_ASCII("Barack Obama"), { 2009, democratic } }, + { MDDS_ASCII("Benjamin Harrison"), { 1889, republican } }, + { MDDS_ASCII("Bill Clinton"), { 1993, democratic } }, + { MDDS_ASCII("Calvin Coolidge"), { 1923, republican } }, + { MDDS_ASCII("Chester A. Arthur"), { 1881, republican } }, + { MDDS_ASCII("Donald Trump"), { 2017, republican } }, + { MDDS_ASCII("Dwight D. Eisenhower"), { 1953, republican } }, + { MDDS_ASCII("Franklin D. Roosevelt"), { 1933, democratic } }, + { MDDS_ASCII("Franklin Pierce"), { 1853, democratic } }, + { MDDS_ASCII("George H. W. Bush"), { 1989, republican } }, + { MDDS_ASCII("George W. Bush"), { 2001, republican } }, + { MDDS_ASCII("George Washington"), { 1789, unaffiliated } }, + { MDDS_ASCII("Gerald Ford"), { 1974, republican } }, + { MDDS_ASCII("Grover Cleveland 1"), { 1885, democratic } }, + { MDDS_ASCII("Grover Cleveland 2"), { 1893, democratic } }, + { MDDS_ASCII("Harry S. Truman"), { 1945, democratic } }, + { MDDS_ASCII("Herbert Hoover"), { 1929, republican } }, + { MDDS_ASCII("James A. Garfield"), { 1881, republican } }, + { MDDS_ASCII("James Buchanan"), { 1857, democratic } }, + { MDDS_ASCII("James K. Polk"), { 1845, democratic } }, + { MDDS_ASCII("James Madison"), { 1809, democratic_republican } }, + { MDDS_ASCII("James Monroe"), { 1817, democratic_republican } }, + { MDDS_ASCII("Jimmy Carter"), { 1977, democratic } }, + { MDDS_ASCII("John Adams"), { 1797, federalist } }, + { MDDS_ASCII("John F. Kennedy"), { 1961, democratic } }, + { MDDS_ASCII("John Quincy Adams"), { 1825, democratic_republican } }, + { MDDS_ASCII("John Tyler"), { 1841, whig } }, + { MDDS_ASCII("Lyndon B. Johnson"), { 1963, democratic } }, + { MDDS_ASCII("Martin Van Buren"), { 1837, democratic } }, + { MDDS_ASCII("Millard Fillmore"), { 1850, whig } }, + { MDDS_ASCII("Richard Nixon"), { 1969, republican } }, + { MDDS_ASCII("Ronald Reagan"), { 1981, republican } }, + { MDDS_ASCII("Rutherford B. Hayes"), { 1877, republican } }, + { MDDS_ASCII("Theodore Roosevelt"), { 1901, republican } }, + { MDDS_ASCII("Thomas Jefferson"), { 1801, democratic_republican } }, + { MDDS_ASCII("Ulysses S. Grant"), { 1869, republican } }, + { MDDS_ASCII("Warren G. Harding"), { 1921, republican } }, + { MDDS_ASCII("William Henry Harrison"), { 1841, whig } }, + { MDDS_ASCII("William Howard Taft"), { 1909, republican } }, + { MDDS_ASCII("William McKinley"), { 1897, republican } }, + { MDDS_ASCII("Woodrow Wilson"), { 1913, democratic } }, + { MDDS_ASCII("Zachary Taylor"), { 1849, whig } }, + }; + + map_type us_presidents(entries.data(), entries.size()); + cout << "Number of entries: " << us_presidents.size() << endl; + + cout << endl; + + { + std::ofstream outfile("us-presidents.bin", std::ios::binary); + us_presidents.save_state<us_president_serializer>(outfile); + } + + map_type us_presidents_loaded; + + { + std::ifstream infile("us-presidents.bin", std::ios::binary); + us_presidents_loaded.load_state<us_president_serializer>(infile); + } + + std::ios_base::fmtflags origflags = cout.flags(); + cout << "Equal to the original? " << std::boolalpha << (us_presidents == us_presidents_loaded) << endl; + cout.setf(origflags); + + cout << endl; + + cout << "Presidents whose first name is 'John':" << endl; + auto results = us_presidents_loaded.prefix_search("John"); + for (const auto& entry : results) + cout << " * " << entry.first << " (" << entry.second.year << "; " << entry.second.party << ")" << endl; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/example/packed_trie_state_int.cpp b/example/packed_trie_state_int.cpp new file mode 100644 index 0000000..e0157b5 --- /dev/null +++ b/example/packed_trie_state_int.cpp @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <iostream> +#include <vector> +#include <fstream> +#include <mdds/trie_map.hpp> + +using std::cout; +using std::endl; + +int main() try +{ + using map_type = mdds::packed_trie_map<mdds::trie::std_string_traits, int>; + + // List of world's largest cities and their populations. The entries must + // be sorted by the keys. + // + // c.f. https://en.wikipedia.org/wiki/List_of_largest_cities#cities + + std::vector<map_type::entry> entries = + { + { MDDS_ASCII("Ahmedabad"), 7681000 }, + { MDDS_ASCII("Alexandria"), 5086000 }, + { MDDS_ASCII("Atlanta"), 5572000 }, + { MDDS_ASCII("Baghdad"), 6812000 }, + { MDDS_ASCII("Bangalore"), 11440000 }, + { MDDS_ASCII("Bangkok"), 10156000 }, + { MDDS_ASCII("Barcelona"), 5494000 }, + { MDDS_ASCII("Beijing"), 19618000 }, + { MDDS_ASCII("Belo Horizonte"), 5972000 }, + { MDDS_ASCII("Bogota"), 10574000 }, + { MDDS_ASCII("Buenos Aires"), 14967000 }, + { MDDS_ASCII("Cairo"), 20076000 }, + { MDDS_ASCII("Chengdu"), 8813000 }, + { MDDS_ASCII("Chennai"), 10456000 }, + { MDDS_ASCII("Chicago"), 8864000 }, + { MDDS_ASCII("Chongqing"), 14838000 }, + { MDDS_ASCII("Dalian"), 5300000 }, + { MDDS_ASCII("Dallas"), 6099000 }, + { MDDS_ASCII("Dar es Salaam"), 6048000 }, + { MDDS_ASCII("Delhi"), 28514000 }, + { MDDS_ASCII("Dhaka"), 19578000 }, + { MDDS_ASCII("Dongguan"), 7360000 }, + { MDDS_ASCII("Foshan"), 7236000 }, + { MDDS_ASCII("Fukuoka"), 5551000 }, + { MDDS_ASCII("Guadalajara"), 5023000 }, + { MDDS_ASCII("Guangzhou"), 12638000 }, + { MDDS_ASCII("Hangzhou"), 7236000 }, + { MDDS_ASCII("Harbin"), 6115000 }, + { MDDS_ASCII("Ho Chi Minh City"), 8145000 }, + { MDDS_ASCII("Hong Kong"), 7429000 }, + { MDDS_ASCII("Houston"), 6115000 }, + { MDDS_ASCII("Hyderabad"), 9482000 }, + { MDDS_ASCII("Istanbul"), 14751000 }, + { MDDS_ASCII("Jakarta"), 10517000 }, + { MDDS_ASCII("Jinan"), 5052000 }, + { MDDS_ASCII("Johannesburg"), 5486000 }, + { MDDS_ASCII("Karachi"), 15400000 }, + { MDDS_ASCII("Khartoum"), 5534000 }, + { MDDS_ASCII("Kinshasa"), 13171000 }, + { MDDS_ASCII("Kolkata"), 14681000 }, + { MDDS_ASCII("Kuala Lumpur"), 7564000 }, + { MDDS_ASCII("Lagos"), 13463000 }, + { MDDS_ASCII("Lahore"), 11738000 }, + { MDDS_ASCII("Lima"), 10391000 }, + { MDDS_ASCII("London"), 9046000 }, + { MDDS_ASCII("Los Angeles"), 12458000 }, + { MDDS_ASCII("Luanda"), 7774000 }, + { MDDS_ASCII("Madrid"), 6497000 }, + { MDDS_ASCII("Manila"), 13482000 }, + { MDDS_ASCII("Mexico City"), 21581000 }, + { MDDS_ASCII("Miami"), 6036000 }, + { MDDS_ASCII("Moscow"), 12410000 }, + { MDDS_ASCII("Mumbai"), 19980000 }, + { MDDS_ASCII("Nagoya"), 9507000 }, + { MDDS_ASCII("Nanjing"), 8245000 }, + { MDDS_ASCII("New York City"), 18819000 }, + { MDDS_ASCII("Osaka"), 19281000 }, + { MDDS_ASCII("Paris"), 10901000 }, + { MDDS_ASCII("Philadelphia"), 5695000 }, + { MDDS_ASCII("Pune"), 6276000 }, + { MDDS_ASCII("Qingdao"), 5381000 }, + { MDDS_ASCII("Rio de Janeiro"), 13293000 }, + { MDDS_ASCII("Riyadh"), 6907000 }, + { MDDS_ASCII("Saint Petersburg"), 5383000 }, + { MDDS_ASCII("Santiago"), 6680000 }, + { MDDS_ASCII("Sao Paulo"), 21650000 }, + { MDDS_ASCII("Seoul"), 9963000 }, + { MDDS_ASCII("Shanghai"), 25582000 }, + { MDDS_ASCII("Shenyang"), 6921000 }, + { MDDS_ASCII("Shenzhen"), 11908000 }, + { MDDS_ASCII("Singapore"), 5792000 }, + { MDDS_ASCII("Surat"), 6564000 }, + { MDDS_ASCII("Suzhou"), 6339000 }, + { MDDS_ASCII("Tehran"), 8896000 }, + { MDDS_ASCII("Tianjin"), 13215000 }, + { MDDS_ASCII("Tokyo"), 37400068 }, + { MDDS_ASCII("Toronto"), 6082000 }, + { MDDS_ASCII("Washington, D.C."), 5207000 }, + { MDDS_ASCII("Wuhan"), 8176000 }, + { MDDS_ASCII("Xi'an"), 7444000 }, + { MDDS_ASCII("Yangon"), 5157000 }, + }; + + map_type cities(entries.data(), entries.size()); + cout << "Number of cities: " << cities.size() << endl; + + cout << endl; + + { + cout << "Cities that begin with 'S':" << endl; + auto results = cities.prefix_search("S"); + for (const auto& city : results) + cout << " * " << city.first << ": " << city.second << endl; + } + + cout << endl; + + { + std::ofstream outfile("cities.bin", std::ios::binary); + cities.save_state(outfile); + } + + map_type cities_loaded; + + { + std::ifstream infile("cities.bin", std::ios::binary); + cities_loaded.load_state(infile); + } + + std::ios_base::fmtflags origflags = cout.flags(); + cout << "Equal to the original? " << std::boolalpha << (cities == cities_loaded) << endl; + cout.setf(origflags); + + cout << endl; + + cout << "Number of cities: " << cities_loaded.size() << endl; + + cout << endl; + + cout << "Cities that begin with 'S':" << endl; + auto results = cities_loaded.prefix_search("S"); + for (const auto& city : results) + cout << " * " << city.first << ": " << city.second << endl; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/point_quad_tree.cpp b/example/point_quad_tree.cpp new file mode 100644 index 0000000..70016f0 --- /dev/null +++ b/example/point_quad_tree.cpp @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/point_quad_tree.hpp> +#include <string> +#include <iostream> + +using std::cout; +using std::endl; + +int main() try +{ + typedef ::mdds::point_quad_tree<double, std::string> db_type; + db_type db; + + std::string chicago("Chicago"); + std::string hamburg("Hamburg"); + std::string helsinki("Helsinki"); + std::string london("London"); + std::string paris("Paris"); + std::string prague("Prague"); + std::string shanghai("Shanghai"); + std::string tokyo("Tokyo"); + + // insert cities by longitude and latitude. + db.insert(-87.755280, 41.784168, chicago); + db.insert(10.000000, 53.633331, hamburg); + db.insert(25.049999, 60.250000, helsinki); + db.insert(-0.450000, 51.483334, london); + db.insert(2.450000, 48.966667, paris); + db.insert(14.250000, 50.099998, prague); + db.insert(121.433334, 31.166668, shanghai); + db.insert(139.850006, 35.633331, tokyo); + + // Perform region search. + db_type::search_results results = db.search_region(100, 30, 140, 40); + + // Print out the result of the search. + cout << "Cities located between longitudes 100 and 140 east and latitudes 30 and 40 north are:" << endl; + for (const auto& res : results) + { + cout << " " << res.second + << ": (latitude=" << res.first.x + << ", longitude=" << res.first.y << ")" << endl; + } +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/rtree_erase.cpp b/example/rtree_erase.cpp new file mode 100644 index 0000000..b1a7744 --- /dev/null +++ b/example/rtree_erase.cpp @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/rtree.hpp> + +#include <string> +#include <iostream> + +int main() try +{ + using rt_type = mdds::rtree<int, std::string>; + + rt_type tree; + + // Insert multiple values at the same point. + tree.insert({1, 1}, "A"); + tree.insert({1, 1}, "B"); + tree.insert({1, 1}, "C"); + tree.insert({1, 1}, "D"); + tree.insert({1, 1}, "E"); + + // This should return all five values. + auto results = tree.search({1, 1}, rt_type::search_type::match); + + for (const std::string& v : results) + std::cout << v << std::endl; + + // Erase "C". + for (auto it = results.begin(); it != results.end(); ++it) + { + if (*it == "C") + { + tree.erase(it); + break; // This invalidates the iterator. Bail out. + } + } + + std::cout << "'C' has been erased." << std::endl; + + // Now this should only return A, B, D and E. + results = tree.search({1, 1}, rt_type::search_type::match); + + for (const std::string& v : results) + std::cout << v << std::endl; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/rtree_medium.cpp b/example/rtree_medium.cpp new file mode 100644 index 0000000..ef46871 --- /dev/null +++ b/example/rtree_medium.cpp @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/rtree.hpp> + +#include <iostream> +#include <fstream> + +// Make the node capacity intentionally small. +struct tiny_traits_2d +{ + constexpr static size_t dimensions = 2; + constexpr static size_t min_node_size = 2; + constexpr static size_t max_node_size = 5; + constexpr static size_t max_tree_depth = 100; + + constexpr static bool enable_forced_reinsertion = true; + constexpr static size_t reinsertion_size = 2; +}; + +using rt_type = mdds::rtree<int, int, tiny_traits_2d>; + +int main() try +{ + // 2D rectangle with the top-left position (x, y), width and height. + struct rect + { + int x; + int y; + int w; + int h; + }; + + std::vector<rect> rects = + { + { 3731, 2433, 1356, 937 }, + { 6003, 3172, 1066, 743 }, + { 4119, 6403, 825, 1949 }, + { 10305, 2315, 776, 548 }, + { 13930, 5468, 1742, 626 }, + { 8614, 4107, 2709, 1793 }, + { 14606, 1887, 5368, 1326 }, + { 17990, 5196, 1163, 1911 }, + { 6728, 7881, 3676, 1210 }, + { 14704, 9789, 5271, 1092 }, + { 4071, 10723, 4739, 898 }, + { 11755, 9010, 1357, 2806 }, + { 13978, 4068, 776, 509 }, + { 17507, 3717, 777, 471 }, + { 20358, 6092, 824, 1093 }, + { 6390, 4535, 1066, 1715 }, + { 13978, 7182, 2516, 1365 }, + { 17942, 11580, 2854, 665 }, + { 9919, 10450, 873, 1716 }, + { 5568, 13215, 7446, 509 }, + { 7357, 15277, 3145, 3234 }, + { 3539, 12592, 631, 509 }, + { 4747, 14498, 825, 626 }, + { 4554, 16913, 969, 1443 }, + { 12771, 14693, 2323, 548 }, + { 18714, 8193, 2372, 586 }, + { 22292, 2743, 487, 1638 }, + { 20987, 17535, 1163, 1249 }, + { 19536, 18859, 632, 431 }, + { 19778, 15394, 1356, 626 }, + { 22969, 15394, 631, 2066 }, + }; + + rt_type tree; + + // Insert the rectangle objects into the tree. + int value = 0; + for (const auto& rect : rects) + tree.insert({{rect.x, rect.y}, {rect.x + rect.w, rect.y + rect.h}}, value++); + + // Export the tree structure as a SVG for visualization. + std::string tree_svg = tree.export_tree(rt_type::export_tree_type::extent_as_svg); + std::ofstream fout("bounds.svg"); + fout << tree_svg; + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/rtree_medium_bulkload.cpp b/example/rtree_medium_bulkload.cpp new file mode 100644 index 0000000..fc28587 --- /dev/null +++ b/example/rtree_medium_bulkload.cpp @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/rtree.hpp> + +#include <iostream> +#include <fstream> + +// Make the node capacity intentionally small. +struct tiny_traits_2d +{ + constexpr static size_t dimensions = 2; + constexpr static size_t min_node_size = 2; + constexpr static size_t max_node_size = 5; + constexpr static size_t max_tree_depth = 100; + + constexpr static bool enable_forced_reinsertion = true; + constexpr static size_t reinsertion_size = 2; +}; + +using rt_type = mdds::rtree<int, int, tiny_traits_2d>; + +// 2D rectangle with the top-left position (x, y), width and height. +struct rect +{ + int x; + int y; + int w; + int h; +}; + +std::vector<rect> rects = +{ + { 3538, 9126, 1908, 1908 }, + { 34272, 52053, 2416, 2543 }, + { 32113, 9761, 2416, 638 }, + { 16493, 16747, 7369, 2289 }, + { 29192, 23732, 3432, 2035 }, + { 35797, 17000, 1781, 892 }, + { 15857, 29319, 2162, 1654 }, + { 5825, 24239, 3559, 8512 }, + { 9127, 46846, 2543, 1019 }, + { 7094, 54338, 5210, 892 }, + { 18779, 39734, 3813, 10417 }, + { 32749, 35923, 2289, 2924 }, + { 26018, 31098, 257, 2797 }, + { 6713, 37066, 2924, 1146 }, + { 19541, 3157, 3305, 1146 }, + { 21953, 10904, 4448, 892 }, + { 15984, 24240, 5210, 1273 }, + { 8237, 15350, 2670, 2797 }, + { 17001, 13826, 4067, 1273 }, + { 30970, 13826, 3940, 765 }, + { 9634, 6587, 1654, 1781 }, + { 38464, 47099, 511, 1400 }, + { 20556, 54085, 1400, 1527 }, + { 37575, 24113, 1019, 765 }, + { 20429, 21064, 1146, 1400 }, + { 31733, 4427, 2543, 638 }, + { 2142, 27161, 1273, 7369 }, + { 3920, 43289, 8131, 1146 }, + { 14714, 34272, 1400, 4956 }, + { 38464, 41258, 1273, 1273 }, + { 35542, 45703, 892, 1273 }, + { 25891, 50783, 1273, 5083 }, + { 35415, 28431, 2924, 1781 }, + { 15476, 7349, 1908, 765 }, + { 12555, 11159, 1654, 2035 }, + { 11158, 21445, 1908, 2416 }, + { 23350, 28049, 3432, 892 }, + { 28684, 15985, 2416, 4321 }, + { 24620, 21953, 1654, 638 }, + { 30208, 30716, 2670, 2162 }, + { 26907, 44179, 2797, 4067 }, + { 21191, 35416, 2162, 1019 }, + { 27668, 38717, 638, 3178 }, + { 3666, 50528, 2035, 1400 }, + { 15349, 48750, 2670, 1654 }, + { 28430, 7221, 2162, 892 }, + { 4808, 3158, 2416, 1273 }, + { 38464, 3666, 1527, 1781 }, + { 2777, 20937, 2289, 1146 }, + { 38209, 9254, 1908, 1781 }, + { 2269, 56497, 2289, 892 }, +}; + +void load_tree() +{ + rt_type tree; + + // Insert the rectangle objects into the tree. + int value = 0; + for (const auto& rect : rects) + tree.insert({{rect.x, rect.y}, {rect.x + rect.w, rect.y + rect.h}}, value++); + + // Export the tree structure as a SVG for visualization. + std::string tree_svg = tree.export_tree(rt_type::export_tree_type::extent_as_svg); + std::ofstream fout("bounds2.svg"); + fout << tree_svg; +} + +void bulkload_tree() +{ + rt_type::bulk_loader loader; + + // Insert the rectangle objects into the tree. + int value = 0; + for (const auto& rect : rects) + loader.insert({{rect.x, rect.y}, {rect.x + rect.w, rect.y + rect.h}}, value++); + + // Start bulk-loading the tree. + rt_type tree = loader.pack(); + + // Export the tree structure as a SVG for visualization. + std::string tree_svg = tree.export_tree(rt_type::export_tree_type::extent_as_svg); + std::ofstream fout("bounds2-bulkload.svg"); + fout << tree_svg; +} + +int main() try +{ + load_tree(); + bulkload_tree(); + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/rtree_simple.cpp b/example/rtree_simple.cpp new file mode 100644 index 0000000..c75eaf9 --- /dev/null +++ b/example/rtree_simple.cpp @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/rtree.hpp> + +#include <string> +#include <iostream> + +int main() try +{ + // key values are of type double, and we are storing std::string as a + // value for each spatial object. By default, tree becomes 2-dimensional + // object store unless otherwise specified. + using rt_type = mdds::rtree<double, std::string>; + + rt_type tree; + + tree.insert({{0.0, 0.0}, {15.0, 20.0}}, "first rectangle data"); + + rt_type::extent_type bounds({-2.0, -1.0}, {1.0, 2.0}); + std::cout << "inserting value for " << bounds.to_string() << std::endl; + tree.insert(bounds, "second rectangle data"); + + bounds.start.d[0] = -1.0; // Change the first dimension value of the start rectangle point. + bounds.end.d[1] += 1.0; // Increment the second dimension value of the end rectangle point. + std::cout << "inserting value for " << bounds.to_string() << std::endl; + tree.insert(bounds, "third rectangle data"); + + tree.insert({5.0, 6.0}, "first point data"); + + { + // Search for all objects that overlap with a (4, 4) - (7, 7) rectangle. + auto results = tree.search({{4.0, 4.0}, {7.0, 7.0}}, rt_type::search_type::overlap); + + for (const std::string& v : results) + std::cout << "value: " << v << std::endl; + } + + { + // Search for all objects whose bounding rectangles are exactly (4, 4) - (7, 7). + auto results = tree.search({{4.0, 4.0}, {7.0, 7.0}}, rt_type::search_type::match); + std::cout << "number of results: " << std::distance(results.begin(), results.end()) << std::endl; + } + + { + // Search for all objects whose bounding rectangles are exactly (0, 0) - (15, 20). + auto results = tree.search({{0.0, 0.0}, {15.0, 20.0}}, rt_type::search_type::match); + std::cout << "number of results: " << std::distance(results.begin(), results.end()) << std::endl; + + std::cout << "value: " << *results.begin() << std::endl; + + std::cout << "--" << std::endl; + + auto it = results.begin(); + std::cout << "value: " << *it << std::endl; + std::cout << "extent: " << it.extent().to_string() << std::endl; + std::cout << "depth: " << it.depth() << std::endl; + } + + return EXIT_SUCCESS; +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/segment_tree.cpp b/example/segment_tree.cpp new file mode 100644 index 0000000..4b70ed9 --- /dev/null +++ b/example/segment_tree.cpp @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/segment_tree.hpp> +#include <string> +#include <iostream> + +using std::cout; +using std::endl; + +typedef ::mdds::segment_tree<long, std::string> db_type; + +struct string_printer +{ + void operator() (const std::string& s) const + { + cout << "search hit: " << s << endl; + } +}; + +int main() try +{ + db_type db; + std::string A("A"); + std::string B("B"); + std::string C("C"); + + // Insert data into the tree. + db.insert(0, 10, A); + db.insert(2, 20, B); + db.insert(10, 15, C); + + // Don't forget to build it before calling search(). + db.build_tree(); + + // Run search and get the result. + db_type::search_results result = db.search(5); + + // Print the result. + cout << "result size: " << result.size() << endl; + std::for_each(result.begin(), result.end(), string_printer()); +} +catch (...) +{ + return EXIT_FAILURE; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/example/trie_map.cpp b/example/trie_map.cpp new file mode 100644 index 0000000..445a9c7 --- /dev/null +++ b/example/trie_map.cpp @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * Copyright (c) 2020 Kohei Yoshida + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + ************************************************************************/ + +#include <mdds/trie_map.hpp> +#include <iostream> + +using std::cout; +using std::endl; + +int main() +{ + using trie_map_type = mdds::trie_map<mdds::trie::std_string_traits, int>; + + // Cities in North Carolina and their populations in 2013. + trie_map_type nc_cities; + + // Insert key-value pairs. + nc_cities.insert("Charlotte", 792862); + nc_cities.insert("Raleigh", 431746); + nc_cities.insert("Greensboro", 279639); + nc_cities.insert("Durham", 245475); + nc_cities.insert("Winston-Salem", 236441); + nc_cities.insert("Fayetteville", 204408); + nc_cities.insert("Cary", 151088); + nc_cities.insert("Wilmington", 112067); + nc_cities.insert("High Point", 107741); + nc_cities.insert("Greenville", 89130); + nc_cities.insert("Asheville", 87236); + nc_cities.insert("Concord", 83506); + nc_cities.insert("Gastonia", 73209); + nc_cities.insert("Jacksonville", 69079); + nc_cities.insert("Chapel Hill", 59635); + nc_cities.insert("Rocky Mount", 56954); + nc_cities.insert("Burlington", 51510); + nc_cities.insert("Huntersville", 50458); + nc_cities.insert("Wilson", 49628); + nc_cities.insert("Kannapolis", 44359); + nc_cities.insert("Apex", 42214); + nc_cities.insert("Hickory", 40361); + nc_cities.insert("Goldsboro", 36306); + + cout << "Cities that start with 'Cha' and their populations:" << endl; + auto results = nc_cities.prefix_search("Cha"); + for (const auto& kv : results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + cout << "Cities that start with 'W' and their populations:" << endl; + results = nc_cities.prefix_search("W"); + for (const auto& kv : results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + // Create a compressed version of the container. It works nearly identically. + auto packed = nc_cities.pack(); + + cout << "Cities that start with 'C' and their populations:" << endl; + auto packed_results = packed.prefix_search("C"); + for (const auto& kv : packed_results) + { + cout << " " << kv.first << ": " << kv.second << endl; + } + + // Individual search. + auto it = packed.find("Wilmington"); + cout << "Population of Wilmington: " << it->second << endl; + + // You get an end position iterator when the container doesn't have the + // specified key. + it = packed.find("Asheboro"); + + cout << "Population of Asheboro: "; + + if (it == packed.end()) + cout << "not found"; + else + cout << it->second; + + cout << endl; + + return EXIT_SUCCESS; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |