diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
commit | 056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch) | |
tree | 4740980126f32e3af7937ba0ca5f83e59baa4ab0 /contrib/restricted/boost/algorithm | |
parent | 269126dcced1cc8b53eb4398b4a33e5142f10290 (diff) | |
download | ydb-056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11.tar.gz |
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'contrib/restricted/boost/algorithm')
52 files changed, 6837 insertions, 0 deletions
diff --git a/contrib/restricted/boost/algorithm/.yandex_meta/devtools.copyrights.report b/contrib/restricted/boost/algorithm/.yandex_meta/devtools.copyrights.report new file mode 100644 index 00000000000..7de075c1bd9 --- /dev/null +++ b/contrib/restricted/boost/algorithm/.yandex_meta/devtools.copyrights.report @@ -0,0 +1,282 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP COPYRIGHT_SERVICE_LABEL 1b80c8e7f5a5f53532760a321c46060b +BELONGS ya.make + License text: + // Copyright Pavol Droba 2002-2004. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/string.hpp [3:3] + include/boost/algorithm/string/find_iterator.hpp [3:3] + include/boost/algorithm/string_regex.hpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 23ebb49331f21ac4d5b9810957996ca2 +BELONGS ya.make + License text: + Copyright (c) T. Zachary Laine 2018. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/find_backward.hpp [2:2] + include/boost/algorithm/find_not.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 25e0eaeed6a114cd44e28e07f4bcf799 +BELONGS ya.make + License text: + Copyright 2008 Adobe Systems Incorporated + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/gather.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 28928198315325a81f74270ad06e5e12 +BELONGS ya.make + License text: + // Copyright Pavol Droba 2002-2006. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/string/compare.hpp [3:3] + include/boost/algorithm/string/detail/finder.hpp [3:3] + include/boost/algorithm/string/erase.hpp [3:3] + include/boost/algorithm/string/finder.hpp [3:3] + include/boost/algorithm/string/join.hpp [3:3] + include/boost/algorithm/string/replace.hpp [3:3] + include/boost/algorithm/string/split.hpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 3f74953683124ccdec5f589c930961bc +BELONGS ya.make + License text: + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.by>, 2017. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/is_partitioned_until.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 419d0482c09d39b3ded1706d383f69bc +BELONGS ya.make + License text: + Copyright (c) Marshall Clow 2017. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/cxx17/exclusive_scan.hpp [2:2] + include/boost/algorithm/cxx17/for_each_n.hpp [2:2] + include/boost/algorithm/cxx17/inclusive_scan.hpp [2:2] + include/boost/algorithm/cxx17/reduce.hpp [2:2] + include/boost/algorithm/cxx17/transform_exclusive_scan.hpp [2:2] + include/boost/algorithm/cxx17/transform_inclusive_scan.hpp [2:2] + include/boost/algorithm/cxx17/transform_reduce.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 6a3e2fab4fddbdc7707570b9a6dd6664 +BELONGS ya.make + License text: + Copyright (c) Ivan Matek, Marshall Clow 2021. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/is_clamped.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 8d1214bd39f8d38ef1ffd0059eaff3a3 +BELONGS ya.make + License text: + Copyright (c) Marshall Clow 2008-2012. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/clamp.hpp [2:2] + include/boost/algorithm/cxx11/all_of.hpp [2:2] + include/boost/algorithm/cxx11/any_of.hpp [2:2] + include/boost/algorithm/cxx11/copy_if.hpp [2:2] + include/boost/algorithm/cxx11/iota.hpp [2:2] + include/boost/algorithm/cxx11/none_of.hpp [2:2] + include/boost/algorithm/cxx11/one_of.hpp [2:2] + include/boost/algorithm/cxx14/equal.hpp [2:2] + include/boost/algorithm/cxx14/mismatch.hpp [2:2] + include/boost/algorithm/sort_subrange.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL 8dda65576163c7b59f1859a97983c400 +BELONGS ya.make + License text: + // (C) Copyright Herve Bronnimann 2004. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/minmax.hpp [1:1] + include/boost/algorithm/minmax_element.hpp [1:1] + +KEEP COPYRIGHT_SERVICE_LABEL 92541842df8561eccc16be0c5aad7f91 +BELONGS ya.make + License text: + Copyright (c) Marshall Clow 2010-2012. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/searching/boyer_moore.hpp [2:2] + include/boost/algorithm/searching/boyer_moore_horspool.hpp [2:2] + include/boost/algorithm/searching/detail/bm_traits.hpp [2:2] + include/boost/algorithm/searching/detail/debugging.hpp [2:2] + include/boost/algorithm/searching/knuth_morris_pratt.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL a57e7bc1a642b17ae2068cf3d13d7cec +BELONGS ya.make + License text: + Copyright (c) Marshall Clow 2011-2012. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/cxx11/copy_n.hpp [2:2] + include/boost/algorithm/cxx11/find_if_not.hpp [2:2] + include/boost/algorithm/cxx11/is_partitioned.hpp [2:2] + include/boost/algorithm/cxx11/is_permutation.hpp [2:2] + include/boost/algorithm/cxx11/partition_copy.hpp [2:2] + include/boost/algorithm/cxx11/partition_point.hpp [2:2] + include/boost/algorithm/hex.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL aeaee3b43c9a47f861a6ff5d3039fb8c +BELONGS ya.make + License text: + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2016 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/is_palindrome.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL c53a70d05211d1267ddeb5866bb86169 +BELONGS ya.make + License text: + // Copyright (c) 2010 Nuovation System Designs, LLC + // Grant Erickson <gerickson@nuovations.com> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/cxx11/is_sorted.hpp [1:2] + +KEEP COPYRIGHT_SERVICE_LABEL c8491f9471a05c66b2b0b94793f3fadc +BELONGS ya.make + License text: + // Copyright Pavol Droba 2002-2003. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/string/case_conv.hpp [3:3] + include/boost/algorithm/string/classification.hpp [3:3] + include/boost/algorithm/string/concept.hpp [3:3] + include/boost/algorithm/string/config.hpp [3:3] + include/boost/algorithm/string/constants.hpp [3:3] + include/boost/algorithm/string/detail/case_conv.hpp [3:3] + include/boost/algorithm/string/detail/classification.hpp [3:3] + include/boost/algorithm/string/detail/find_format.hpp [3:3] + include/boost/algorithm/string/detail/find_format_all.hpp [3:3] + include/boost/algorithm/string/detail/find_format_store.hpp [3:3] + include/boost/algorithm/string/detail/find_iterator.hpp [3:3] + include/boost/algorithm/string/detail/finder_regex.hpp [3:3] + include/boost/algorithm/string/detail/formatter.hpp [3:3] + include/boost/algorithm/string/detail/formatter_regex.hpp [3:3] + include/boost/algorithm/string/detail/predicate.hpp [3:3] + include/boost/algorithm/string/detail/replace_storage.hpp [3:3] + include/boost/algorithm/string/detail/sequence.hpp [3:3] + include/boost/algorithm/string/detail/trim.hpp [3:3] + include/boost/algorithm/string/detail/util.hpp [3:3] + include/boost/algorithm/string/find.hpp [3:3] + include/boost/algorithm/string/find_format.hpp [3:3] + include/boost/algorithm/string/formatter.hpp [3:3] + include/boost/algorithm/string/iter_find.hpp [3:3] + include/boost/algorithm/string/predicate.hpp [3:3] + include/boost/algorithm/string/predicate_facade.hpp [3:3] + include/boost/algorithm/string/regex.hpp [3:3] + include/boost/algorithm/string/regex_find_format.hpp [3:3] + include/boost/algorithm/string/sequence_traits.hpp [3:3] + include/boost/algorithm/string/std/list_traits.hpp [3:3] + include/boost/algorithm/string/std/rope_traits.hpp [3:3] + include/boost/algorithm/string/std/slist_traits.hpp [3:3] + include/boost/algorithm/string/std/string_traits.hpp [3:3] + include/boost/algorithm/string/std_containers_traits.hpp [3:3] + include/boost/algorithm/string/trim.hpp [3:3] + include/boost/algorithm/string/trim_all.hpp [3:3] + include/boost/algorithm/string/yes_no_type.hpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL e52bfa20bf609c836f15095ec431514d +BELONGS ya.make + License text: + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2017 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/apply_permutation.hpp [2:2] + +KEEP COPYRIGHT_SERVICE_LABEL f33a64b4b1ee1bea603ff632b1a22ec0 +BELONGS ya.make + License text: + Copyright (c) Marshall Clow 2014. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/algorithm/algorithm.hpp [2:2] + include/boost/algorithm/cxx14/is_permutation.hpp [2:2] diff --git a/contrib/restricted/boost/algorithm/.yandex_meta/devtools.licenses.report b/contrib/restricted/boost/algorithm/.yandex_meta/devtools.licenses.report new file mode 100644 index 00000000000..8fefa0600ae --- /dev/null +++ b/contrib/restricted/boost/algorithm/.yandex_meta/devtools.licenses.report @@ -0,0 +1,226 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP BSL-1.0 0bfa54b6d82598f1c5f117adedeec37c +BELONGS ya.make + License text: + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/algorithm.hpp [4:5] + include/boost/algorithm/clamp.hpp [4:5] + include/boost/algorithm/cxx11/all_of.hpp [4:5] + include/boost/algorithm/cxx11/any_of.hpp [4:5] + include/boost/algorithm/cxx11/copy_if.hpp [4:5] + include/boost/algorithm/cxx11/copy_n.hpp [4:5] + include/boost/algorithm/cxx11/find_if_not.hpp [4:5] + include/boost/algorithm/cxx11/iota.hpp [4:5] + include/boost/algorithm/cxx11/is_partitioned.hpp [4:5] + include/boost/algorithm/cxx11/is_permutation.hpp [4:5] + include/boost/algorithm/cxx11/none_of.hpp [4:5] + include/boost/algorithm/cxx11/one_of.hpp [4:5] + include/boost/algorithm/cxx11/partition_copy.hpp [4:5] + include/boost/algorithm/cxx11/partition_point.hpp [4:5] + include/boost/algorithm/cxx14/equal.hpp [4:5] + include/boost/algorithm/cxx14/is_permutation.hpp [4:5] + include/boost/algorithm/cxx14/mismatch.hpp [4:5] + include/boost/algorithm/cxx17/exclusive_scan.hpp [4:5] + include/boost/algorithm/cxx17/for_each_n.hpp [4:5] + include/boost/algorithm/cxx17/inclusive_scan.hpp [4:5] + include/boost/algorithm/cxx17/reduce.hpp [4:5] + include/boost/algorithm/cxx17/transform_exclusive_scan.hpp [4:5] + include/boost/algorithm/cxx17/transform_inclusive_scan.hpp [4:5] + include/boost/algorithm/cxx17/transform_reduce.hpp [4:5] + include/boost/algorithm/find_backward.hpp [4:5] + include/boost/algorithm/find_not.hpp [4:5] + include/boost/algorithm/gather.hpp [4:5] + include/boost/algorithm/hex.hpp [4:5] + include/boost/algorithm/is_clamped.hpp [4:5] + include/boost/algorithm/is_partitioned_until.hpp [4:5] + include/boost/algorithm/searching/boyer_moore.hpp [4:5] + include/boost/algorithm/searching/boyer_moore_horspool.hpp [4:5] + include/boost/algorithm/searching/detail/bm_traits.hpp [4:5] + include/boost/algorithm/searching/detail/debugging.hpp [4:5] + include/boost/algorithm/searching/knuth_morris_pratt.hpp [4:5] + include/boost/algorithm/sort_subrange.hpp [4:5] + +KEEP BSL-1.0 1bc23f67ca27c295e38b46190cdce22f +BELONGS ya.make + License text: + // Distributed under the Boost Software License, Version 1.0. (See accompanying + // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/minmax.hpp [3:4] + include/boost/algorithm/minmax_element.hpp [3:4] + +KEEP BSL-1.0 2c7a3fa82e66676005cd4ee2608fd7d2 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : TEXT + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + LICENSE [1:23] + +KEEP BSL-1.0 648ee54e68cb4c96cfd2e41a7a53e0f8 +BELONGS ya.make + License text: + \### License + Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + Scancode info: + Original SPDX id: BSL-1.0 + Score : 60.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + README.md [3:5] + +KEEP BSL-1.0 6f142535a1deefdedb1f10f224c9b0ed +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/string/detail/formatter.hpp [5:9] + +KEEP BSL-1.0 8abbac2c705b0911702566954b0ebe9b +BELONGS ya.make + License text: + // Distributed under the Boost Software License, Version 1.0. (See + // accompanying file LICENSE_1_0.txt or copy at + // http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/cxx11/is_sorted.hpp [6:8] + +KEEP BSL-1.0 901941bd35f9f19e23af80f6271c10c4 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSL-1.0 + Score : 60.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + README.md [32:32] + +KEEP BSL-1.0 ca05dbe6a64cb6bf8779bd19f5bb4d80 +BELONGS ya.make + License text: + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/apply_permutation.hpp [4:6] + include/boost/algorithm/is_palindrome.hpp [4:6] + +KEEP BSL-1.0 f262303c7ce4d7bb32412cf8e6aa42e5 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/algorithm/string.hpp [5:9] + include/boost/algorithm/string/case_conv.hpp [5:9] + include/boost/algorithm/string/classification.hpp [5:9] + include/boost/algorithm/string/compare.hpp [5:9] + include/boost/algorithm/string/concept.hpp [5:9] + include/boost/algorithm/string/config.hpp [5:9] + include/boost/algorithm/string/constants.hpp [5:9] + include/boost/algorithm/string/detail/case_conv.hpp [5:9] + include/boost/algorithm/string/detail/classification.hpp [5:9] + include/boost/algorithm/string/detail/find_format.hpp [5:9] + include/boost/algorithm/string/detail/find_format_all.hpp [5:9] + include/boost/algorithm/string/detail/find_format_store.hpp [5:9] + include/boost/algorithm/string/detail/find_iterator.hpp [5:9] + include/boost/algorithm/string/detail/finder.hpp [5:9] + include/boost/algorithm/string/detail/finder_regex.hpp [5:9] + include/boost/algorithm/string/detail/formatter_regex.hpp [5:9] + include/boost/algorithm/string/detail/predicate.hpp [5:9] + include/boost/algorithm/string/detail/replace_storage.hpp [5:9] + include/boost/algorithm/string/detail/sequence.hpp [5:9] + include/boost/algorithm/string/detail/trim.hpp [5:9] + include/boost/algorithm/string/detail/util.hpp [5:9] + include/boost/algorithm/string/erase.hpp [5:9] + include/boost/algorithm/string/find.hpp [5:9] + include/boost/algorithm/string/find_format.hpp [5:9] + include/boost/algorithm/string/find_iterator.hpp [5:9] + include/boost/algorithm/string/finder.hpp [5:9] + include/boost/algorithm/string/formatter.hpp [5:9] + include/boost/algorithm/string/iter_find.hpp [5:9] + include/boost/algorithm/string/join.hpp [5:9] + include/boost/algorithm/string/predicate.hpp [5:9] + include/boost/algorithm/string/predicate_facade.hpp [5:9] + include/boost/algorithm/string/regex.hpp [5:9] + include/boost/algorithm/string/regex_find_format.hpp [5:9] + include/boost/algorithm/string/replace.hpp [5:9] + include/boost/algorithm/string/sequence_traits.hpp [5:9] + include/boost/algorithm/string/split.hpp [5:9] + include/boost/algorithm/string/std/list_traits.hpp [5:9] + include/boost/algorithm/string/std/rope_traits.hpp [5:9] + include/boost/algorithm/string/std/slist_traits.hpp [5:9] + include/boost/algorithm/string/std/string_traits.hpp [5:9] + include/boost/algorithm/string/std_containers_traits.hpp [5:9] + include/boost/algorithm/string/trim.hpp [5:9] + include/boost/algorithm/string/trim_all.hpp [5:9] + include/boost/algorithm/string/yes_no_type.hpp [5:9] + include/boost/algorithm/string_regex.hpp [5:9] diff --git a/contrib/restricted/boost/algorithm/.yandex_meta/licenses.list.txt b/contrib/restricted/boost/algorithm/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..9f42d9b5559 --- /dev/null +++ b/contrib/restricted/boost/algorithm/.yandex_meta/licenses.list.txt @@ -0,0 +1,136 @@ +====================BSL-1.0==================== + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +### License + +Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + + +====================BSL-1.0==================== +* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +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, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +====================COPYRIGHT==================== + Copyright 2008 Adobe Systems Incorporated + + +====================COPYRIGHT==================== + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.by>, 2017. + + +====================COPYRIGHT==================== + Copyright (c) Ivan Matek, Marshall Clow 2021. + + +====================COPYRIGHT==================== + Copyright (c) Marshall Clow 2008-2012. + + +====================COPYRIGHT==================== + Copyright (c) Marshall Clow 2010-2012. + + +====================COPYRIGHT==================== + Copyright (c) Marshall Clow 2011-2012. + + +====================COPYRIGHT==================== + Copyright (c) Marshall Clow 2014. + + +====================COPYRIGHT==================== + Copyright (c) Marshall Clow 2017. + + +====================COPYRIGHT==================== + Copyright (c) T. Zachary Laine 2018. + + +====================COPYRIGHT==================== + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2016 + + +====================COPYRIGHT==================== + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2017 + + +====================COPYRIGHT==================== +// (C) Copyright Herve Bronnimann 2004. + + +====================COPYRIGHT==================== +// Copyright (c) 2010 Nuovation System Designs, LLC +// Grant Erickson <gerickson@nuovations.com> + + +====================COPYRIGHT==================== +// Copyright Pavol Droba 2002-2003. + + +====================COPYRIGHT==================== +// Copyright Pavol Droba 2002-2004. + + +====================COPYRIGHT==================== +// Copyright Pavol Droba 2002-2006. diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/algorithm.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/algorithm.hpp new file mode 100644 index 00000000000..85b43c0ed38 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/algorithm.hpp @@ -0,0 +1,89 @@ +/* + Copyright (c) Marshall Clow 2014. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + Revision history: + 2 Dec 2014 mtc First version; power + +*/ + +/// \file algorithm.hpp +/// \brief Misc Algorithms +/// \author Marshall Clow +/// + +#ifndef BOOST_ALGORITHM_HPP +#define BOOST_ALGORITHM_HPP + +#include <functional> // for plus and multiplies + +#include <boost/config.hpp> +#include <boost/core/enable_if.hpp> // for boost::disable_if +#include <boost/type_traits/is_integral.hpp> + +namespace boost { namespace algorithm { + +template <typename T> +BOOST_CXX14_CONSTEXPR T identity_operation ( std::multiplies<T> ) { return T(1); } + +template <typename T> +BOOST_CXX14_CONSTEXPR T identity_operation ( std::plus<T> ) { return T(0); } + + +/// \fn power ( T x, Integer n ) +/// \return the value "x" raised to the power "n" +/// +/// \param x The value to be exponentiated +/// \param n The exponent (must be >= 0) +/// +// \remark Taken from Knuth, The Art of Computer Programming, Volume 2: +// Seminumerical Algorithms, Section 4.6.3 +template <typename T, typename Integer> +BOOST_CXX14_CONSTEXPR typename boost::enable_if<boost::is_integral<Integer>, T>::type +power (T x, Integer n) { + T y = 1; // Should be "T y{1};" + if (n == 0) return y; + while (true) { + if (n % 2 == 1) { + y = x * y; + if (n == 1) + return y; + } + n = n / 2; + x = x * x; + } + return y; + } + +/// \fn power ( T x, Integer n, Operation op ) +/// \return the value "x" raised to the power "n" +/// using the operation "op". +/// +/// \param x The value to be exponentiated +/// \param n The exponent (must be >= 0) +/// \param op The operation used +/// +// \remark Taken from Knuth, The Art of Computer Programming, Volume 2: +// Seminumerical Algorithms, Section 4.6.3 +template <typename T, typename Integer, typename Operation> +BOOST_CXX14_CONSTEXPR typename boost::enable_if<boost::is_integral<Integer>, T>::type +power (T x, Integer n, Operation op) { + T y = identity_operation(op); + if (n == 0) return y; + while (true) { + if (n % 2 == 1) { + y = op(x, y); + if (n == 1) + return y; + } + n = n / 2; + x = op(x, x); + } + return y; + } + +}} + +#endif // BOOST_ALGORITHM_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/apply_permutation.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/apply_permutation.hpp new file mode 100644 index 00000000000..124c31efe3c --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/apply_permutation.hpp @@ -0,0 +1,126 @@ +/* + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2017 + + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + + See http://www.boost.org/ for latest version. + + + Based on https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=95115 +*/ + +/// \file apply_permutation.hpp +/// \brief Apply permutation to a sequence. +/// \author Alexander Zaitsev + +#ifndef BOOST_ALGORITHM_APPLY_PERMUTATION_HPP +#define BOOST_ALGORITHM_APPLY_PERMUTATION_HPP + +#include <algorithm> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm +{ + +/// \fn apply_permutation ( RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, RandomAccessIterator2 ind_begin ) +/// \brief Reorder item sequence with index sequence order +/// +/// \param item_begin The start of the item sequence +/// \param item_end One past the end of the item sequence +/// \param ind_begin The start of the index sequence. +/// +/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined. +/// Complexity: O(N). +template<typename RandomAccessIterator1, typename RandomAccessIterator2> +void +apply_permutation(RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, + RandomAccessIterator2 ind_begin, RandomAccessIterator2 ind_end) +{ + typedef typename std::iterator_traits<RandomAccessIterator1>::difference_type Diff; + typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Index; + using std::swap; + Diff size = std::distance(item_begin, item_end); + for (Diff i = 0; i < size; i++) + { + Diff current = i; + while (i != ind_begin[current]) + { + Index next = ind_begin[current]; + swap(item_begin[current], item_begin[next]); + ind_begin[current] = current; + current = next; + } + ind_begin[current] = current; + } +} + +/// \fn apply_reverse_permutation ( RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, RandomAccessIterator2 ind_begin ) +/// \brief Reorder item sequence with index sequence order +/// +/// \param item_begin The start of the item sequence +/// \param item_end One past the end of the item sequence +/// \param ind_begin The start of the index sequence. +/// +/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined. +/// Complexity: O(N). +template<typename RandomAccessIterator1, typename RandomAccessIterator2> +void +apply_reverse_permutation( + RandomAccessIterator1 item_begin, + RandomAccessIterator1 item_end, + RandomAccessIterator2 ind_begin, + RandomAccessIterator2 ind_end) +{ + typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Diff; + using std::swap; + Diff length = std::distance(item_begin, item_end); + for (Diff i = 0; i < length; i++) + { + while (i != ind_begin[i]) + { + Diff next = ind_begin[i]; + swap(item_begin[i], item_begin[next]); + swap(ind_begin[i], ind_begin[next]); + } + } +} + +/// \fn apply_permutation ( Range1 item_range, Range2 ind_range ) +/// \brief Reorder item sequence with index sequence order +/// +/// \param item_range The item sequence +/// \param ind_range The index sequence +/// +/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined. +/// Complexity: O(N). +template<typename Range1, typename Range2> +void +apply_permutation(Range1& item_range, Range2& ind_range) +{ + apply_permutation(boost::begin(item_range), boost::end(item_range), + boost::begin(ind_range), boost::end(ind_range)); +} + +/// \fn apply_reverse_permutation ( Range1 item_range, Range2 ind_range ) +/// \brief Reorder item sequence with index sequence order +/// +/// \param item_range The item sequence +/// \param ind_range The index sequence +/// +/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined. +/// Complexity: O(N). +template<typename Range1, typename Range2> +void +apply_reverse_permutation(Range1& item_range, Range2& ind_range) +{ + apply_reverse_permutation(boost::begin(item_range), boost::end(item_range), + boost::begin(ind_range), boost::end(ind_range)); +} + +}} +#endif //BOOST_ALGORITHM_APPLY_PERMUTATION_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/clamp.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/clamp.hpp new file mode 100644 index 00000000000..2f160a0160d --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/clamp.hpp @@ -0,0 +1,176 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + Revision history: + 27 June 2009 mtc First version + 23 Oct 2010 mtc Added predicate version + +*/ + +/// \file clamp.hpp +/// \brief Clamp algorithm +/// \author Marshall Clow +/// +/// Suggested by olafvdspek in https://svn.boost.org/trac/boost/ticket/3215 + +#ifndef BOOST_ALGORITHM_CLAMP_HPP +#define BOOST_ALGORITHM_CLAMP_HPP + +#include <functional> // For std::less +#include <iterator> // For std::iterator_traits +#include <cassert> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/type_traits/type_identity.hpp> // for boost::type_identity +#include <boost/core/enable_if.hpp> // for boost::disable_if + +namespace boost { namespace algorithm { + +/// \fn clamp ( T const& val, +/// typename boost::type_identity<T>::type const & lo, +/// typename boost::type_identity<T>::type const & hi, Pred p ) +/// \return the value "val" brought into the range [ lo, hi ] +/// using the comparison predicate p. +/// If p ( val, lo ) return lo. +/// If p ( hi, val ) return hi. +/// Otherwise, return the original value. +/// +/// \param val The value to be clamped +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. +/// + template<typename T, typename Pred> + BOOST_CXX14_CONSTEXPR T const & clamp ( T const& val, + typename boost::type_identity<T>::type const & lo, + typename boost::type_identity<T>::type const & hi, Pred p ) + { +// assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal + return p ( val, lo ) ? lo : p ( hi, val ) ? hi : val; + } + + +/// \fn clamp ( T const& val, +/// typename boost::identity<T>::type const & lo, +/// typename boost::identity<T>::type const & hi ) +/// \return the value "val" brought into the range [ lo, hi ]. +/// If the value is less than lo, return lo. +/// If the value is greater than "hi", return hi. +/// Otherwise, return the original value. +/// +/// \param val The value to be clamped +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// + template<typename T> + BOOST_CXX14_CONSTEXPR T const& clamp ( const T& val, + typename boost::type_identity<T>::type const & lo, + typename boost::type_identity<T>::type const & hi ) + { + return boost::algorithm::clamp ( val, lo, hi, std::less<T>()); + } + +/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, +/// std::iterator_traits<InputIterator>::value_type const & lo, +/// std::iterator_traits<InputIterator>::value_type const & hi ) +/// \return clamp the sequence of values [first, last) into [ lo, hi ] +/// +/// \param first The start of the range of values +/// \param last One past the end of the range of input values +/// \param out An output iterator to write the clamped values into +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// + template<typename InputIterator, typename OutputIterator> + BOOST_CXX14_CONSTEXPR OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out, + typename std::iterator_traits<InputIterator>::value_type const & lo, + typename std::iterator_traits<InputIterator>::value_type const & hi ) + { + // this could also be written with bind and std::transform + while ( first != last ) + *out++ = boost::algorithm::clamp ( *first++, lo, hi ); + return out; + } + +/// \fn clamp_range ( const Range &r, OutputIterator out, +/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo, +/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi ) +/// \return clamp the sequence of values [first, last) into [ lo, hi ] +/// +/// \param r The range of values to be clamped +/// \param out An output iterator to write the clamped values into +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// + template<typename Range, typename OutputIterator> + BOOST_CXX14_CONSTEXPR typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type + clamp_range ( const Range &r, OutputIterator out, + typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo, + typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi ) + { + return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi ); + } + + +/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, +/// std::iterator_traits<InputIterator>::value_type const & lo, +/// std::iterator_traits<InputIterator>::value_type const & hi, Pred p ) +/// \return clamp the sequence of values [first, last) into [ lo, hi ] +/// using the comparison predicate p. +/// +/// \param first The start of the range of values +/// \param last One past the end of the range of input values +/// \param out An output iterator to write the clamped values into +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. + +/// + template<typename InputIterator, typename OutputIterator, typename Pred> + BOOST_CXX14_CONSTEXPR OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out, + typename std::iterator_traits<InputIterator>::value_type const & lo, + typename std::iterator_traits<InputIterator>::value_type const & hi, Pred p ) + { + // this could also be written with bind and std::transform + while ( first != last ) + *out++ = boost::algorithm::clamp ( *first++, lo, hi, p ); + return out; + } + +/// \fn clamp_range ( const Range &r, OutputIterator out, +/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo, +/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi, +/// Pred p ) +/// \return clamp the sequence of values [first, last) into [ lo, hi ] +/// using the comparison predicate p. +/// +/// \param r The range of values to be clamped +/// \param out An output iterator to write the clamped values into +/// \param lo The lower bound of the range to be clamped to +/// \param hi The upper bound of the range to be clamped to +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. +// +// Disable this template if the first two parameters are the same type; +// In that case, the user will get the two iterator version. + template<typename Range, typename OutputIterator, typename Pred> + BOOST_CXX14_CONSTEXPR typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type + clamp_range ( const Range &r, OutputIterator out, + typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo, + typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi, + Pred p ) + { + return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p ); + } + + +}} + +#endif // BOOST_ALGORITHM_CLAMP_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/all_of.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/all_of.hpp new file mode 100644 index 00000000000..f7ee311b28e --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/all_of.hpp @@ -0,0 +1,84 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file all_of.hpp +/// \brief Test ranges to see if all elements match a value or predicate. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_ALL_OF_HPP +#define BOOST_ALGORITHM_ALL_OF_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn all_of ( InputIterator first, InputIterator last, Predicate p ) +/// \return true if all elements in [first, last) satisfy the predicate 'p' +/// \note returns true on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p A predicate for testing the elements of the sequence +/// +/// \note This function is part of the C++2011 standard library. +template<typename InputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR bool all_of ( InputIterator first, InputIterator last, Predicate p ) +{ + for ( ; first != last; ++first ) + if ( !p(*first)) + return false; + return true; +} + +/// \fn all_of ( const Range &r, Predicate p ) +/// \return true if all elements in the range satisfy the predicate 'p' +/// \note returns true on an empty range +/// +/// \param r The input range +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename Predicate> +BOOST_CXX14_CONSTEXPR bool all_of ( const Range &r, Predicate p ) +{ + return boost::algorithm::all_of ( boost::begin (r), boost::end (r), p ); +} + +/// \fn all_of_equal ( InputIterator first, InputIterator last, const T &val ) +/// \return true if all elements in [first, last) are equal to 'val' +/// \note returns true on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param val A value to compare against +/// +template<typename InputIterator, typename T> +BOOST_CXX14_CONSTEXPR bool all_of_equal ( InputIterator first, InputIterator last, const T &val ) +{ + for ( ; first != last; ++first ) + if ( val != *first ) + return false; + return true; +} + +/// \fn all_of_equal ( const Range &r, const T &val ) +/// \return true if all elements in the range are equal to 'val' +/// \note returns true on an empty range +/// +/// \param r The input range +/// \param val A value to compare against +/// +template<typename Range, typename T> +BOOST_CXX14_CONSTEXPR bool all_of_equal ( const Range &r, const T &val ) +{ + return boost::algorithm::all_of_equal ( boost::begin (r), boost::end (r), val ); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_ALL_OF_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/any_of.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/any_of.hpp new file mode 100644 index 00000000000..51dfba1936b --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/any_of.hpp @@ -0,0 +1,85 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +/// \file +/// \brief Test ranges to see if any elements match a value or predicate. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_ANY_OF_HPP +#define BOOST_ALGORITHM_ANY_OF_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn any_of ( InputIterator first, InputIterator last, Predicate p ) +/// \return true if any of the elements in [first, last) satisfy the predicate +/// \note returns false on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p A predicate for testing the elements of the sequence +/// +template<typename InputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR bool any_of ( InputIterator first, InputIterator last, Predicate p ) +{ + for ( ; first != last; ++first ) + if ( p(*first)) + return true; + return false; +} + +/// \fn any_of ( const Range &r, Predicate p ) +/// \return true if any elements in the range satisfy the predicate 'p' +/// \note returns false on an empty range +/// +/// \param r The input range +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename Predicate> +BOOST_CXX14_CONSTEXPR bool any_of ( const Range &r, Predicate p ) +{ + return boost::algorithm::any_of (boost::begin (r), boost::end (r), p); +} + +/// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val ) +/// \return true if any of the elements in [first, last) are equal to 'val' +/// \note returns false on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param val A value to compare against +/// +template<typename InputIterator, typename V> +BOOST_CXX14_CONSTEXPR bool any_of_equal ( InputIterator first, InputIterator last, const V &val ) +{ + for ( ; first != last; ++first ) + if ( val == *first ) + return true; + return false; +} + +/// \fn any_of_equal ( const Range &r, const V &val ) +/// \return true if any of the elements in the range are equal to 'val' +/// \note returns false on an empty range +/// +/// \param r The input range +/// \param val A value to compare against +/// +template<typename Range, typename V> +BOOST_CXX14_CONSTEXPR bool any_of_equal ( const Range &r, const V &val ) +{ + return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_ANY_OF_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_if.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_if.hpp new file mode 100644 index 00000000000..307c2131048 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_if.hpp @@ -0,0 +1,211 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file copy_if.hpp +/// \brief Copy a subset of a sequence to a new sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_COPY_IF_HPP +#define BOOST_ALGORITHM_COPY_IF_HPP + +#include <utility> // for std::pair, std::make_pair + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +/// \brief Copies all the elements from the input range that satisfy the +/// predicate to the output range. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// \note This function is part of the C++2011 standard library. +template<typename InputIterator, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +{ + for ( ; first != last; ++first ) + if (p(*first)) + *result++ = *first; + return result; +} + +/// \fn copy_if ( const Range &r, OutputIterator result, Predicate p ) +/// \brief Copies all the elements from the input range that satisfy the +/// predicate to the output range. +/// \return The updated output iterator +/// +/// \param r The input range +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p ) +{ + return boost::algorithm::copy_if (boost::begin (r), boost::end(r), result, p); +} + + +/// \fn copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +/// \brief Copies all the elements at the start of the input range that +/// satisfy the predicate to the output range. +/// \return The updated input and output iterators +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// +template<typename InputIterator, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator> +copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +{ + for ( ; first != last && p(*first); ++first ) + *result++ = *first; + return std::make_pair(first, result); +} + +/// \fn copy_while ( const Range &r, OutputIterator result, Predicate p ) +/// \brief Copies all the elements at the start of the input range that +/// satisfy the predicate to the output range. +/// \return The updated input and output iterators +/// +/// \param r The input range +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_while ( const Range &r, OutputIterator result, Predicate p ) +{ + return boost::algorithm::copy_while (boost::begin (r), boost::end(r), result, p); +} + + +/// \fn copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +/// \brief Copies all the elements at the start of the input range that do not +/// satisfy the predicate to the output range. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// +template<typename InputIterator, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator> +copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p ) +{ + for ( ; first != last && !p(*first); ++first ) + *result++ = *first; + return std::make_pair(first, result); +} + +/// \fn copy_until ( const Range &r, OutputIterator result, Predicate p ) +/// \brief Copies all the elements at the start of the input range that do not +/// satisfy the predicate to the output range. +/// \return The updated output iterator +/// +/// \param r The input range +/// \param result An output iterator to write the results into +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename OutputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_until ( const Range &r, OutputIterator result, Predicate p ) +{ + return boost::algorithm::copy_until (boost::begin (r), boost::end(r), result, p); +} + +/// \fn copy_if_while ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred ) +/// \brief Copies all the elements from the input range that satisfy the +/// copy predicate to the output range while the termination predicate is +/// satisfied. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param result An output iterator to write the results into +/// \param copy_pred A predicate for testing whether to the current element +/// \param term_pred A predicate for testing whether to end the copy operation +template<typename InputIterator, typename OutputIterator, typename CopyPredicate, typename TerminatePred> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator> +copy_if_while ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred) +{ + for ( ; first != last && term_pred(*first); ++first ) { + if (copy_pred(*first)) { + *result++ = *first; + } + } + return std::make_pair(first, result); +} + +/// \fn copy_if_while ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred ) +/// \brief Copies all the elements from the input range that satisfy the +/// copy predicate to the output range while the termination predicate is +/// satisfied. +/// \return The updated output iterator +/// +/// \param r The input range +/// \param result An output iterator to write the results into +/// \param copy_pred A predicate for testing whether to the current element +/// \param term_pred A predicate for testing whether to end the copy operation +template<typename Range, typename OutputIterator, typename CopyPredicate, typename TerminatePred> +BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_if_while ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred) +{ + return boost::algorithm::copy_if_while(boost::begin(r), boost::end(r), result, copy_pred, term_pred); +} + +/// \fn copy_if_until ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred ) +/// \brief Copies all the elements from the input range that satisfy the +/// copy predicate to the output range until the termination predicate is +/// satisfied. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param result An output iterator to write the results into +/// \param copy_pred A predicate for testing whether to the current element +/// \param term_pred A predicate for testing whether to end the copy operation +template<typename InputIterator, typename OutputIterator, typename CopyPredicate, typename TerminatePred> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator> +copy_if_until ( InputIterator first, InputIterator last, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred) +{ + for ( ; first != last && !term_pred(*first); ++first ) { + if (copy_pred(*first)) { + *result++ = *first; + } + } + return std::make_pair(first, result); +} + +/// \fn copy_if_until ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred ) +/// \brief Copies all the elements from the input range that satisfy the +/// copy predicate to the output range until the termination predicate is +/// satisfied. +/// \return The updated output iterator +/// +/// \param r The input range +/// \param result An output iterator to write the results into +/// \param copy_pred A predicate for testing whether to the current element +/// \param term_pred A predicate for testing whether to end the copy operation +template<typename Range, typename OutputIterator, typename CopyPredicate, typename TerminatePred> +BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator> +copy_if_until ( const Range& r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred) +{ + return boost::algorithm::copy_if_until(boost::begin(r), boost::end(r), result, copy_pred, term_pred); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_COPY_IF_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_n.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_n.hpp new file mode 100644 index 00000000000..a0130fabe0a --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/copy_n.hpp @@ -0,0 +1,37 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file copy_n.hpp +/// \brief Copy n items from one sequence to another +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_COPY_N_HPP +#define BOOST_ALGORITHM_COPY_N_HPP + +#include <boost/config.hpp> + +namespace boost { namespace algorithm { + +/// \fn copy_n ( InputIterator first, Size n, OutputIterator result ) +/// \brief Copies exactly n (n > 0) elements from the range starting at first to +/// the range starting at result. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param n The number of elements to copy +/// \param result An output iterator to write the results into +/// \note This function is part of the C++2011 standard library. +template <typename InputIterator, typename Size, typename OutputIterator> +BOOST_CXX14_CONSTEXPR OutputIterator copy_n ( InputIterator first, Size n, OutputIterator result ) +{ + for ( ; n > 0; --n, ++first, ++result ) + *result = *first; + return result; +} +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_COPY_IF_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/find_if_not.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/find_if_not.hpp new file mode 100644 index 00000000000..cc81d297500 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/find_if_not.hpp @@ -0,0 +1,52 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file find_if_not.hpp +/// \brief Find the first element in a sequence that does not satisfy a predicate. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_FIND_IF_NOT_HPP +#define BOOST_ALGORITHM_FIND_IF_NOT_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn find_if_not(InputIterator first, InputIterator last, Predicate p) +/// \brief Finds the first element in the sequence that does not satisfy the predicate. +/// \return The iterator pointing to the desired element. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p A predicate for testing the elements of the range +/// \note This function is part of the C++2011 standard library. +template<typename InputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p ) +{ + for ( ; first != last; ++first ) + if ( !p(*first)) + break; + return first; +} + +/// \fn find_if_not ( const Range &r, Predicate p ) +/// \brief Finds the first element in the sequence that does not satisfy the predicate. +/// \return The iterator pointing to the desired element. +/// +/// \param r The input range +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename Predicate> +BOOST_CXX14_CONSTEXPR typename boost::range_iterator<const Range>::type find_if_not ( const Range &r, Predicate p ) +{ + return boost::algorithm::find_if_not (boost::begin (r), boost::end(r), p); +} + +}} +#endif // BOOST_ALGORITHM_FIND_IF_NOT_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/iota.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/iota.hpp new file mode 100644 index 00000000000..e8b2b62ff43 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/iota.hpp @@ -0,0 +1,66 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file iota.hpp +/// \brief Generate an increasing series +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_IOTA_HPP +#define BOOST_ALGORITHM_IOTA_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn iota ( ForwardIterator first, ForwardIterator last, T value ) +/// \brief Generates an increasing sequence of values, and stores them in [first, last) +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param value The initial value of the sequence to be generated +/// \note This function is part of the C++2011 standard library. +template <typename ForwardIterator, typename T> +BOOST_CXX14_CONSTEXPR void iota ( ForwardIterator first, ForwardIterator last, T value ) +{ + for ( ; first != last; ++first, ++value ) + *first = value; +} + +/// \fn iota ( Range &r, T value ) +/// \brief Generates an increasing sequence of values, and stores them in the input Range. +/// +/// \param r The input range +/// \param value The initial value of the sequence to be generated +/// +template <typename Range, typename T> +BOOST_CXX14_CONSTEXPR void iota ( Range &r, T value ) +{ + boost::algorithm::iota (boost::begin(r), boost::end(r), value); +} + + +/// \fn iota_n ( OutputIterator out, T value, std::size_t n ) +/// \brief Generates an increasing sequence of values, and stores them in the input Range. +/// +/// \param out An output iterator to write the results into +/// \param value The initial value of the sequence to be generated +/// \param n The number of items to write +/// +template <typename OutputIterator, typename T> +BOOST_CXX14_CONSTEXPR OutputIterator iota_n ( OutputIterator out, T value, std::size_t n ) +{ + for ( ; n > 0; --n, ++value ) + *out++ = value; + + return out; +} + +}} + +#endif // BOOST_ALGORITHM_IOTA_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_partitioned.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_partitioned.hpp new file mode 100644 index 00000000000..47abc2c8d10 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_partitioned.hpp @@ -0,0 +1,59 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file is_partitioned.hpp +/// \brief Tell if a sequence is partitioned +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_IS_PARTITIONED_HPP +#define BOOST_ALGORITHM_IS_PARTITIONED_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p The predicate to test the values with +/// \note This function is part of the C++2011 standard library. +template <typename InputIterator, typename UnaryPredicate> +BOOST_CXX14_CONSTEXPR bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) +{ +// Run through the part that satisfy the predicate + for ( ; first != last; ++first ) + if ( !p (*first)) + break; +// Now the part that does not satisfy the predicate + for ( ; first != last; ++first ) + if ( p (*first)) + return false; + return true; +} + +/// \fn is_partitioned ( const Range &r, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param r The input range +/// \param p The predicate to test the values with +/// +template <typename Range, typename UnaryPredicate> +BOOST_CXX14_CONSTEXPR bool is_partitioned ( const Range &r, UnaryPredicate p ) +{ + return boost::algorithm::is_partitioned (boost::begin(r), boost::end(r), p); +} + + +}} + +#endif // BOOST_ALGORITHM_IS_PARTITIONED_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_permutation.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_permutation.hpp new file mode 100644 index 00000000000..693f54a49ca --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_permutation.hpp @@ -0,0 +1,186 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file is_permutation.hpp +/// \brief Is a sequence a permutation of another sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_IS_PERMUTATION11_HPP +#define BOOST_ALGORITHM_IS_PERMUTATION11_HPP + +#include <algorithm> // for std::find_if, count_if, mismatch +#include <utility> // for std::pair +#include <functional> // for std::equal_to +#include <iterator> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace algorithm { + +/// \cond DOXYGEN_HIDE +namespace detail { + template <typename Predicate, typename Iterator> + struct value_predicate { + value_predicate ( Predicate p, Iterator it ) : p_ ( p ), it_ ( it ) {} + + template <typename T1> + bool operator () ( const T1 &t1 ) const { return p_ ( *it_, t1 ); } + private: + Predicate p_; + Iterator it_; + }; + +// Preconditions: +// 1. The sequences are the same length +// 2. Any common elements on the front have been removed (not necessary for correctness, just for performance) + template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > + bool is_permutation_inner ( ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate p ) { + // for each unique value in the sequence [first1,last1), count how many times + // it occurs, and make sure it occurs the same number of times in [first2, last2) + for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) { + value_predicate<BinaryPredicate, ForwardIterator1> pred ( p, iter ); + + /* For each value we haven't seen yet... */ + if ( std::find_if ( first1, iter, pred ) == iter ) { + std::size_t dest_count = std::count_if ( first2, last2, pred ); + if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred )) + return false; + } + } + + return true; + } + + template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> + bool is_permutation_tag ( ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate p, + std::forward_iterator_tag, std::forward_iterator_tag ) { + + // Skip the common prefix (if any) + while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) { + ++first1; + ++first2; + } + if ( first1 != last1 && first2 != last2 ) + return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, + std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ()); + return first1 == last1 && first2 == last2; + } + + template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate> + bool is_permutation_tag ( RandomAccessIterator1 first1, RandomAccessIterator1 last1, + RandomAccessIterator2 first2, RandomAccessIterator2 last2, + BinaryPredicate p, + std::random_access_iterator_tag, std::random_access_iterator_tag ) { + // Cheap check + if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 )) + return false; + // Skip the common prefix (if any) + while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) { + ++first1; + ++first2; + } + + if ( first1 != last1 && first2 != last2 ) + return is_permutation_inner (first1, last1, first2, last2, p); + return first1 == last1 && first2 == last2; + } + +} +/// \endcond + +/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2, BinaryPredicate p ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param first1 The start of the input sequence +/// \param last1 One past the end of the input sequence +/// \param first2 The start of the second sequence +/// \param p The predicate to compare elements with +/// +/// \note This function is part of the C++2011 standard library. +template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > +bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, BinaryPredicate p ) +{ +// Skip the common prefix (if any) + std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2, p); + first1 = eq.first; + first2 = eq.second; + if ( first1 != last1 ) { + // Create last2 + ForwardIterator2 last2 = first2; + std::advance ( last2, std::distance (first1, last1)); + return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, p ); + } + + return true; +} + +/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2 ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param first1 The start of the input sequence +/// \param last2 One past the end of the input sequence +/// \param first2 The start of the second sequence +/// \note This function is part of the C++2011 standard library. +template< class ForwardIterator1, class ForwardIterator2 > +bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2 ) +{ +// How should I deal with the idea that ForwardIterator1::value_type +// and ForwardIterator2::value_type could be different? Define my own comparison predicate? +// Skip the common prefix (if any) + std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2 ); + first1 = eq.first; + first2 = eq.second; + if ( first1 != last1 ) { + // Create last2 + ForwardIterator2 last2 = first2; + std::advance ( last2, std::distance (first1, last1)); + return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, + std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ()); + } + return true; +} + + +/// \fn is_permutation ( const Range &r, ForwardIterator first2 ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param r The input range +/// \param first2 The start of the second sequence +template <typename Range, typename ForwardIterator> +bool is_permutation ( const Range &r, ForwardIterator first2 ) +{ + return boost::algorithm::is_permutation (boost::begin (r), boost::end (r), first2 ); +} + +/// \fn is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param r The input range +/// \param first2 The start of the second sequence +/// \param pred The predicate to compare elements with +/// +// Disable this template when the first two parameters are the same type +// That way the non-range version will be chosen. +template <typename Range, typename ForwardIterator, typename BinaryPredicate> +typename boost::disable_if_c<boost::is_same<Range, ForwardIterator>::value, bool>::type +is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred ) +{ + return boost::algorithm::is_permutation (boost::begin (r), boost::end (r), first2, pred ); +} + +}} + +#endif // BOOST_ALGORITHM_IS_PERMUTATION11_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_sorted.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_sorted.hpp new file mode 100644 index 00000000000..2526a87281e --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/is_sorted.hpp @@ -0,0 +1,281 @@ +// Copyright (c) 2010 Nuovation System Designs, LLC +// Grant Erickson <gerickson@nuovations.com> +// +// Reworked somewhat by Marshall Clow; August 2010 +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/ for latest version. +// + +#ifndef BOOST_ALGORITHM_ORDERED_HPP +#define BOOST_ALGORITHM_ORDERED_HPP + +#include <functional> +#include <iterator> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/type_identity.hpp> // for boost::type_identity + +namespace boost { namespace algorithm { + +/// \fn is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p ) +/// \return the point in the sequence [first, last) where the elements are unordered +/// (according to the comparison predicate 'p'). +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// \param p A binary predicate that returns true if two elements are ordered. +/// + template <typename ForwardIterator, typename Pred> + BOOST_CXX14_CONSTEXPR ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p ) + { + if ( first == last ) return last; // the empty sequence is ordered + ForwardIterator next = first; + while ( ++next != last ) + { + if ( p ( *next, *first )) + return next; + first = next; + } + return last; + } + +/// \fn is_sorted_until ( ForwardIterator first, ForwardIterator last ) +/// \return the point in the sequence [first, last) where the elements are unordered +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last ) + { + typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; + return boost::algorithm::is_sorted_until ( first, last, std::less<value_type>()); + } + + +/// \fn is_sorted ( ForwardIterator first, ForwardIterator last, Pred p ) +/// \return whether or not the entire sequence is sorted +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// \param p A binary predicate that returns true if two elements are ordered. +/// + template <typename ForwardIterator, typename Pred> + BOOST_CXX14_CONSTEXPR bool is_sorted ( ForwardIterator first, ForwardIterator last, Pred p ) + { + return boost::algorithm::is_sorted_until (first, last, p) == last; + } + +/// \fn is_sorted ( ForwardIterator first, ForwardIterator last ) +/// \return whether or not the entire sequence is sorted +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR bool is_sorted ( ForwardIterator first, ForwardIterator last ) + { + return boost::algorithm::is_sorted_until (first, last) == last; + } + +/// +/// -- Range based versions of the C++11 functions +/// + +/// \fn is_sorted_until ( const R &range, Pred p ) +/// \return the point in the range R where the elements are unordered +/// (according to the comparison predicate 'p'). +/// +/// \param range The range to be tested. +/// \param p A binary predicate that returns true if two elements are ordered. +/// + template <typename R, typename Pred> + BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c< + boost::is_same<R, Pred>::value, + typename boost::range_iterator<const R> + >::type is_sorted_until ( const R &range, Pred p ) + { + return boost::algorithm::is_sorted_until ( boost::begin ( range ), boost::end ( range ), p ); + } + + +/// \fn is_sorted_until ( const R &range ) +/// \return the point in the range R where the elements are unordered +/// +/// \param range The range to be tested. +/// + template <typename R> + BOOST_CXX14_CONSTEXPR typename boost::range_iterator<const R>::type is_sorted_until ( const R &range ) + { + return boost::algorithm::is_sorted_until ( boost::begin ( range ), boost::end ( range )); + } + +/// \fn is_sorted ( const R &range, Pred p ) +/// \return whether or not the entire range R is sorted +/// (according to the comparison predicate 'p'). +/// +/// \param range The range to be tested. +/// \param p A binary predicate that returns true if two elements are ordered. +/// + template <typename R, typename Pred> + BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c< boost::is_same<R, Pred>::value, boost::type_identity<bool> >::type + is_sorted ( const R &range, Pred p ) + { + return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ), p ); + } + + +/// \fn is_sorted ( const R &range ) +/// \return whether or not the entire range R is sorted +/// +/// \param range The range to be tested. +/// + template <typename R> + BOOST_CXX14_CONSTEXPR bool is_sorted ( const R &range ) + { + return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range )); + } + + +/// +/// -- Range based versions of the C++11 functions +/// + +/// \fn is_increasing ( ForwardIterator first, ForwardIterator last ) +/// \return true if the entire sequence is increasing; i.e, each item is greater than or +/// equal to the previous one. +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// +/// \note This function will return true for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_strictly_increasing instead. + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR bool is_increasing ( ForwardIterator first, ForwardIterator last ) + { + typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; + return boost::algorithm::is_sorted (first, last, std::less<value_type>()); + } + + +/// \fn is_increasing ( const R &range ) +/// \return true if the entire sequence is increasing; i.e, each item is greater than or +/// equal to the previous one. +/// +/// \param range The range to be tested. +/// +/// \note This function will return true for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_strictly_increasing instead. + template <typename R> + BOOST_CXX14_CONSTEXPR bool is_increasing ( const R &range ) + { + return is_increasing ( boost::begin ( range ), boost::end ( range )); + } + + + +/// \fn is_decreasing ( ForwardIterator first, ForwardIterator last ) +/// \return true if the entire sequence is decreasing; i.e, each item is less than +/// or equal to the previous one. +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// +/// \note This function will return true for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_strictly_decreasing instead. + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR bool is_decreasing ( ForwardIterator first, ForwardIterator last ) + { + typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; + return boost::algorithm::is_sorted (first, last, std::greater<value_type>()); + } + +/// \fn is_decreasing ( const R &range ) +/// \return true if the entire sequence is decreasing; i.e, each item is less than +/// or equal to the previous one. +/// +/// \param range The range to be tested. +/// +/// \note This function will return true for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_strictly_decreasing instead. + template <typename R> + BOOST_CXX14_CONSTEXPR bool is_decreasing ( const R &range ) + { + return is_decreasing ( boost::begin ( range ), boost::end ( range )); + } + + + +/// \fn is_strictly_increasing ( ForwardIterator first, ForwardIterator last ) +/// \return true if the entire sequence is strictly increasing; i.e, each item is greater +/// than the previous one +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// +/// \note This function will return false for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_increasing instead. + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR bool is_strictly_increasing ( ForwardIterator first, ForwardIterator last ) + { + typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; + return boost::algorithm::is_sorted (first, last, std::less_equal<value_type>()); + } + +/// \fn is_strictly_increasing ( const R &range ) +/// \return true if the entire sequence is strictly increasing; i.e, each item is greater +/// than the previous one +/// +/// \param range The range to be tested. +/// +/// \note This function will return false for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_increasing instead. + template <typename R> + BOOST_CXX14_CONSTEXPR bool is_strictly_increasing ( const R &range ) + { + return is_strictly_increasing ( boost::begin ( range ), boost::end ( range )); + } + + +/// \fn is_strictly_decreasing ( ForwardIterator first, ForwardIterator last ) +/// \return true if the entire sequence is strictly decreasing; i.e, each item is less than +/// the previous one +/// +/// \param first The start of the sequence to be tested. +/// \param last One past the end of the sequence +/// +/// \note This function will return false for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_decreasing instead. + template <typename ForwardIterator> + BOOST_CXX14_CONSTEXPR bool is_strictly_decreasing ( ForwardIterator first, ForwardIterator last ) + { + typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; + return boost::algorithm::is_sorted (first, last, std::greater_equal<value_type>()); + } + +/// \fn is_strictly_decreasing ( const R &range ) +/// \return true if the entire sequence is strictly decreasing; i.e, each item is less than +/// the previous one +/// +/// \param range The range to be tested. +/// +/// \note This function will return false for sequences that contain items that compare +/// equal. If that is not what you intended, you should use is_decreasing instead. + template <typename R> + BOOST_CXX14_CONSTEXPR bool is_strictly_decreasing ( const R &range ) + { + return is_strictly_decreasing ( boost::begin ( range ), boost::end ( range )); + } + +}} // namespace boost + +#endif // BOOST_ALGORITHM_ORDERED_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/none_of.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/none_of.hpp new file mode 100644 index 00000000000..715c9ab01ec --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/none_of.hpp @@ -0,0 +1,83 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file none_of.hpp +/// \brief Test ranges to see if no elements match a value or predicate. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_NONE_OF_HPP +#define BOOST_ALGORITHM_NONE_OF_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn none_of ( InputIterator first, InputIterator last, Predicate p ) +/// \return true if none of the elements in [first, last) satisfy the predicate 'p' +/// \note returns true on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p A predicate for testing the elements of the sequence +/// +template<typename InputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR bool none_of ( InputIterator first, InputIterator last, Predicate p ) +{ + for ( ; first != last; ++first ) + if ( p(*first)) + return false; + return true; +} + +/// \fn none_of ( const Range &r, Predicate p ) +/// \return true if none of the elements in the range satisfy the predicate 'p' +/// \note returns true on an empty range +/// +/// \param r The input range +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename Predicate> +BOOST_CXX14_CONSTEXPR bool none_of ( const Range &r, Predicate p ) +{ + return boost::algorithm::none_of (boost::begin (r), boost::end (r), p ); +} + +/// \fn none_of_equal ( InputIterator first, InputIterator last, const V &val ) +/// \return true if none of the elements in [first, last) are equal to 'val' +/// \note returns true on an empty range +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param val A value to compare against +/// +template<typename InputIterator, typename V> +BOOST_CXX14_CONSTEXPR bool none_of_equal ( InputIterator first, InputIterator last, const V &val ) +{ + for ( ; first != last; ++first ) + if ( val == *first ) + return false; + return true; +} + +/// \fn none_of_equal ( const Range &r, const V &val ) +/// \return true if none of the elements in the range are equal to 'val' +/// \note returns true on an empty range +/// +/// \param r The input range +/// \param val A value to compare against +/// +template<typename Range, typename V> +BOOST_CXX14_CONSTEXPR bool none_of_equal ( const Range &r, const V & val ) +{ + return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_NONE_OF_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/one_of.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/one_of.hpp new file mode 100644 index 00000000000..52f77b67599 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/one_of.hpp @@ -0,0 +1,91 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file one_of.hpp +/// \brief Test ranges to see if only one element matches a value or predicate. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_ONE_OF_HPP +#define BOOST_ALGORITHM_ONE_OF_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/algorithm/cxx11/none_of.hpp> + + +namespace boost { namespace algorithm { + +/// \fn one_of ( InputIterator first, InputIterator last, Predicate p ) +/// \return true if the predicate 'p' is true for exactly one item in [first, last). +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p A predicate for testing the elements of the sequence +/// +template<typename InputIterator, typename Predicate> +BOOST_CXX14_CONSTEXPR bool one_of ( InputIterator first, InputIterator last, Predicate p ) +{ +// find_if + for (; first != last; ++first) + if (p(*first)) + break; + + if (first == last) + return false; // Didn't occur at all + return boost::algorithm::none_of (++first, last, p); +} + +/// \fn one_of ( const Range &r, Predicate p ) +/// \return true if the predicate 'p' is true for exactly one item in the range. +/// +/// \param r The input range +/// \param p A predicate for testing the elements of the range +/// +template<typename Range, typename Predicate> +BOOST_CXX14_CONSTEXPR bool one_of ( const Range &r, Predicate p ) +{ + return boost::algorithm::one_of ( boost::begin (r), boost::end (r), p ); +} + + +/// \fn one_of_equal ( InputIterator first, InputIterator last, const V &val ) +/// \return true if the value 'val' exists only once in [first, last). +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param val A value to compare against +/// +template<typename InputIterator, typename V> +BOOST_CXX14_CONSTEXPR bool one_of_equal ( InputIterator first, InputIterator last, const V &val ) +{ +// find + for (; first != last; ++first) + if (*first == val) + break; + + if (first == last) + return false; // Didn't occur at all + return boost::algorithm::none_of_equal (++first, last, val); +} + +/// \fn one_of_equal ( const Range &r, const V &val ) +/// \return true if the value 'val' exists only once in the range. +/// +/// \param r The input range +/// \param val A value to compare against +/// +template<typename Range, typename V> +BOOST_CXX14_CONSTEXPR bool one_of_equal ( const Range &r, const V &val ) +{ + return boost::algorithm::one_of_equal ( boost::begin (r), boost::end (r), val ); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_ALL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_copy.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_copy.hpp new file mode 100644 index 00000000000..635b1e7390e --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_copy.hpp @@ -0,0 +1,71 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file partition_copy.hpp +/// \brief Copy a subset of a sequence to a new sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_PARTITION_COPY_HPP +#define BOOST_ALGORITHM_PARTITION_COPY_HPP + +#include <utility> // for std::pair + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn partition_copy ( InputIterator first, InputIterator last, +/// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) +/// \brief Copies the elements that satisfy the predicate p from the range [first, last) +/// to the range beginning at d_first_true, and +/// copies the elements that do not satisfy p to the range beginning at d_first_false. +/// +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param out_true An output iterator to write the elements that satisfy the predicate into +/// \param out_false An output iterator to write the elements that do not satisfy the predicate into +/// \param p A predicate for dividing the elements of the input sequence. +/// +/// \note This function is part of the C++2011 standard library. +template <typename InputIterator, + typename OutputIterator1, typename OutputIterator2, typename UnaryPredicate> +BOOST_CXX14_CONSTEXPR std::pair<OutputIterator1, OutputIterator2> +partition_copy ( InputIterator first, InputIterator last, + OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) +{ + for ( ; first != last; ++first ) + if ( p (*first)) + *out_true++ = *first; + else + *out_false++ = *first; + return std::pair<OutputIterator1, OutputIterator2> ( out_true, out_false ); +} + +/// \fn partition_copy ( const Range &r, +/// OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p ) +/// +/// \param r The input range +/// \param out_true An output iterator to write the elements that satisfy the predicate into +/// \param out_false An output iterator to write the elements that do not satisfy the predicate into +/// \param p A predicate for dividing the elements of the input sequence. +/// +template <typename Range, typename OutputIterator1, typename OutputIterator2, + typename UnaryPredicate> +BOOST_CXX14_CONSTEXPR std::pair<OutputIterator1, OutputIterator2> +partition_copy ( const Range &r, OutputIterator1 out_true, OutputIterator2 out_false, + UnaryPredicate p ) +{ + return boost::algorithm::partition_copy + (boost::begin(r), boost::end(r), out_true, out_false, p ); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_PARTITION_COPY_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_point.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_point.hpp new file mode 100644 index 00000000000..aa184acbf41 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx11/partition_point.hpp @@ -0,0 +1,66 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file partition_point.hpp +/// \brief Find the partition point in a sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_PARTITION_POINT_HPP +#define BOOST_ALGORITHM_PARTITION_POINT_HPP + +#include <iterator> // for std::distance, advance + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn partition_point ( ForwardIterator first, ForwardIterator last, Predicate p ) +/// \brief Given a partitioned range, returns the partition point, i.e, the first element +/// that does not satisfy p +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p The predicate to test the values with +/// \note This function is part of the C++2011 standard library. +template <typename ForwardIterator, typename Predicate> +ForwardIterator partition_point ( ForwardIterator first, ForwardIterator last, Predicate p ) +{ + std::size_t dist = std::distance ( first, last ); + while ( first != last ) { + std::size_t d2 = dist / 2; + ForwardIterator ret_val = first; + std::advance (ret_val, d2); + if (p (*ret_val)) { + first = ++ret_val; + dist -= d2 + 1; + } + else { + last = ret_val; + dist = d2; + } + } + return first; +} + +/// \fn partition_point ( Range &r, Predicate p ) +/// \brief Given a partitioned range, returns the partition point +/// +/// \param r The input range +/// \param p The predicate to test the values with +/// +template <typename Range, typename Predicate> +typename boost::range_iterator<Range>::type partition_point ( Range &r, Predicate p ) +{ + return boost::algorithm::partition_point (boost::begin(r), boost::end(r), p); +} + + +}} + +#endif // BOOST_ALGORITHM_PARTITION_POINT_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/equal.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/equal.hpp new file mode 100644 index 00000000000..a1501baf9a4 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/equal.hpp @@ -0,0 +1,106 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file equal.hpp +/// \brief Test ranges to if they are equal +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_EQUAL_HPP +#define BOOST_ALGORITHM_EQUAL_HPP + +#include <iterator> + +#include <boost/config.hpp> + +namespace boost { namespace algorithm { + +namespace detail { + + template <class T1, class T2> + struct eq { + BOOST_CONSTEXPR bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;} + }; + + template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate> + BOOST_CXX14_CONSTEXPR + bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1, + RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred, + std::random_access_iterator_tag, std::random_access_iterator_tag ) + { + // Random-access iterators let is check the sizes in constant time + if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 )) + return false; + + // std::equal + for (; first1 != last1; ++first1, ++first2) + if (!pred(*first1, *first2)) + return false; + return true; + } + + template <class InputIterator1, class InputIterator2, class BinaryPredicate> + BOOST_CXX14_CONSTEXPR + bool equal ( InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred, + std::input_iterator_tag, std::input_iterator_tag ) + { + for (; first1 != last1 && first2 != last2; ++first1, ++first2 ) + if ( !pred(*first1, *first2 )) + return false; + + return first1 == last1 && first2 == last2; + } +} + +/// \fn equal ( InputIterator1 first1, InputIterator1 last1, +/// InputIterator2 first2, InputIterator2 last2, +/// BinaryPredicate pred ) +/// \return true if all elements in the two ranges are equal +/// +/// \param first1 The start of the first range. +/// \param last1 One past the end of the first range. +/// \param first2 The start of the second range. +/// \param last2 One past the end of the second range. +/// \param pred A predicate for comparing the elements of the ranges +template <class InputIterator1, class InputIterator2, class BinaryPredicate> +BOOST_CXX14_CONSTEXPR +bool equal ( InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred ) +{ + return boost::algorithm::detail::equal ( + first1, last1, first2, last2, pred, + typename std::iterator_traits<InputIterator1>::iterator_category (), + typename std::iterator_traits<InputIterator2>::iterator_category ()); +} + +/// \fn equal ( InputIterator1 first1, InputIterator1 last1, +/// InputIterator2 first2, InputIterator2 last2 ) +/// \return true if all elements in the two ranges are equal +/// +/// \param first1 The start of the first range. +/// \param last1 One past the end of the first range. +/// \param first2 The start of the second range. +/// \param last2 One past the end of the second range. +template <class InputIterator1, class InputIterator2> +BOOST_CXX14_CONSTEXPR +bool equal ( InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2 ) +{ + return boost::algorithm::detail::equal ( + first1, last1, first2, last2, + boost::algorithm::detail::eq< + typename std::iterator_traits<InputIterator1>::value_type, + typename std::iterator_traits<InputIterator2>::value_type> (), + typename std::iterator_traits<InputIterator1>::iterator_category (), + typename std::iterator_traits<InputIterator2>::iterator_category ()); +} + +// There are already range-based versions of these. + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_EQUAL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/is_permutation.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/is_permutation.hpp new file mode 100644 index 00000000000..e889347db09 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/is_permutation.hpp @@ -0,0 +1,80 @@ +/* + Copyright (c) Marshall Clow 2014. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file is_permutation.hpp +/// \brief Is a sequence a permutation of another sequence (four iterator versions) +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_IS_PERMUTATION14_HPP +#define BOOST_ALGORITHM_IS_PERMUTATION14_HPP + +#include <utility> // for std::pair +#include <functional> // for std::equal_to +#include <iterator> + +#include <boost/config.hpp> +#include <boost/algorithm/cxx11/is_permutation.hpp> +#include <boost/algorithm/cxx14/mismatch.hpp> + +namespace boost { namespace algorithm { + +/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, +/// ForwardIterator2 first2, ForwardIterator2 last2 ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param first1 The start of the input sequence +/// \param last2 One past the end of the input sequence +/// \param first2 The start of the second sequence +/// \param last1 One past the end of the second sequence +/// \note This function is part of the C++2014 standard library. +template< class ForwardIterator1, class ForwardIterator2 > +bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2 ) +{ +// How should I deal with the idea that ForwardIterator1::value_type +// and ForwardIterator2::value_type could be different? Define my own comparison predicate? + std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch + ( first1, last1, first2, last2 ); + if ( eq.first == last1 && eq.second == last2) + return true; + return boost::algorithm::detail::is_permutation_tag ( + eq.first, last1, eq.second, last2, + std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (), + typename std::iterator_traits<ForwardIterator1>::iterator_category (), + typename std::iterator_traits<ForwardIterator2>::iterator_category ()); +} + +/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, +/// ForwardIterator2 first2, ForwardIterator2 last2, +/// BinaryPredicate p ) +/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2 +/// +/// \param first1 The start of the input sequence +/// \param last1 One past the end of the input sequence +/// \param first2 The start of the second sequence +/// \param last2 One past the end of the second sequence +/// \param pred The predicate to compare elements with +/// +/// \note This function is part of the C++2014 standard library. +template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate > +bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred ) +{ + std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch + ( first1, last1, first2, last2, pred ); + if ( eq.first == last1 && eq.second == last2) + return true; + return boost::algorithm::detail::is_permutation_tag ( + first1, last1, first2, last2, pred, + typename std::iterator_traits<ForwardIterator1>::iterator_category (), + typename std::iterator_traits<ForwardIterator2>::iterator_category ()); +} + +}} + +#endif // BOOST_ALGORITHM_IS_PERMUTATION14_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/mismatch.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/mismatch.hpp new file mode 100644 index 00000000000..a1fafe80dfa --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx14/mismatch.hpp @@ -0,0 +1,66 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file mismatch.hpp +/// \brief Find the first mismatched element in a sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_MISMATCH_HPP +#define BOOST_ALGORITHM_MISMATCH_HPP + +#include <utility> // for std::pair + +#include <boost/config.hpp> + +namespace boost { namespace algorithm { + +/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, +/// InputIterator2 first2, InputIterator2 last2, +/// BinaryPredicate pred ) +/// \return a pair of iterators pointing to the first elements in the sequence that do not match +/// +/// \param first1 The start of the first range. +/// \param last1 One past the end of the first range. +/// \param first2 The start of the second range. +/// \param last2 One past the end of the second range. +/// \param pred A predicate for comparing the elements of the ranges +template <class InputIterator1, class InputIterator2, class BinaryPredicate> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch ( + InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + BinaryPredicate pred ) +{ + for (; first1 != last1 && first2 != last2; ++first1, ++first2) + if ( !pred ( *first1, *first2 )) + break; + return std::pair<InputIterator1, InputIterator2>(first1, first2); +} + +/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, +/// InputIterator2 first2, InputIterator2 last2 ) +/// \return a pair of iterators pointing to the first elements in the sequence that do not match +/// +/// \param first1 The start of the first range. +/// \param last1 One past the end of the first range. +/// \param first2 The start of the second range. +/// \param last2 One past the end of the second range. +template <class InputIterator1, class InputIterator2> +BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch ( + InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2 ) +{ + for (; first1 != last1 && first2 != last2; ++first1, ++first2) + if ( *first1 != *first2 ) + break; + return std::pair<InputIterator1, InputIterator2>(first1, first2); +} + +// There are already range-based versions of these. + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_MISMATCH_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/exclusive_scan.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/exclusive_scan.hpp new file mode 100644 index 00000000000..9dbfbe966e2 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/exclusive_scan.hpp @@ -0,0 +1,53 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file exclusive_scan.hpp +/// \brief ??? +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP +#define BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, class T, class BinaryOperation> +OutputIterator exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, BinaryOperation bOp) +{ + if (first != last) + { + T saved = init; + do + { + init = bOp(init, *first); + *result = saved; + saved = init; + ++result; + } while (++first != last); + } + return result; +} + +template<class InputIterator, class OutputIterator, class T> +OutputIterator exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return boost::algorithm::exclusive_scan(first, last, result, init, std::plus<VT>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_EXCLUSIVE_SCAN_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/for_each_n.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/for_each_n.hpp new file mode 100644 index 00000000000..59abb448d7c --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/for_each_n.hpp @@ -0,0 +1,39 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file for_each_n.hpp +/// \brief Apply a functor to the elements of a sequence +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_FOR_EACH_N_HPP +#define BOOST_ALGORITHM_FOR_EACH_N_HPP + +#include <utility> // for std::pair + +#include <boost/config.hpp> + +namespace boost { namespace algorithm { + +/// \fn for_each_n(InputIterator first, Size n, Function f); +/// \return first + n +/// +/// \param first The start of the first range. +/// \param n One past the end of the first range. +/// \param f A functor to apply to the elements of the sequence +/// \note If f returns a result, the result is ignored. +template<class InputIterator, class Size, class Function> +InputIterator for_each_n(InputIterator first, Size n, Function f) +{ + for ( ; n > 0; --n, ++first ) + f(*first); + + return first; +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_FOR_EACH_N_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/inclusive_scan.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/inclusive_scan.hpp new file mode 100644 index 00000000000..fcc9bc2dae6 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/inclusive_scan.hpp @@ -0,0 +1,61 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP +#define BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class OutputIterator, class T, class BinaryOperation> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation bOp, T init) +{ + for (; first != last; ++first, (void) ++result) { + init = bOp(init, *first); + *result = init; + } + return result; +} + + +template<class InputIterator, class OutputIterator, class BinaryOperation> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation bOp) +{ + if (first != last) { + typename std::iterator_traits<InputIterator>::value_type init = *first; + *result++ = init; + if (++first != last) + return boost::algorithm::inclusive_scan(first, last, result, bOp, init); + } + + return result; +} + +template<class InputIterator, class OutputIterator> +OutputIterator inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return boost::algorithm::inclusive_scan(first, last, result, std::plus<VT>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/reduce.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/reduce.hpp new file mode 100644 index 00000000000..35f217cf196 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/reduce.hpp @@ -0,0 +1,73 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file reduce.hpp +/// \brief Combine the elements of a sequence into a single value +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_REDUCE_HPP +#define BOOST_ALGORITHM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator, class T, class BinaryOperation> +T reduce(InputIterator first, InputIterator last, T init, BinaryOperation bOp) +{ + ; + for (; first != last; ++first) + init = bOp(init, *first); + return init; +} + +template<class InputIterator, class T> +T reduce(InputIterator first, InputIterator last, T init) +{ + typedef typename std::iterator_traits<InputIterator>::value_type VT; + return boost::algorithm::reduce(first, last, init, std::plus<VT>()); +} + +template<class InputIterator> +typename std::iterator_traits<InputIterator>::value_type +reduce(InputIterator first, InputIterator last) +{ + return boost::algorithm::reduce(first, last, + typename std::iterator_traits<InputIterator>::value_type()); +} + +template<class Range> +typename boost::range_value<Range>::type +reduce(const Range &r) +{ + return boost::algorithm::reduce(boost::begin(r), boost::end(r)); +} + +// Not sure that this won't be ambiguous (1) +template<class Range, class T> +T reduce(const Range &r, T init) +{ + return boost::algorithm::reduce(boost::begin (r), boost::end (r), init); +} + + +// Not sure that this won't be ambiguous (2) +template<class Range, class T, class BinaryOperation> +T reduce(const Range &r, T init, BinaryOperation bOp) +{ + return boost::algorithm::reduce(boost::begin(r), boost::end(r), init, bOp); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_REDUCE_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_exclusive_scan.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_exclusive_scan.hpp new file mode 100644 index 00000000000..86446b80378 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_exclusive_scan.hpp @@ -0,0 +1,62 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file transform_exclusive_scan.hpp +/// \brief ???? +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +/// \fn transform_exclusive_scan ( InputIterator first, InputIterator last, OutputIterator result, BinaryOperation bOp, UnaryOperation uOp, T init ) +/// \brief Transforms elements from the input range with uOp and then combines +/// those transformed elements with bOp such that the n-1th element and the nth +/// element are combined. Exclusivity means that the nth element is not +/// included in the nth combination. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last The end of the input sequence +/// \param result The output iterator to write the results into +/// \param bOp The operation for combining transformed input elements +/// \param uOp The operation for transforming input elements +/// \param init The initial value +/// +/// \note This function is part of the C++17 standard library +template<class InputIterator, class OutputIterator, class T, + class BinaryOperation, class UnaryOperation> +OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, + BinaryOperation bOp, UnaryOperation uOp) +{ + if (first != last) + { + T saved = init; + do + { + init = bOp(init, uOp(*first)); + *result = saved; + saved = init; + ++result; + } while (++first != last); + } + return result; +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp new file mode 100644 index 00000000000..9d877c02d3a --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp @@ -0,0 +1,89 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP +#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +/// \fn transform_inclusive_scan ( InputIterator first, InputIterator last, OutputIterator result, BinaryOperation bOp, UnaryOperation uOp, T init ) +/// \brief Transforms elements from the input range with uOp and then combines +/// those transformed elements with bOp such that the n-1th element and the nth +/// element are combined. Inclusivity means that the nth element is included in +/// the nth combination. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last The end of the input sequence +/// \param result The output iterator to write the results into +/// \param bOp The operation for combining transformed input elements +/// \param uOp The operation for transforming input elements +/// \param init The initial value +/// +/// \note This function is part of the C++17 standard library +template<class InputIterator, class OutputIterator, + class BinaryOperation, class UnaryOperation, class T> +OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation bOp, UnaryOperation uOp, + T init) +{ + for (; first != last; ++first, (void) ++result) { + init = bOp(init, uOp(*first)); + *result = init; + } + + return result; +} + +/// \fn transform_inclusive_scan ( InputIterator first, InputIterator last, OutputIterator result, BinaryOperation bOp, UnaryOperation uOp, T init ) +/// \brief Transforms elements from the input range with uOp and then combines +/// those transformed elements with bOp such that the n-1th element and the nth +/// element are combined. Inclusivity means that the nth element is included in +/// the nth combination. The first value will be used as the init. +/// \return The updated output iterator +/// +/// \param first The start of the input sequence +/// \param last The end of the input sequence +/// \param result The output iterator to write the results into +/// \param bOp The operation for combining transformed input elements +/// \param uOp The operation for transforming input elements +/// +/// \note This function is part of the C++17 standard library +template<class InputIterator, class OutputIterator, + class BinaryOperation, class UnaryOperation> +OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation bOp, UnaryOperation uOp) +{ + if (first != last) { + typename std::iterator_traits<InputIterator>::value_type init = uOp(*first); + *result++ = init; + if (++first != last) + return boost::algorithm::transform_inclusive_scan + (first, last, result, bOp, uOp, init); + } + + return result; +} + + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_reduce.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_reduce.hpp new file mode 100644 index 00000000000..1bef5d1ab03 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/cxx17/transform_reduce.hpp @@ -0,0 +1,56 @@ +/* + Copyright (c) Marshall Clow 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file transform_reduce.hpp +/// \brief Combine the (transformed) elements of a sequence (or two) into a single value. +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP +#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP + +#include <functional> // for std::plus +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +namespace boost { namespace algorithm { + +template<class InputIterator1, class InputIterator2, class T, + class BinaryOperation1, class BinaryOperation2> +T transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 bOp1, BinaryOperation2 bOp2) +{ + for (; first1 != last1; ++first1, (void) ++first2) + init = bOp1(init, bOp2(*first1, *first2)); + return init; +} + +template<class InputIterator, class T, + class BinaryOperation, class UnaryOperation> +T transform_reduce(InputIterator first, InputIterator last, + T init, BinaryOperation bOp, UnaryOperation uOp) +{ + for (; first != last; ++first) + init = bOp(init, uOp(*first)); + return init; +} + +template<class InputIterator1, class InputIterator2, class T> +T transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) +{ + return boost::algorithm::transform_reduce(first1, last1, first2, init, + std::plus<T>(), std::multiplies<T>()); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/find_backward.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/find_backward.hpp new file mode 100644 index 00000000000..5903203499d --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/find_backward.hpp @@ -0,0 +1,96 @@ +/* + Copyright (c) T. Zachary Laine 2018. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ +#ifndef BOOST_ALGORITHM_FIND_BACKWARD_HPP +#define BOOST_ALGORITHM_FIND_BACKWARD_HPP + +#include <utility> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +template<typename BidiIter, typename T> +BOOST_CXX14_CONSTEXPR +BidiIter find_backward(BidiIter first, BidiIter last, const T & x) +{ + BidiIter it = last; + while (it != first) { + if (*--it == x) + return it; + } + return last; +} + +template<typename Range, typename T> +BOOST_CXX14_CONSTEXPR +typename boost::range_iterator<Range>::type find_backward(Range & range, const T & x) +{ + return ::boost::algorithm::find_backward(boost::begin(range), boost::end(range), x); +} + +template<typename BidiIter, typename T> +BOOST_CXX14_CONSTEXPR +BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x) +{ + BidiIter it = last; + while (it != first) { + if (*--it != x) + return it; + } + return last; +} + +template<typename Range, typename T> +BOOST_CXX14_CONSTEXPR +typename boost::range_iterator<Range>::type find_not_backward(Range & range, const T & x) +{ + return ::boost::algorithm::find_not_backward(boost::begin(range), boost::end(range), x); +} + +template<typename BidiIter, typename Pred> +BOOST_CXX14_CONSTEXPR +BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p) +{ + BidiIter it = last; + while (it != first) { + if (p(*--it)) + return it; + } + return last; +} + +template<typename Range, typename Pred> +BOOST_CXX14_CONSTEXPR +typename boost::range_iterator<Range>::type find_if_backward(Range & range, Pred p) +{ + return ::boost::algorithm::find_if_backward(boost::begin(range), boost::end(range), p); +} + +template<typename BidiIter, typename Pred> +BOOST_CXX14_CONSTEXPR +BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p) +{ + BidiIter it = last; + while (it != first) { + if (!p(*--it)) + return it; + } + return last; +} + +template<typename Range, typename Pred> +BOOST_CXX14_CONSTEXPR +typename boost::range_iterator<Range>::type find_if_not_backward(Range & range, Pred p) +{ + return ::boost::algorithm::find_if_not_backward(boost::begin(range), boost::end(range), p); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_FIND_BACKWARD_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/find_not.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/find_not.hpp new file mode 100644 index 00000000000..cc9dc214f24 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/find_not.hpp @@ -0,0 +1,38 @@ +/* + Copyright (c) T. Zachary Laine 2018. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ +#ifndef BOOST_ALGORITHM_FIND_NOT_HPP +#define BOOST_ALGORITHM_FIND_NOT_HPP + +#include <utility> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +template<typename InputIter, typename Sentinel, typename T> +BOOST_CXX14_CONSTEXPR +InputIter find_not(InputIter first, Sentinel last, const T & x) +{ + for (; first != last; ++first) { + if (*first != x) + break; + } + return first; +} + +template<typename Range, typename T> +BOOST_CXX14_CONSTEXPR +typename boost::range_iterator<Range>::type find_not(Range & r, const T & x) +{ + return ::boost::algorithm::find_not(boost::begin(r), boost::end(r), x); +} + +}} // namespace boost and algorithm + +#endif // BOOST_ALGORITHM_FIND_NOT_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/gather.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/gather.hpp new file mode 100644 index 00000000000..e777f8bd162 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/gather.hpp @@ -0,0 +1,126 @@ +/* + Copyright 2008 Adobe Systems Incorporated + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + Revision history: + January 2008 mtc Version for Adobe Source Library + January 2013 mtc Version for Boost.Algorithm + +*/ + +/**************************************************************************************************/ + +/*! +\author Marshall Clow +\date January 2008 +*/ + +#ifndef BOOST_ALGORITHM_GATHER_HPP +#define BOOST_ALGORITHM_GATHER_HPP + +#include <algorithm> // for std::stable_partition +#include <functional> +#include <utility> // for std::make_pair + +#include <boost/config.hpp> +#include <boost/bind/bind.hpp> // for boost::bind +#include <boost/range/begin.hpp> // for boost::begin(range) +#include <boost/range/end.hpp> // for boost::end(range) + + +/**************************************************************************************************/ +/*! + \defgroup gather gather + \ingroup mutating_algorithm + + \c gather() takes a collection of elements defined by a pair of iterators and moves + the ones satisfying a predicate to them to a position (called the pivot) within + the sequence. The algorithm is stable. The result is a pair of iterators that + contains the items that satisfy the predicate. + + Given an sequence containing: + <pre> + 0 1 2 3 4 5 6 7 8 9 + </pre> + + a call to gather ( arr, arr + 10, arr + 4, IsEven ()) will result in: + + <pre> + 1 3 0 2 4 6 8 5 7 9 + |---|-----| + first | second + pivot + </pre> + + + The problem is broken down into two basic steps, namely, moving the items before the pivot + and then moving the items from the pivot to the end. These "moves" are done with calls to + stable_partition. + + \par Storage Requirements: + + The algorithm uses stable_partition, which will attempt to allocate temporary memory, + but will work in-situ if there is none available. + + \par Time Complexity: + + If there is sufficient memory available, the run time is linear in <code>N</code>. + If there is not any memory available, then the run time is <code>O(N log N)</code>. +*/ + +/**************************************************************************************************/ + +namespace boost { namespace algorithm { + +/**************************************************************************************************/ + +/*! + \ingroup gather + \brief iterator-based gather implementation +*/ + +template < + typename BidirectionalIterator, // models BidirectionalIterator + typename Pred> // models UnaryPredicate +std::pair<BidirectionalIterator, BidirectionalIterator> gather + ( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred ) +{ +// The first call partitions everything up to (but not including) the pivot element, +// while the second call partitions the rest of the sequence. + using namespace boost::placeholders; + return std::make_pair ( + std::stable_partition ( first, pivot, !boost::bind<bool> ( pred, _1 )), + std::stable_partition ( pivot, last, boost::bind<bool> ( pred, _1 ))); +} + +/**************************************************************************************************/ + +/*! + \ingroup gather + \brief range-based gather implementation +*/ + +template < + typename BidirectionalRange, // + typename Pred> // Pred models UnaryPredicate +std::pair< + typename boost::range_iterator<const BidirectionalRange>::type, + typename boost::range_iterator<const BidirectionalRange>::type> +gather ( + const BidirectionalRange &range, + typename boost::range_iterator<const BidirectionalRange>::type pivot, + Pred pred ) +{ + return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred ); +} + +/**************************************************************************************************/ + +}} // namespace + +/**************************************************************************************************/ + +#endif + diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/hex.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/hex.hpp new file mode 100644 index 00000000000..f9458046858 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/hex.hpp @@ -0,0 +1,326 @@ +/* + Copyright (c) Marshall Clow 2011-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + Thanks to Nevin for his comments/help. +*/ + +/* + General problem - turn a sequence of integral types into a sequence of hexadecimal characters. + - and back. +*/ + +/// \file hex.hpp +/// \brief Convert sequence of integral types into a sequence of hexadecimal +/// characters and back. Based on the MySQL functions HEX and UNHEX +/// \author Marshall Clow + +#ifndef BOOST_ALGORITHM_HEXHPP +#define BOOST_ALGORITHM_HEXHPP + +#include <iterator> // for std::iterator_traits +#include <stdexcept> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/exception/exception.hpp> +#include <boost/exception/info.hpp> +#include <boost/throw_exception.hpp> + +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> + + +namespace boost { namespace algorithm { + +/*! + \struct hex_decode_error + \brief Base exception class for all hex decoding errors +*/ /*! + \struct non_hex_input + \brief Thrown when a non-hex value (0-9, A-F) encountered when decoding. + Contains the offending character +*/ /*! + \struct not_enough_input + \brief Thrown when the input sequence unexpectedly ends + +*/ +struct BOOST_SYMBOL_VISIBLE hex_decode_error : virtual boost::exception, virtual std::exception {}; +struct BOOST_SYMBOL_VISIBLE not_enough_input : virtual hex_decode_error {}; +struct BOOST_SYMBOL_VISIBLE non_hex_input : virtual hex_decode_error {}; +typedef boost::error_info<struct bad_char_,char> bad_char; + +namespace detail { +/// \cond DOXYGEN_HIDE + + template <typename T, typename OutputIterator> + OutputIterator encode_one ( T val, OutputIterator out, const char * hexDigits ) { + const std::size_t num_hex_digits = 2 * sizeof ( T ); + char res [ num_hex_digits ]; + char *p = res + num_hex_digits; + for ( std::size_t i = 0; i < num_hex_digits; ++i, val >>= 4 ) + *--p = hexDigits [ val & 0x0F ]; + return std::copy ( res, res + num_hex_digits, out ); + } + + template <typename T> + unsigned char hex_char_to_int ( T val ) { + char c = static_cast<char> ( val ); + unsigned retval = 0; + if ( c >= '0' && c <= '9' ) retval = c - '0'; + else if ( c >= 'A' && c <= 'F' ) retval = c - 'A' + 10; + else if ( c >= 'a' && c <= 'f' ) retval = c - 'a' + 10; + else BOOST_THROW_EXCEPTION (non_hex_input() << bad_char (c)); + return static_cast<char>(retval); + } + +// My own iterator_traits class. +// It is here so that I can "reach inside" some kinds of output iterators +// and get the type to write. + template <typename Iterator> + struct hex_iterator_traits { + typedef typename std::iterator_traits<Iterator>::value_type value_type; + }; + + template<typename Container> + struct hex_iterator_traits< std::back_insert_iterator<Container> > { + typedef typename Container::value_type value_type; + }; + + template<typename Container> + struct hex_iterator_traits< std::front_insert_iterator<Container> > { + typedef typename Container::value_type value_type; + }; + + template<typename Container> + struct hex_iterator_traits< std::insert_iterator<Container> > { + typedef typename Container::value_type value_type; + }; + +// ostream_iterators have three template parameters. +// The first one is the output type, the second one is the character type of +// the underlying stream, the third is the character traits. +// We only care about the first one. + template<typename T, typename charType, typename traits> + struct hex_iterator_traits< std::ostream_iterator<T, charType, traits> > { + typedef T value_type; + }; + + template <typename Iterator> + bool iter_end ( Iterator current, Iterator last ) { return current == last; } + + template <typename T> + bool ptr_end ( const T* ptr, const T* /*end*/ ) { return *ptr == '\0'; } + +// What can we assume here about the inputs? +// is std::iterator_traits<InputIterator>::value_type always 'char' ? +// Could it be wchar_t, say? Does it matter? +// We are assuming ASCII for the values - but what about the storage? + template <typename InputIterator, typename OutputIterator, typename EndPred> + typename boost::enable_if<boost::is_integral<typename hex_iterator_traits<OutputIterator>::value_type>, OutputIterator>::type + decode_one ( InputIterator &first, InputIterator last, OutputIterator out, EndPred pred ) { + typedef typename hex_iterator_traits<OutputIterator>::value_type T; + T res (0); + + // Need to make sure that we get can read that many chars here. + for ( std::size_t i = 0; i < 2 * sizeof ( T ); ++i, ++first ) { + if ( pred ( first, last )) + BOOST_THROW_EXCEPTION (not_enough_input ()); + res = ( 16 * res ) + hex_char_to_int (*first); + } + + *out = res; + return ++out; + } +/// \endcond + } + + +/// \fn hex ( InputIterator first, InputIterator last, OutputIterator out ) +/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename InputIterator, typename OutputIterator> +typename boost::enable_if<boost::is_integral<typename detail::hex_iterator_traits<InputIterator>::value_type>, OutputIterator>::type +hex ( InputIterator first, InputIterator last, OutputIterator out ) { + for ( ; first != last; ++first ) + out = detail::encode_one ( *first, out, "0123456789ABCDEF" ); + return out; + } + + +/// \fn hex_lower ( InputIterator first, InputIterator last, OutputIterator out ) +/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename InputIterator, typename OutputIterator> +typename boost::enable_if<boost::is_integral<typename detail::hex_iterator_traits<InputIterator>::value_type>, OutputIterator>::type +hex_lower ( InputIterator first, InputIterator last, OutputIterator out ) { + for ( ; first != last; ++first ) + out = detail::encode_one ( *first, out, "0123456789abcdef" ); + return out; + } + + +/// \fn hex ( const T *ptr, OutputIterator out ) +/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. +/// +/// \param ptr A pointer to a 0-terminated sequence of data. +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename T, typename OutputIterator> +typename boost::enable_if<boost::is_integral<T>, OutputIterator>::type +hex ( const T *ptr, OutputIterator out ) { + while ( *ptr ) + out = detail::encode_one ( *ptr++, out, "0123456789ABCDEF" ); + return out; + } + + +/// \fn hex_lower ( const T *ptr, OutputIterator out ) +/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. +/// +/// \param ptr A pointer to a 0-terminated sequence of data. +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename T, typename OutputIterator> +typename boost::enable_if<boost::is_integral<T>, OutputIterator>::type +hex_lower ( const T *ptr, OutputIterator out ) { + while ( *ptr ) + out = detail::encode_one ( *ptr++, out, "0123456789abcdef" ); + return out; + } + + +/// \fn hex ( const Range &r, OutputIterator out ) +/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. +/// +/// \param r The input range +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename Range, typename OutputIterator> +typename boost::enable_if<boost::is_integral<typename detail::hex_iterator_traits<typename Range::iterator>::value_type>, OutputIterator>::type +hex ( const Range &r, OutputIterator out ) { + return hex (boost::begin(r), boost::end(r), out); +} + + +/// \fn hex_lower ( const Range &r, OutputIterator out ) +/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. +/// +/// \param r The input range +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename Range, typename OutputIterator> +typename boost::enable_if<boost::is_integral<typename detail::hex_iterator_traits<typename Range::iterator>::value_type>, OutputIterator>::type +hex_lower ( const Range &r, OutputIterator out ) { + return hex_lower (boost::begin(r), boost::end(r), out); +} + + +/// \fn unhex ( InputIterator first, InputIterator last, OutputIterator out ) +/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename InputIterator, typename OutputIterator> +OutputIterator unhex ( InputIterator first, InputIterator last, OutputIterator out ) { + while ( first != last ) + out = detail::decode_one ( first, last, out, detail::iter_end<InputIterator> ); + return out; + } + + +/// \fn unhex ( const T *ptr, OutputIterator out ) +/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. +/// +/// \param ptr A pointer to a null-terminated input sequence. +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename T, typename OutputIterator> +OutputIterator unhex ( const T *ptr, OutputIterator out ) { +// If we run into the terminator while decoding, we will throw a +// malformed input exception. It would be nicer to throw a 'Not enough input' +// exception - but how much extra work would that require? + while ( *ptr ) + out = detail::decode_one ( ptr, (const T *) NULL, out, detail::ptr_end<T> ); + return out; + } + + +/// \fn OutputIterator unhex ( const Range &r, OutputIterator out ) +/// \brief Converts a sequence of hexadecimal characters into a sequence of integers. +/// +/// \param r The input range +/// \param out An output iterator to the results into +/// \return The updated output iterator +/// \note Based on the MySQL function of the same name +template <typename Range, typename OutputIterator> +OutputIterator unhex ( const Range &r, OutputIterator out ) { + return unhex (boost::begin(r), boost::end(r), out); + } + + +/// \fn String hex ( const String &input ) +/// \brief Converts a sequence of integral types into a hexadecimal sequence of characters. +/// +/// \param input A container to be converted +/// \return A container with the encoded text +template<typename String> +String hex ( const String &input ) { + String output; + output.reserve (input.size () * (2 * sizeof (typename String::value_type))); + (void) hex (input, std::back_inserter (output)); + return output; + } + + +/// \fn String hex_lower ( const String &input ) +/// \brief Converts a sequence of integral types into a lower case hexadecimal sequence of characters. +/// +/// \param input A container to be converted +/// \return A container with the encoded text +template<typename String> +String hex_lower ( const String &input ) { + String output; + output.reserve (input.size () * (2 * sizeof (typename String::value_type))); + (void) hex_lower (input, std::back_inserter (output)); + return output; + } + + +/// \fn String unhex ( const String &input ) +/// \brief Converts a sequence of hexadecimal characters into a sequence of characters. +/// +/// \param input A container to be converted +/// \return A container with the decoded text +template<typename String> +String unhex ( const String &input ) { + String output; + output.reserve (input.size () / (2 * sizeof (typename String::value_type))); + (void) unhex (input, std::back_inserter (output)); + return output; + } + +}} + +#endif // BOOST_ALGORITHM_HEXHPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/is_clamped.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_clamped.hpp new file mode 100644 index 00000000000..72287d30209 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_clamped.hpp @@ -0,0 +1,72 @@ +/* + Copyright (c) Ivan Matek, Marshall Clow 2021. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +*/ + +/// \file is_clamped.hpp +/// \brief IsClamped algorithm +/// \authors Ivan Matek, Marshall Clow +/// + +#ifndef BOOST_ALGORITHM_IS_CLAMPED_HPP +#define BOOST_ALGORITHM_IS_CLAMPED_HPP + +#include <functional> // for std::less +#include <cassert> + +#include <boost/type_traits/type_identity.hpp> // for boost::type_identity + +namespace boost { namespace algorithm { + +/// \fn is_clamped ( T const& val, +/// typename boost::type_identity<T>::type const & lo, +/// typename boost::type_identity<T>::type const & hi, Pred p ) +/// \returns true if value "val" is in the range [ lo, hi ] +/// using the comparison predicate p. +/// If p ( val, lo ) return false. +/// If p ( hi, val ) return false. +/// Otherwise, returns true. +/// +/// \param val The value to be checked +/// \param lo The lower bound of the range +/// \param hi The upper bound of the range +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. +/// + template <typename T, typename Pred> + BOOST_CXX14_CONSTEXPR bool is_clamped( + T const& val, typename boost::type_identity<T>::type const& lo, + typename boost::type_identity<T>::type const& hi, Pred p) { + // assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they + // might be equal + return p(val, lo) ? false : p(hi, val) ? false : true; + } + +/// \fn is_clamped ( T const& val, +/// typename boost::type_identity<T>::type const & lo, +/// typename boost::type_identity<T>::type const & hi) +/// \returns true if value "val" is in the range [ lo, hi ] +/// using operator < for comparison. +/// If the value is less than lo, return false. +/// If the value is greater than hi, return false. +/// Otherwise, returns true. +/// +/// \param val The value to be checked +/// \param lo The lower bound of the range +/// \param hi The upper bound of the range +/// + + template<typename T> + BOOST_CXX14_CONSTEXPR bool is_clamped ( const T& val, + typename boost::type_identity<T>::type const & lo, + typename boost::type_identity<T>::type const & hi ) + { + return boost::algorithm::is_clamped ( val, lo, hi, std::less<T>()); + } + +}} + +#endif // BOOST_ALGORITHM_CLAMP_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/is_palindrome.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_palindrome.hpp new file mode 100644 index 00000000000..531f82ecf9a --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_palindrome.hpp @@ -0,0 +1,141 @@ +/* + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2016 + + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + + See http://www.boost.org/ for latest version. +*/ + +/// \file is_palindrome.hpp +/// \brief Checks the input sequence on palindrome. +/// \author Alexander Zaitsev + +#ifndef BOOST_ALGORITHM_IS_PALINDROME_HPP +#define BOOST_ALGORITHM_IS_PALINDROME_HPP + +#include <iterator> +#include <functional> +#include <cstring> + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn is_palindrome ( BidirectionalIterator begin, BidirectionalIterator end, Predicate p ) +/// \return true if the entire sequence is palindrome +/// +/// \param begin The start of the input sequence +/// \param end One past the end of the input sequence +/// \param p A predicate used to compare the values. +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +template <typename BidirectionalIterator, typename Predicate> +bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end, Predicate p) +{ + if(begin == end) + { + return true; + } + + --end; + while(begin != end) + { + if(!p(*begin, *end)) + { + return false; + } + ++begin; + if(begin == end) + { + break; + } + --end; + } + return true; +} + +/// \fn is_palindrome ( BidirectionalIterator begin, BidirectionalIterator end ) +/// \return true if the entire sequence is palindrome +/// +/// \param begin The start of the input sequence +/// \param end One past the end of the input sequence +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +template <typename BidirectionalIterator> +bool is_palindrome(BidirectionalIterator begin, BidirectionalIterator end) +{ + return is_palindrome(begin, end, + std::equal_to<typename std::iterator_traits<BidirectionalIterator>::value_type> ()); +} + +/// \fn is_palindrome ( const R& range ) +/// \return true if the entire sequence is palindrome +/// +/// \param range The range to be tested. +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +template <typename R> +bool is_palindrome(const R& range) +{ + return is_palindrome(boost::begin(range), boost::end(range)); +} + +/// \fn is_palindrome ( const R& range, Predicate p ) +/// \return true if the entire sequence is palindrome +/// +/// \param range The range to be tested. +/// \param p A predicate used to compare the values. +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +template <typename R, typename Predicate> +bool is_palindrome(const R& range, Predicate p) +{ + return is_palindrome(boost::begin(range), boost::end(range), p); +} + +/// \fn is_palindrome ( const char* str ) +/// \return true if the entire sequence is palindrome +/// +/// \param str C-string to be tested. +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +inline bool is_palindrome(const char* str) +{ + if(!str) + return true; + return is_palindrome(str, str + strlen(str)); +} + +/// \fn is_palindrome ( const char* str, Predicate p ) +/// \return true if the entire sequence is palindrome +/// +/// \param str C-string to be tested. +/// \param p A predicate used to compare the values. +/// +/// \note This function will return true for empty sequences and for palindromes. +/// For other sequences function will return false. +/// Complexity: O(N). +template<typename Predicate> +bool is_palindrome(const char* str, Predicate p) +{ + if(!str) + return true; + return is_palindrome(str, str + strlen(str), p); +} +}} + +#endif // BOOST_ALGORITHM_IS_PALINDROME_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/is_partitioned_until.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_partitioned_until.hpp new file mode 100644 index 00000000000..bf3ac6722fe --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/is_partitioned_until.hpp @@ -0,0 +1,64 @@ +/* + Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.by>, 2017. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +/// \file is_partitioned_until.hpp +/// \brief Tell if a sequence is partitioned +/// \author Alexander Zaitsev + +#ifndef BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP +#define BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param first The start of the input sequence +/// \param last One past the end of the input sequence +/// \param p The predicate to test the values with +/// +/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. +/// Returns last if the entire sequence is partitioned. +/// Complexity: O(N). +template <typename InputIterator, typename UnaryPredicate> +InputIterator is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p ) +{ +// Run through the part that satisfy the predicate + for ( ; first != last; ++first ) + if ( !p (*first)) + break; +// Now the part that does not satisfy the predicate + for ( ; first != last; ++first ) + if ( p (*first)) + return first; + return last; +} + +/// \fn is_partitioned_until ( const Range &r, UnaryPredicate p ) +/// \brief Tests to see if a sequence is partitioned according to a predicate. +/// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence. +/// +/// \param r The input range +/// \param p The predicate to test the values with +/// +/// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false. +/// Returns last if the entire sequence is partitioned. +/// Complexity: O(N). +template <typename Range, typename UnaryPredicate> +typename boost::range_iterator<const Range>::type is_partitioned_until ( const Range &r, UnaryPredicate p ) +{ + return boost::algorithm::is_partitioned_until (boost::begin(r), boost::end(r), p); +} + +}} + +#endif // BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax.hpp new file mode 100644 index 00000000000..c1aadb290d0 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax.hpp @@ -0,0 +1,48 @@ +// (C) Copyright Herve Bronnimann 2004. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 1 July 2004 + Split the code into two headers to lessen dependence on + Boost.tuple. (Herve) + 26 June 2004 + Added the code for the boost minmax library. (Herve) +*/ + +#ifndef BOOST_ALGORITHM_MINMAX_HPP +#define BOOST_ALGORITHM_MINMAX_HPP + +/* PROPOSED STANDARD EXTENSIONS: + * + * minmax(a, b) + * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b); + * + * minmax(a, b, comp) + * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b); + * + */ + +#include <boost/config.hpp> +#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref +#include <boost/ref.hpp> + +namespace boost { + + template <typename T> + tuple< T const&, T const& > + minmax(T const& a, T const& b) { + return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); + } + + template <typename T, class BinaryPredicate> + tuple< T const&, T const& > + minmax(T const& a, T const& b, BinaryPredicate comp) { + return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); + } + +} // namespace boost + +#endif // BOOST_ALGORITHM_MINMAX_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax_element.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax_element.hpp new file mode 100644 index 00000000000..651a552fe16 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/minmax_element.hpp @@ -0,0 +1,555 @@ +// (C) Copyright Herve Bronnimann 2004. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 1 July 2004 + Split the code into two headers to lessen dependence on + Boost.tuple. (Herve) + 26 June 2004 + Added the code for the boost minmax library. (Herve) +*/ + +#ifndef BOOST_ALGORITHM_MINMAX_ELEMENT_HPP +#define BOOST_ALGORITHM_MINMAX_ELEMENT_HPP + +/* PROPOSED STANDARD EXTENSIONS: + * + * minmax_element(first, last) + * Effect: std::make_pair( std::min_element(first, last), + * std::max_element(first, last) ); + * + * minmax_element(first, last, comp) + * Effect: std::make_pair( std::min_element(first, last, comp), + * std::max_element(first, last, comp) ); + */ + +#include <utility> // for std::pair and std::make_pair + +#include <boost/config.hpp> + +namespace boost { + + namespace detail { // for obtaining a uniform version of minmax_element + // that compiles with VC++ 6.0 -- avoid the iterator_traits by + // having comparison object over iterator, not over dereferenced value + + template <typename Iterator> + struct less_over_iter { + bool operator()(Iterator const& it1, + Iterator const& it2) const { return *it1 < *it2; } + }; + + template <typename Iterator, class BinaryPredicate> + struct binary_pred_over_iter { + explicit binary_pred_over_iter(BinaryPredicate const& p ) : m_p( p ) {} + bool operator()(Iterator const& it1, + Iterator const& it2) const { return m_p(*it1, *it2); } + private: + BinaryPredicate m_p; + }; + + // common base for the two minmax_element overloads + + template <typename ForwardIter, class Compare > + std::pair<ForwardIter,ForwardIter> + basic_minmax_element(ForwardIter first, ForwardIter last, Compare comp) + { + if (first == last) + return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + // if only one element + ForwardIter second = first; ++second; + if (second == last) + return std::make_pair(min_result, max_result); + + // treat first pair separately (only one comparison for first two elements) + ForwardIter potential_min_result = last; + if (comp(first, second)) + max_result = second; + else { + min_result = second; + potential_min_result = first; + } + + // then each element by pairs, with at most 3 comparisons per pair + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (comp(first, min_result)) { + min_result = first; + potential_min_result = last; + } + if (comp(max_result, second)) + max_result = second; + } else { + if (comp(second, min_result)) { + min_result = second; + potential_min_result = first; + } + if (comp(max_result, first)) + max_result = first; + } + first = ++second; + if (first != last) ++second; + } + + // if odd number of elements, treat last element + if (first != last) { // odd number of elements + if (comp(first, min_result)) { + min_result = first; + potential_min_result = last; + } + else if (comp(max_result, first)) + max_result = first; + } + + // resolve min_result being incorrect with one extra comparison + // (in which case potential_min_result is necessarily the correct result) + if (potential_min_result != last + && !comp(min_result, potential_min_result)) + min_result = potential_min_result; + + return std::make_pair(min_result,max_result); + } + + } // namespace detail + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + minmax_element(ForwardIter first, ForwardIter last) + { + return detail::basic_minmax_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + minmax_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_minmax_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + +} + +/* PROPOSED BOOST EXTENSIONS + * In the description below, [rfirst,rlast) denotes the reversed range + * of [first,last). Even though the iterator type of first and last may + * be only a Forward Iterator, it is possible to explain the semantics + * by assuming that it is a Bidirectional Iterator. In the sequel, + * reverse(ForwardIterator&) returns the reverse_iterator adaptor. + * This is not how the functions would be implemented! + * + * first_min_element(first, last) + * Effect: std::min_element(first, last); + * + * first_min_element(first, last, comp) + * Effect: std::min_element(first, last, comp); + * + * last_min_element(first, last) + * Effect: reverse( std::min_element(reverse(last), reverse(first)) ); + * + * last_min_element(first, last, comp) + * Effect: reverse( std::min_element(reverse(last), reverse(first), comp) ); + * + * first_max_element(first, last) + * Effect: std::max_element(first, last); + * + * first_max_element(first, last, comp) + * Effect: max_element(first, last); + * + * last_max_element(first, last) + * Effect: reverse( std::max_element(reverse(last), reverse(first)) ); + * + * last_max_element(first, last, comp) + * Effect: reverse( std::max_element(reverse(last), reverse(first), comp) ); + * + * first_min_first_max_element(first, last) + * Effect: std::make_pair( first_min_element(first, last), + * first_max_element(first, last) ); + * + * first_min_first_max_element(first, last, comp) + * Effect: std::make_pair( first_min_element(first, last, comp), + * first_max_element(first, last, comp) ); + * + * first_min_last_max_element(first, last) + * Effect: std::make_pair( first_min_element(first, last), + * last_max_element(first, last) ); + * + * first_min_last_max_element(first, last, comp) + * Effect: std::make_pair( first_min_element(first, last, comp), + * last_max_element(first, last, comp) ); + * + * last_min_first_max_element(first, last) + * Effect: std::make_pair( last_min_element(first, last), + * first_max_element(first, last) ); + * + * last_min_first_max_element(first, last, comp) + * Effect: std::make_pair( last_min_element(first, last, comp), + * first_max_element(first, last, comp) ); + * + * last_min_last_max_element(first, last) + * Effect: std::make_pair( last_min_element(first, last), + * last_max_element(first, last) ); + * + * last_min_last_max_element(first, last, comp) + * Effect: std::make_pair( last_min_element(first, last, comp), + * last_max_element(first, last, comp) ); + */ + +namespace boost { + + // Min_element and max_element variants + + namespace detail { // common base for the overloads + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_first_min_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter min_result = first; + while (++first != last) + if (comp(first, min_result)) + min_result = first; + return min_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_last_min_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter min_result = first; + while (++first != last) + if (!comp(min_result, first)) + min_result = first; + return min_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter max_result = first; + while (++first != last) + if (comp(max_result, first)) + max_result = first; + return max_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter max_result = first; + while (++first != last) + if (!comp(first, max_result)) + max_result = first; + return max_result; + } + + } // namespace detail + + template <typename ForwardIter> + ForwardIter + first_min_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_min_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + first_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_first_min_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + last_min_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + last_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_last_min_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + first_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + first_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_first_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + last_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + + // Minmax_element variants -- comments removed + + namespace detail { + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_first_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) + return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = ++first; + if (second == last) + return std::make_pair(min_result, max_result); + + if (comp(second, min_result)) + min_result = second; + else + max_result = second; + + first = ++second; if (first != last) ++second; + while (second != last) { + if (!comp(second, first)) { + if (comp(first, min_result)) + min_result = first; + if (!comp(second, max_result)) + max_result = second; + } else { + if (comp(second, min_result)) + min_result = second; + if (!comp(first, max_result)) + max_result = first; + } + first = ++second; if (first != last) ++second; + } + + if (first != last) { + if (comp(first, min_result)) + min_result = first; + else if (!comp(first, max_result)) + max_result = first; + } + + return std::make_pair(min_result, max_result); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_last_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = ++first; + if (second == last) + return std::make_pair(min_result, max_result); + + if (comp(max_result, second)) + max_result = second; + else + min_result = second; + + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (!comp(min_result, first)) + min_result = first; + if (comp(max_result, second)) + max_result = second; + } else { + if (!comp(min_result, second)) + min_result = second; + if (comp(max_result, first)) + max_result = first; + } + first = ++second; if (first != last) ++second; + } + + if (first != last) { + if (!comp(min_result, first)) + min_result = first; + else if (comp(max_result, first)) + max_result = first; + } + + return std::make_pair(min_result, max_result); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_last_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = first; ++second; + if (second == last) + return std::make_pair(min_result,max_result); + + ForwardIter potential_max_result = last; + if (comp(first, second)) + max_result = second; + else { + min_result = second; + potential_max_result = second; + } + + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (!comp(min_result, first)) + min_result = first; + if (!comp(second, max_result)) { + max_result = second; + potential_max_result = last; + } + } else { + if (!comp(min_result, second)) + min_result = second; + if (!comp(first, max_result)) { + max_result = first; + potential_max_result = second; + } + } + first = ++second; + if (first != last) ++second; + } + + if (first != last) { + if (!comp(min_result, first)) + min_result = first; + if (!comp(first, max_result)) { + max_result = first; + potential_max_result = last; + } + } + + if (potential_max_result != last + && !comp(potential_max_result, max_result)) + max_result = potential_max_result; + + return std::make_pair(min_result,max_result); + } + + } // namespace detail + + template <typename ForwardIter> + inline std::pair<ForwardIter,ForwardIter> + first_min_first_max_element(ForwardIter first, ForwardIter last) + { + return minmax_element(first, last); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + first_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return minmax_element(first, last, comp); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + first_min_last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_min_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + first_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_first_min_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + last_min_first_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_first_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + last_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_last_min_first_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + last_min_last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + last_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_last_min_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + +} // namespace boost + +#endif // BOOST_ALGORITHM_MINMAX_ELEMENT_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore.hpp new file mode 100644 index 00000000000..80a5a4474d9 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore.hpp @@ -0,0 +1,273 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#ifndef BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP +#define BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP + +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/assert.hpp> +#include <boost/static_assert.hpp> + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <boost/algorithm/searching/detail/bm_traits.hpp> +#include <boost/algorithm/searching/detail/debugging.hpp> + +namespace boost { namespace algorithm { + +/* + A templated version of the boyer-moore searching algorithm. + +References: + http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/ + http://www.cs.utexas.edu/~moore/publications/fstrpos.pdf + +Explanations: + http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm + http://www.movsd.com/bm.htm + http://www.cs.ucdavis.edu/~gusfield/cs224f09/bnotes.pdf + +The Boyer-Moore search algorithm uses two tables, a "bad character" table +to tell how far to skip ahead when it hits a character that is not in the pattern, +and a "good character" table to tell how far to skip ahead when it hits a +mismatch on a character that _is_ in the pattern. + +Requirements: + * Random access iterators + * The two iterator types (patIter and corpusIter) must + "point to" the same underlying type and be comparable. + * Additional requirements may be imposed but the skip table, such as: + ** Numeric type (array-based skip table) + ** Hashable type (map-based skip table) +*/ + + template <typename patIter, typename traits = detail::BM_traits<patIter> > + class boyer_moore { + typedef typename std::iterator_traits<patIter>::difference_type difference_type; + public: + boyer_moore ( patIter first, patIter last ) + : pat_first ( first ), pat_last ( last ), + k_pattern_length ( std::distance ( pat_first, pat_last )), + skip_ ( k_pattern_length, -1 ), + suffix_ ( k_pattern_length + 1 ) + { + this->build_skip_table ( first, last ); + this->build_suffix_table ( first, last ); + } + + ~boyer_moore () {} + + /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last ) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { + BOOST_STATIC_ASSERT (( boost::is_same< + typename std::iterator_traits<patIter>::value_type, + typename std::iterator_traits<corpusIter>::value_type>::value )); + + if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! + if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start + + const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); + // If the pattern is larger than the corpus, we can't find it! + if ( k_corpus_length < k_pattern_length ) + return std::make_pair(corpus_last, corpus_last); + + // Do the search + return this->do_search ( corpus_first, corpus_last ); + } + + template <typename Range> + std::pair<typename boost::range_iterator<Range>::type, typename boost::range_iterator<Range>::type> + operator () ( Range &r ) const { + return (*this) (boost::begin(r), boost::end(r)); + } + + private: +/// \cond DOXYGEN_HIDE + patIter pat_first, pat_last; + const difference_type k_pattern_length; + typename traits::skip_table_t skip_; + std::vector <difference_type> suffix_; + + /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// \param p A predicate used for the search comparisons. + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + do_search ( corpusIter corpus_first, corpusIter corpus_last ) const { + /* ---- Do the matching ---- */ + corpusIter curPos = corpus_first; + const corpusIter lastPos = corpus_last - k_pattern_length; + difference_type j, k, m; + + while ( curPos <= lastPos ) { + /* while ( std::distance ( curPos, corpus_last ) >= k_pattern_length ) { */ + // Do we match right where we are? + j = k_pattern_length; + while ( pat_first [j-1] == curPos [j-1] ) { + j--; + // We matched - we're done! + if ( j == 0 ) + return std::make_pair(curPos, curPos + k_pattern_length); + } + + // Since we didn't match, figure out how far to skip forward + k = skip_ [ curPos [ j - 1 ]]; + m = j - k - 1; + if ( k < j && m > suffix_ [ j ] ) + curPos += m; + else + curPos += suffix_ [ j ]; + } + + return std::make_pair(corpus_last, corpus_last); // We didn't find anything + } + + + void build_skip_table ( patIter first, patIter last ) { + for ( std::size_t i = 0; first != last; ++first, ++i ) + skip_.insert ( *first, i ); + } + + + template<typename Iter, typename Container> + void compute_bm_prefix ( Iter first, Iter last, Container &prefix ) { + const std::size_t count = std::distance ( first, last ); + BOOST_ASSERT ( count > 0 ); + BOOST_ASSERT ( prefix.size () == count ); + + prefix[0] = 0; + std::size_t k = 0; + for ( std::size_t i = 1; i < count; ++i ) { + BOOST_ASSERT ( k < count ); + while ( k > 0 && ( first[k] != first[i] )) { + BOOST_ASSERT ( k < count ); + k = prefix [ k - 1 ]; + } + + if ( first[k] == first[i] ) + k++; + prefix [ i ] = k; + } + } + + void build_suffix_table ( patIter first, patIter last ) { + const std::size_t count = (std::size_t) std::distance ( first, last ); + + if ( count > 0 ) { // empty pattern + std::vector<typename std::iterator_traits<patIter>::value_type> reversed(count); + (void) std::reverse_copy ( first, last, reversed.begin ()); + + std::vector<difference_type> prefix (count); + compute_bm_prefix ( first, last, prefix ); + + std::vector<difference_type> prefix_reversed (count); + compute_bm_prefix ( reversed.begin (), reversed.end (), prefix_reversed ); + + for ( std::size_t i = 0; i <= count; i++ ) + suffix_[i] = count - prefix [count-1]; + + for ( std::size_t i = 0; i < count; i++ ) { + const std::size_t j = count - prefix_reversed[i]; + const difference_type k = i - prefix_reversed[i] + 1; + + if (suffix_[j] > k) + suffix_[j] = k; + } + } + } +/// \endcond + }; + + +/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters + Use a bit of TMP to disambiguate the 3-argument templates */ + +/// \fn boyer_moore_search ( corpusIter corpus_first, corpusIter corpus_last, +/// patIter pat_first, patIter pat_last ) +/// \brief Searches the corpus for the pattern. +/// +/// \param corpus_first The start of the data to search (Random Access Iterator) +/// \param corpus_last One past the end of the data to search +/// \param pat_first The start of the pattern to search for (Random Access Iterator) +/// \param pat_last One past the end of the data to search for +/// + template <typename patIter, typename corpusIter> + std::pair<corpusIter, corpusIter> boyer_moore_search ( + corpusIter corpus_first, corpusIter corpus_last, + patIter pat_first, patIter pat_last ) + { + boyer_moore<patIter> bm ( pat_first, pat_last ); + return bm ( corpus_first, corpus_last ); + } + + template <typename PatternRange, typename corpusIter> + std::pair<corpusIter, corpusIter> boyer_moore_search ( + corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + boyer_moore<pattern_iterator> bm ( boost::begin(pattern), boost::end (pattern)); + return bm ( corpus_first, corpus_last ); + } + + template <typename patIter, typename CorpusRange> + typename boost::disable_if_c< + boost::is_same<CorpusRange, patIter>::value, + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> > + ::type + boyer_moore_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) + { + boyer_moore<patIter> bm ( pat_first, pat_last ); + return bm (boost::begin (corpus), boost::end (corpus)); + } + + template <typename PatternRange, typename CorpusRange> + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> + boyer_moore_search ( CorpusRange &corpus, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + boyer_moore<pattern_iterator> bm ( boost::begin(pattern), boost::end (pattern)); + return bm (boost::begin (corpus), boost::end (corpus)); + } + + + // Creator functions -- take a pattern range, return an object + template <typename Range> + boost::algorithm::boyer_moore<typename boost::range_iterator<const Range>::type> + make_boyer_moore ( const Range &r ) { + return boost::algorithm::boyer_moore + <typename boost::range_iterator<const Range>::type> (boost::begin(r), boost::end(r)); + } + + template <typename Range> + boost::algorithm::boyer_moore<typename boost::range_iterator<Range>::type> + make_boyer_moore ( Range &r ) { + return boost::algorithm::boyer_moore + <typename boost::range_iterator<Range>::type> (boost::begin(r), boost::end(r)); + } + +}} + +#endif // BOOST_ALGORITHM_BOYER_MOORE_SEARCH_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore_horspool.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore_horspool.hpp new file mode 100644 index 00000000000..b8038fd7f79 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/boyer_moore_horspool.hpp @@ -0,0 +1,203 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#ifndef BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP +#define BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP + +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/assert.hpp> +#include <boost/static_assert.hpp> + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <boost/algorithm/searching/detail/bm_traits.hpp> +#include <boost/algorithm/searching/detail/debugging.hpp> + +// #define BOOST_ALGORITHM_BOYER_MOORE_HORSPOOL_DEBUG_HPP + +namespace boost { namespace algorithm { + +/* + A templated version of the boyer-moore-horspool searching algorithm. + + Requirements: + * Random access iterators + * The two iterator types (patIter and corpusIter) must + "point to" the same underlying type. + * Additional requirements may be imposed buy the skip table, such as: + ** Numeric type (array-based skip table) + ** Hashable type (map-based skip table) + +http://www-igm.univ-mlv.fr/%7Elecroq/string/node18.html + +*/ + + template <typename patIter, typename traits = detail::BM_traits<patIter> > + class boyer_moore_horspool { + typedef typename std::iterator_traits<patIter>::difference_type difference_type; + public: + boyer_moore_horspool ( patIter first, patIter last ) + : pat_first ( first ), pat_last ( last ), + k_pattern_length ( std::distance ( pat_first, pat_last )), + skip_ ( k_pattern_length, k_pattern_length ) { + + // Build the skip table + std::size_t i = 0; + if ( first != last ) // empty pattern? + for ( patIter iter = first; iter != last-1; ++iter, ++i ) + skip_.insert ( *iter, k_pattern_length - 1 - i ); +#ifdef BOOST_ALGORITHM_BOYER_MOORE_HORSPOOL_DEBUG_HPP + skip_.PrintSkipTable (); +#endif + } + + ~boyer_moore_horspool () {} + + /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { + BOOST_STATIC_ASSERT (( boost::is_same< + typename std::iterator_traits<patIter>::value_type, + typename std::iterator_traits<corpusIter>::value_type>::value )); + + if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! + if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start + + const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); + // If the pattern is larger than the corpus, we can't find it! + if ( k_corpus_length < k_pattern_length ) + return std::make_pair(corpus_last, corpus_last); + + // Do the search + return this->do_search ( corpus_first, corpus_last ); + } + + template <typename Range> + std::pair<typename boost::range_iterator<Range>::type, typename boost::range_iterator<Range>::type> + operator () ( Range &r ) const { + return (*this) (boost::begin(r), boost::end(r)); + } + + private: +/// \cond DOXYGEN_HIDE + patIter pat_first, pat_last; + const difference_type k_pattern_length; + typename traits::skip_table_t skip_; + + /// \fn do_search ( corpusIter corpus_first, corpusIter corpus_last ) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// \param k_corpus_length The length of the corpus to search + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + do_search ( corpusIter corpus_first, corpusIter corpus_last ) const { + corpusIter curPos = corpus_first; + const corpusIter lastPos = corpus_last - k_pattern_length; + while ( curPos <= lastPos ) { + // Do we match right where we are? + std::size_t j = k_pattern_length - 1; + while ( pat_first [j] == curPos [j] ) { + // We matched - we're done! + if ( j == 0 ) + return std::make_pair(curPos, curPos + k_pattern_length); + j--; + } + + curPos += skip_ [ curPos [ k_pattern_length - 1 ]]; + } + + return std::make_pair(corpus_last, corpus_last); + } +// \endcond + }; + +/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters + Use a bit of TMP to disambiguate the 3-argument templates */ + +/// \fn boyer_moore_horspool_search ( corpusIter corpus_first, corpusIter corpus_last, +/// patIter pat_first, patIter pat_last ) +/// \brief Searches the corpus for the pattern. +/// +/// \param corpus_first The start of the data to search (Random Access Iterator) +/// \param corpus_last One past the end of the data to search +/// \param pat_first The start of the pattern to search for (Random Access Iterator) +/// \param pat_last One past the end of the data to search for +/// + template <typename patIter, typename corpusIter> + std::pair<corpusIter, corpusIter> boyer_moore_horspool_search ( + corpusIter corpus_first, corpusIter corpus_last, + patIter pat_first, patIter pat_last ) + { + boyer_moore_horspool<patIter> bmh ( pat_first, pat_last ); + return bmh ( corpus_first, corpus_last ); + } + + template <typename PatternRange, typename corpusIter> + std::pair<corpusIter, corpusIter> boyer_moore_horspool_search ( + corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + boyer_moore_horspool<pattern_iterator> bmh ( boost::begin(pattern), boost::end (pattern)); + return bmh ( corpus_first, corpus_last ); + } + + template <typename patIter, typename CorpusRange> + typename boost::disable_if_c< + boost::is_same<CorpusRange, patIter>::value, + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> > + ::type + boyer_moore_horspool_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) + { + boyer_moore_horspool<patIter> bmh ( pat_first, pat_last ); + return bm (boost::begin (corpus), boost::end (corpus)); + } + + template <typename PatternRange, typename CorpusRange> + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> + boyer_moore_horspool_search ( CorpusRange &corpus, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + boyer_moore_horspool<pattern_iterator> bmh ( boost::begin(pattern), boost::end (pattern)); + return bmh (boost::begin (corpus), boost::end (corpus)); + } + + + // Creator functions -- take a pattern range, return an object + template <typename Range> + boost::algorithm::boyer_moore_horspool<typename boost::range_iterator<const Range>::type> + make_boyer_moore_horspool ( const Range &r ) { + return boost::algorithm::boyer_moore_horspool + <typename boost::range_iterator<const Range>::type> (boost::begin(r), boost::end(r)); + } + + template <typename Range> + boost::algorithm::boyer_moore_horspool<typename boost::range_iterator<Range>::type> + make_boyer_moore_horspool ( Range &r ) { + return boost::algorithm::boyer_moore_horspool + <typename boost::range_iterator<Range>::type> (boost::begin(r), boost::end(r)); + } + +}} + +#endif // BOOST_ALGORITHM_BOYER_MOORE_HORSPOOOL_SEARCH_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/bm_traits.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/bm_traits.hpp new file mode 100644 index 00000000000..12143636be0 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/bm_traits.hpp @@ -0,0 +1,113 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#ifndef BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP +#define BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP + +#include <climits> // for CHAR_BIT +#include <vector> +#include <iterator> // for std::iterator_traits + +#include <boost/type_traits/make_unsigned.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/remove_pointer.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/array.hpp> +#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP +#include <boost/unordered_map.hpp> +#else +#include <unordered_map> +#endif + +#include <boost/algorithm/searching/detail/debugging.hpp> + +namespace boost { namespace algorithm { namespace detail { + +// +// Default implementations of the skip tables for B-M and B-M-H +// + template<typename key_type, typename value_type, bool /*useArray*/> class skip_table; + +// General case for data searching other than bytes; use a map + template<typename key_type, typename value_type> + class skip_table<key_type, value_type, false> { + private: +#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP + typedef boost::unordered_map<key_type, value_type> skip_map; +#else + typedef std::unordered_map<key_type, value_type> skip_map; +#endif + const value_type k_default_value; + skip_map skip_; + + public: + skip_table ( std::size_t patSize, value_type default_value ) + : k_default_value ( default_value ), skip_ ( patSize ) {} + + void insert ( key_type key, value_type val ) { + skip_ [ key ] = val; // Would skip_.insert (val) be better here? + } + + value_type operator [] ( key_type key ) const { + typename skip_map::const_iterator it = skip_.find ( key ); + return it == skip_.end () ? k_default_value : it->second; + } + + void PrintSkipTable () const { + std::cout << "BM(H) Skip Table <unordered_map>:" << std::endl; + for ( typename skip_map::const_iterator it = skip_.begin (); it != skip_.end (); ++it ) + if ( it->second != k_default_value ) + std::cout << " " << it->first << ": " << it->second << std::endl; + std::cout << std::endl; + } + }; + + +// Special case small numeric values; use an array + template<typename key_type, typename value_type> + class skip_table<key_type, value_type, true> { + private: + typedef typename boost::make_unsigned<key_type>::type unsigned_key_type; + typedef boost::array<value_type, 1U << (CHAR_BIT * sizeof(key_type))> skip_map; + skip_map skip_; + const value_type k_default_value; + public: + skip_table ( std::size_t /*patSize*/, value_type default_value ) : k_default_value ( default_value ) { + std::fill_n ( skip_.begin(), skip_.size(), default_value ); + } + + void insert ( key_type key, value_type val ) { + skip_ [ static_cast<unsigned_key_type> ( key ) ] = val; + } + + value_type operator [] ( key_type key ) const { + return skip_ [ static_cast<unsigned_key_type> ( key ) ]; + } + + void PrintSkipTable () const { + std::cout << "BM(H) Skip Table <boost:array>:" << std::endl; + for ( typename skip_map::const_iterator it = skip_.begin (); it != skip_.end (); ++it ) + if ( *it != k_default_value ) + std::cout << " " << std::distance (skip_.begin (), it) << ": " << *it << std::endl; + std::cout << std::endl; + } + }; + + template<typename Iterator> + struct BM_traits { + typedef typename std::iterator_traits<Iterator>::difference_type value_type; + typedef typename std::iterator_traits<Iterator>::value_type key_type; + typedef boost::algorithm::detail::skip_table<key_type, value_type, + boost::is_integral<key_type>::value && (sizeof(key_type)==1)> skip_table_t; + }; + +}}} // namespaces + +#endif // BOOST_ALGORITHM_SEARCH_DETAIL_BM_TRAITS_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/debugging.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/debugging.hpp new file mode 100644 index 00000000000..3996e0f503c --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/detail/debugging.hpp @@ -0,0 +1,30 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#ifndef BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP +#define BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP + +#include <iostream> +/// \cond DOXYGEN_HIDE + +namespace boost { namespace algorithm { namespace detail { + +// Debugging support + template <typename Iter> + void PrintTable ( Iter first, Iter last ) { + std::cout << std::distance ( first, last ) << ": { "; + for ( Iter iter = first; iter != last; ++iter ) + std::cout << *iter << " "; + std::cout << "}" << std::endl; + } + +}}} +/// \endcond + +#endif // BOOST_ALGORITHM_SEARCH_DETAIL_DEBUG_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/knuth_morris_pratt.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/knuth_morris_pratt.hpp new file mode 100644 index 00000000000..4c93ffff6cc --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/searching/knuth_morris_pratt.hpp @@ -0,0 +1,264 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#ifndef BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP +#define BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP + +#include <vector> +#include <iterator> // for std::iterator_traits + +#include <boost/config.hpp> +#include <boost/assert.hpp> +#include <boost/static_assert.hpp> + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <boost/algorithm/searching/detail/debugging.hpp> + +// #define BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_DEBUG + +namespace boost { namespace algorithm { + +// #define NEW_KMP + +/* + A templated version of the Knuth-Morris-Pratt searching algorithm. + + Requirements: + * Random-access iterators + * The two iterator types (I1 and I2) must "point to" the same underlying type. + + http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm + http://www.inf.fh-flensburg.de/lang/algorithmen/pattern/kmpen.htm +*/ + + template <typename patIter> + class knuth_morris_pratt { + typedef typename std::iterator_traits<patIter>::difference_type difference_type; + public: + knuth_morris_pratt ( patIter first, patIter last ) + : pat_first ( first ), pat_last ( last ), + k_pattern_length ( std::distance ( pat_first, pat_last )), + skip_ ( k_pattern_length + 1 ) { +#ifdef NEW_KMP + preKmp ( pat_first, pat_last ); +#else + init_skip_table ( pat_first, pat_last ); +#endif +#ifdef BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_DEBUG + detail::PrintTable ( skip_.begin (), skip_.end ()); +#endif + } + + ~knuth_morris_pratt () {} + + /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// \param p A predicate used for the search comparisons. + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + operator () ( corpusIter corpus_first, corpusIter corpus_last ) const { + BOOST_STATIC_ASSERT (( boost::is_same< + typename std::iterator_traits<patIter>::value_type, + typename std::iterator_traits<corpusIter>::value_type>::value )); + + if ( corpus_first == corpus_last ) return std::make_pair(corpus_last, corpus_last); // if nothing to search, we didn't find it! + if ( pat_first == pat_last ) return std::make_pair(corpus_first, corpus_first); // empty pattern matches at start + + const difference_type k_corpus_length = std::distance ( corpus_first, corpus_last ); + // If the pattern is larger than the corpus, we can't find it! + if ( k_corpus_length < k_pattern_length ) + return std::make_pair(corpus_last, corpus_last); + + return do_search ( corpus_first, corpus_last, k_corpus_length ); + } + + template <typename Range> + std::pair<typename boost::range_iterator<Range>::type, typename boost::range_iterator<Range>::type> + operator () ( Range &r ) const { + return (*this) (boost::begin(r), boost::end(r)); + } + + private: +/// \cond DOXYGEN_HIDE + patIter pat_first, pat_last; + const difference_type k_pattern_length; + std::vector <difference_type> skip_; + + /// \fn operator ( corpusIter corpus_first, corpusIter corpus_last, Pred p ) + /// \brief Searches the corpus for the pattern that was passed into the constructor + /// + /// \param corpus_first The start of the data to search (Random Access Iterator) + /// \param corpus_last One past the end of the data to search + /// \param p A predicate used for the search comparisons. + /// + template <typename corpusIter> + std::pair<corpusIter, corpusIter> + do_search ( corpusIter corpus_first, corpusIter corpus_last, + difference_type k_corpus_length ) const { + difference_type match_start = 0; // position in the corpus that we're matching + +#ifdef NEW_KMP + int patternIdx = 0; + while ( match_start < k_corpus_length ) { + while ( patternIdx > -1 && pat_first[patternIdx] != corpus_first [match_start] ) + patternIdx = skip_ [patternIdx]; //<--- Shifting the pattern on mismatch + + patternIdx++; + match_start++; //<--- corpus is always increased by 1 + + if ( patternIdx >= (int) k_pattern_length ) + return corpus_first + match_start - patternIdx; + } + +#else +// At this point, we know: +// k_pattern_length <= k_corpus_length +// for all elements of skip, it holds -1 .. k_pattern_length +// +// In the loop, we have the following invariants +// idx is in the range 0 .. k_pattern_length +// match_start is in the range 0 .. k_corpus_length - k_pattern_length + 1 + + const difference_type last_match = k_corpus_length - k_pattern_length; + difference_type idx = 0; // position in the pattern we're comparing + + while ( match_start <= last_match ) { + while ( pat_first [ idx ] == corpus_first [ match_start + idx ] ) { + if ( ++idx == k_pattern_length ) + return std::make_pair(corpus_first + match_start, corpus_first + match_start + k_pattern_length); + } + // Figure out where to start searching again + // assert ( idx - skip_ [ idx ] > 0 ); // we're always moving forward + match_start += idx - skip_ [ idx ]; + idx = skip_ [ idx ] >= 0 ? skip_ [ idx ] : 0; + // assert ( idx >= 0 && idx < k_pattern_length ); + } +#endif + + // We didn't find anything + return std::make_pair(corpus_last, corpus_last); + } + + + void preKmp ( patIter first, patIter last ) { + const difference_type count = std::distance ( first, last ); + + difference_type i, j; + + i = 0; + j = skip_[0] = -1; + while (i < count) { + while (j > -1 && first[i] != first[j]) + j = skip_[j]; + i++; + j++; + if (first[i] == first[j]) + skip_[i] = skip_[j]; + else + skip_[i] = j; + } + } + + + void init_skip_table ( patIter first, patIter last ) { + const difference_type count = std::distance ( first, last ); + + difference_type j; + skip_ [ 0 ] = -1; + for ( int i = 1; i <= count; ++i ) { + j = skip_ [ i - 1 ]; + while ( j >= 0 ) { + if ( first [ j ] == first [ i - 1 ] ) + break; + j = skip_ [ j ]; + } + skip_ [ i ] = j + 1; + } + } +// \endcond + }; + + +/* Two ranges as inputs gives us four possibilities; with 2,3,3,4 parameters + Use a bit of TMP to disambiguate the 3-argument templates */ + +/// \fn knuth_morris_pratt_search ( corpusIter corpus_first, corpusIter corpus_last, +/// patIter pat_first, patIter pat_last ) +/// \brief Searches the corpus for the pattern. +/// +/// \param corpus_first The start of the data to search (Random Access Iterator) +/// \param corpus_last One past the end of the data to search +/// \param pat_first The start of the pattern to search for (Random Access Iterator) +/// \param pat_last One past the end of the data to search for +/// + template <typename patIter, typename corpusIter> + std::pair<corpusIter, corpusIter> knuth_morris_pratt_search ( + corpusIter corpus_first, corpusIter corpus_last, + patIter pat_first, patIter pat_last ) + { + knuth_morris_pratt<patIter> kmp ( pat_first, pat_last ); + return kmp ( corpus_first, corpus_last ); + } + + template <typename PatternRange, typename corpusIter> + std::pair<corpusIter, corpusIter> knuth_morris_pratt_search ( + corpusIter corpus_first, corpusIter corpus_last, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + knuth_morris_pratt<pattern_iterator> kmp ( boost::begin(pattern), boost::end (pattern)); + return kmp ( corpus_first, corpus_last ); + } + + template <typename patIter, typename CorpusRange> + typename boost::disable_if_c< + boost::is_same<CorpusRange, patIter>::value, + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> > + ::type + knuth_morris_pratt_search ( CorpusRange &corpus, patIter pat_first, patIter pat_last ) + { + knuth_morris_pratt<patIter> kmp ( pat_first, pat_last ); + return kmp (boost::begin (corpus), boost::end (corpus)); + } + + template <typename PatternRange, typename CorpusRange> + std::pair<typename boost::range_iterator<CorpusRange>::type, typename boost::range_iterator<CorpusRange>::type> + knuth_morris_pratt_search ( CorpusRange &corpus, const PatternRange &pattern ) + { + typedef typename boost::range_iterator<const PatternRange>::type pattern_iterator; + knuth_morris_pratt<pattern_iterator> kmp ( boost::begin(pattern), boost::end (pattern)); + return kmp (boost::begin (corpus), boost::end (corpus)); + } + + + // Creator functions -- take a pattern range, return an object + template <typename Range> + boost::algorithm::knuth_morris_pratt<typename boost::range_iterator<const Range>::type> + make_knuth_morris_pratt ( const Range &r ) { + return boost::algorithm::knuth_morris_pratt + <typename boost::range_iterator<const Range>::type> (boost::begin(r), boost::end(r)); + } + + template <typename Range> + boost::algorithm::knuth_morris_pratt<typename boost::range_iterator<Range>::type> + make_knuth_morris_pratt ( Range &r ) { + return boost::algorithm::knuth_morris_pratt + <typename boost::range_iterator<Range>::type> (boost::begin(r), boost::end(r)); + } +}} + +#endif // BOOST_ALGORITHM_KNUTH_MORRIS_PRATT_SEARCH_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/sort_subrange.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/sort_subrange.hpp new file mode 100644 index 00000000000..700dd6dc89f --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/sort_subrange.hpp @@ -0,0 +1,110 @@ +/* + Copyright (c) Marshall Clow 2008-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + Revision history: + 28 Sep 2015 mtc First version + +*/ + +/// \file sort_subrange.hpp +/// \brief Sort a subrange +/// \author Marshall Clow +/// +/// Suggested by Sean Parent in his CppCon 2015 keynote + +#ifndef BOOST_ALGORITHM_SORT_SUBRANGE_HPP +#define BOOST_ALGORITHM_SORT_SUBRANGE_HPP + +#include <functional> // For std::less +#include <iterator> // For std::iterator_traits +#include <algorithm> // For nth_element and partial_sort + +#include <boost/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { namespace algorithm { + +/// \fn sort_subrange ( T const& val, +/// Iterator first, Iterator last, +/// Iterator sub_first, Iterator sub_last, +/// Pred p ) +/// \brief Sort the subrange [sub_first, sub_last) that is inside +/// the range [first, last) as if you had sorted the entire range. +/// +/// \param first The start of the larger range +/// \param last The end of the larger range +/// \param sub_first The start of the sub range +/// \param sub_last The end of the sub range +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. +/// + template<typename Iterator, typename Pred> + void sort_subrange ( + Iterator first, Iterator last, + Iterator sub_first, Iterator sub_last, + Pred p) + { + if (sub_first == sub_last) return; // the empty sub-range is already sorted. + + if (sub_first != first) { // sub-range is at the start, don't need to partition + (void) std::nth_element(first, sub_first, last, p); + ++sub_first; + } + std::partial_sort(sub_first, sub_last, last, p); + } + + + + template<typename Iterator> + void sort_subrange (Iterator first, Iterator last, Iterator sub_first, Iterator sub_last) + { + typedef typename std::iterator_traits<Iterator>::value_type value_type; + return sort_subrange(first, last, sub_first, sub_last, std::less<value_type>()); + } + +/// range versions? + + +/// \fn partition_subrange ( T const& val, +/// Iterator first, Iterator last, +/// Iterator sub_first, Iterator sub_last, +/// Pred p ) +/// \brief Gather the elements of the subrange [sub_first, sub_last) that is +/// inside the range [first, last) as if you had sorted the entire range. +/// +/// \param first The start of the larger range +/// \param last The end of the larger range +/// \param sub_first The start of the sub range +/// \param sub_last The end of the sub range +/// \param p A predicate to use to compare the values. +/// p ( a, b ) returns a boolean. +/// + template<typename Iterator, typename Pred> + void partition_subrange ( + Iterator first, Iterator last, + Iterator sub_first, Iterator sub_last, + Pred p) + { + if (sub_first != first) { + (void) std::nth_element(first, sub_first, last, p); + ++sub_first; + } + + if (sub_last != last) + (void) std::nth_element(sub_first, sub_last, last, p); + } + + template<typename Iterator> + void partition_subrange (Iterator first, Iterator last, Iterator sub_first, Iterator sub_last) + { + typedef typename std::iterator_traits<Iterator>::value_type value_type; + return partition_subrange(first, last, sub_first, sub_last, std::less<value_type>()); + } + +}} + +#endif // BOOST_ALGORITHM_SORT_SUBRANGE_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/finder_regex.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/finder_regex.hpp new file mode 100644 index 00000000000..9cb01cfaf13 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/finder_regex.hpp @@ -0,0 +1,122 @@ +// Boost string_algo library find_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FINDER_REGEX_DETAIL_HPP +#define BOOST_STRING_FINDER_REGEX_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> + +#include <boost/range/iterator_range_core.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// regex find functor -----------------------------------------------// + + // regex search result + template<typename IteratorT> + struct regex_search_result : + public iterator_range<IteratorT> + { + typedef regex_search_result<IteratorT> type; + typedef iterator_range<IteratorT> base_type; + typedef BOOST_STRING_TYPENAME base_type::value_type value_type; + typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type; + typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator; + typedef BOOST_STRING_TYPENAME base_type::iterator iterator; + typedef boost::match_results<iterator> match_results_type; + + // Construction + + // Construction from the match result + regex_search_result( const match_results_type& MatchResults ) : + base_type( MatchResults[0].first, MatchResults[0].second ), + m_MatchResults( MatchResults ) {} + + // Construction of empty match. End iterator has to be specified + regex_search_result( IteratorT End ) : + base_type( End, End ) {} + + regex_search_result( const regex_search_result& Other ) : + base_type( Other.begin(), Other.end() ), + m_MatchResults( Other.m_MatchResults ) {} + + // Assignment + regex_search_result& operator=( const regex_search_result& Other ) + { + base_type::operator=( Other ); + m_MatchResults=Other.m_MatchResults; + return *this; + } + + // Match result retrieval + const match_results_type& match_results() const + { + return m_MatchResults; + } + + private: + // Saved match result + match_results_type m_MatchResults; + }; + + // find_regex + /* + Regex based search functor + */ + template<typename RegExT> + struct find_regexF + { + typedef RegExT regex_type; + typedef const RegExT& regex_reference_type; + + // Construction + find_regexF( regex_reference_type Rx, match_flag_type MatchFlags = match_default ) : + m_Rx(Rx), m_MatchFlags(MatchFlags) {} + + // Operation + template< typename ForwardIteratorT > + regex_search_result<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + typedef ForwardIteratorT input_iterator_type; + typedef regex_search_result<ForwardIteratorT> result_type; + + // instantiate match result + match_results<input_iterator_type> result; + // search for a match + if ( ::boost::regex_search( Begin, End, result, m_Rx, m_MatchFlags ) ) + { + // construct a result + return result_type( result ); + } + else + { + // empty result + return result_type( End ); + } + } + + private: + regex_reference_type m_Rx; // Regexp + match_flag_type m_MatchFlags; // match flags + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FIND_DETAIL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/formatter_regex.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/formatter_regex.hpp new file mode 100644 index 00000000000..5f26407bed8 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/detail/formatter_regex.hpp @@ -0,0 +1,61 @@ +// Boost string_algo library formatter_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP +#define BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <string> +#include <boost/regex.hpp> +#include <boost/algorithm/string/detail/finder_regex.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// regex format functor -----------------------------------------// + + // regex format functor + template<typename StringT> + struct regex_formatF + { + private: + typedef StringT result_type; + typedef BOOST_STRING_TYPENAME StringT::value_type char_type; + + public: + // Construction + regex_formatF( const StringT& Fmt, match_flag_type Flags=format_default ) : + m_Fmt(Fmt), m_Flags( Flags ) {} + + template<typename InputIteratorT> + result_type operator()( + const regex_search_result<InputIteratorT>& Replace ) const + { + if ( Replace.empty() ) + { + return result_type(); + } + else + { + return Replace.match_results().format( m_Fmt, m_Flags ); + } + } + private: + const StringT& m_Fmt; + match_flag_type m_Flags; + }; + + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FORMATTER_DETAIL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex.hpp new file mode 100644 index 00000000000..a6c7c60ae8d --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex.hpp @@ -0,0 +1,646 @@ +// Boost string_algo library regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REGEX_HPP +#define BOOST_STRING_REGEX_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> + +#include <boost/range/iterator_range_core.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/find_format.hpp> +#include <boost/algorithm/string/regex_find_format.hpp> +#include <boost/algorithm/string/formatter.hpp> +#include <boost/algorithm/string/iter_find.hpp> + +/*! \file + Defines regex variants of the algorithms. +*/ + +namespace boost { + namespace algorithm { + +// find_regex -----------------------------------------------// + + //! Find regex algorithm + /*! + Search for a substring matching the given regex in the input. + + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename RangeT, + typename CharT, + typename RegexTraitsT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type > + find_regex( + RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + return ::boost::algorithm::regex_finder(Rx,Flags)( + ::boost::begin(lit_input), ::boost::end(lit_input) ); + } + +// replace_regex --------------------------------------------------------------------// + + //! Replace regex algorithm + /*! + Search for a substring matching given regex and format it with + the specified format. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline OutputIteratorT replace_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline SequenceT replace_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace regex algorithm + /*! + Search for a substring matching given regex and format it with + the specified format. The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline void replace_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + +// replace_all_regex --------------------------------------------------------------------// + + //! Replace all regex algorithm + /*! + Format all substrings, matching given regex, with the specified format. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline OutputIteratorT replace_all_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace all regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline SequenceT replace_all_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace all regex algorithm + /*! + Format all substrings, matching given regex, with the specified format. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline void replace_all_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + +// erase_regex --------------------------------------------------------------------// + + //! Erase regex algorithm + /*! + Remove a substring matching given regex from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline OutputIteratorT erase_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline SequenceT erase_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase regex algorithm + /*! + Remove a substring matching given regex from the input. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline void erase_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + +// erase_all_regex --------------------------------------------------------------------// + + //! Erase all regex algorithm + /*! + Erase all substrings, matching given regex, from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline OutputIteratorT erase_all_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase all regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline SequenceT erase_all_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase all regex algorithm + /*! + Erase all substrings, matching given regex, from the input. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT> + inline void erase_all_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + +// find_all_regex ------------------------------------------------------------------// + + //! Find all regex algorithm + /*! + This algorithm finds all substrings matching the give regex + in the input. + + Each part is copied and added as a new element to the output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings. + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return A reference to the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline SequenceSequenceT& find_all_regex( + SequenceSequenceT& Result, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::iter_find( + Result, + Input, + ::boost::algorithm::regex_finder(Rx,Flags) ); + } + +// split_regex ------------------------------------------------------------------// + + //! Split regex algorithm + /*! + Tokenize expression. This function is equivalent to C strtok. Input + sequence is split into tokens, separated by separators. Separator + is an every match of the given regex. + Each part is copied and added as a new element to the output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings. + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return A reference to the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline SequenceSequenceT& split_regex( + SequenceSequenceT& Result, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::iter_split( + Result, + Input, + ::boost::algorithm::regex_finder(Rx,Flags) ); + } + +// join_if ------------------------------------------------------------------// + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + match the given regular expression will be added to the result + + This is a specialization of join_if algorithm. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Rx A regular expression + \param Flags Regex options + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename Range1T, + typename CharT, + typename RegexTraitsT > + inline typename range_value<SequenceSequenceT>::type + join_if( + const SequenceSequenceT& Input, + const Range1T& Separator, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + + // Roll to the first element that will be added + while( + itBegin!=itEnd && + !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; + + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + } + + return Result; + } + +#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + match the given regular expression will be added to the result + + This is a specialization of join_if algorithm. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Rx A regular expression + \param Flags Regex options + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename Range1T, + typename CharT, + typename RegexTraitsT > + inline typename range_value<SequenceSequenceT>::type + join_if_regex( + const SequenceSequenceT& Input, + const Range1T& Separator, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + + // Roll to the first element that will be added + while( + itBegin!=itEnd && + !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; + + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + } + + return Result; + } + + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + } // namespace algorithm + + // pull names into the boost namespace + using algorithm::find_regex; + using algorithm::replace_regex; + using algorithm::replace_regex_copy; + using algorithm::replace_all_regex; + using algorithm::replace_all_regex_copy; + using algorithm::erase_regex; + using algorithm::erase_regex_copy; + using algorithm::erase_all_regex; + using algorithm::erase_all_regex_copy; + using algorithm::find_all_regex; + using algorithm::split_regex; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + using algorithm::join_if; +#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + using algorithm::join_if_regex; +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +} // namespace boost + + +#endif // BOOST_STRING_REGEX_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex_find_format.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex_find_format.hpp new file mode 100644 index 00000000000..409afc2ba0c --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/regex_find_format.hpp @@ -0,0 +1,90 @@ +// Boost string_algo library regex_find_format.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REGEX_FIND_FORMAT_HPP +#define BOOST_STRING_REGEX_FIND_FORMAT_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> +#include <boost/algorithm/string/detail/finder_regex.hpp> +#include <boost/algorithm/string/detail/formatter_regex.hpp> + +/*! \file + Defines the \c regex_finder and \c regex_formatter generators. These two functors + are designed to work together. \c regex_formatter uses additional information + about a match contained in the regex_finder search result. +*/ + +namespace boost { + namespace algorithm { + +// regex_finder -----------------------------------------------// + + //! "Regex" finder + /*! + Construct the \c regex_finder. Finder uses the regex engine to search + for a match. + Result is given in \c regex_search_result. This is an extension + of the iterator_range. In addition it contains match results + from the \c regex_search algorithm. + + \param Rx A regular expression + \param MatchFlags Regex search options + \return An instance of the \c regex_finder object + */ + template< + typename CharT, + typename RegexTraitsT> + inline detail::find_regexF< basic_regex<CharT, RegexTraitsT> > + regex_finder( + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type MatchFlags=match_default ) + { + return detail:: + find_regexF< + basic_regex<CharT, RegexTraitsT> >( Rx, MatchFlags ); + } + +// regex_formater ---------------------------------------------// + + //! Regex formatter + /*! + Construct the \c regex_formatter. Regex formatter uses the regex engine to + format a match found by the \c regex_finder. + This formatted it designed to closely cooperate with \c regex_finder. + + \param Format Regex format definition + \param Flags Format flags + \return An instance of the \c regex_formatter functor + */ + template< + typename CharT, + typename TraitsT, typename AllocT > + inline detail::regex_formatF< std::basic_string< CharT, TraitsT, AllocT > > + regex_formatter( + const std::basic_string<CharT, TraitsT, AllocT>& Format, + match_flag_type Flags=format_default ) + { + return + detail::regex_formatF< std::basic_string<CharT, TraitsT, AllocT> >( + Format, + Flags ); + } + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::regex_finder; + using algorithm::regex_formatter; + +} // namespace boost + + +#endif // BOOST_STRING_REGEX_FIND_FORMAT_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/std/rope_traits.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/std/rope_traits.hpp new file mode 100644 index 00000000000..637059a5504 --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/std/rope_traits.hpp @@ -0,0 +1,81 @@ +// Boost string_algo library string_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_ROPE_TRAITS_HPP +#define BOOST_STRING_STD_ROPE_TRAITS_HPP + +#include <boost/algorithm/string/yes_no_type.hpp> +#include <rope> +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + +// SGI's std::rope<> traits -----------------------------------------------// + + + // native replace trait + template<typename T, typename TraitsT, typename AllocT> + class has_native_replace< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // stable iterators trait + template<typename T, typename TraitsT, typename AllocT> + class has_stable_iterators< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // const time insert trait + template<typename T, typename TraitsT, typename AllocT> + class has_const_time_insert< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // const time erase trait + template<typename T, typename TraitsT, typename AllocT> + class has_const_time_erase< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_ROPE_TRAITS_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string/trim_all.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/trim_all.hpp new file mode 100644 index 00000000000..a616f7f33ea --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string/trim_all.hpp @@ -0,0 +1,217 @@ +// Boost string_algo library trim.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_TRIM_ALL_HPP +#define BOOST_STRING_TRIM_ALL_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/algorithm/string/trim.hpp> +#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string/find_format.hpp> +#include <boost/algorithm/string/formatter.hpp> +#include <boost/algorithm/string/finder.hpp> +#include <locale> + +/*! \file + Defines trim_all algorithms. + + Just like \c trim, \c trim_all removes all trailing and leading spaces from a + sequence (string). In addition, spaces in the middle of the sequence are truncated + to just one character. Space is recognized using given locales. + + \c trim_fill acts as trim_all, but the spaces in the middle are replaces with + a user-define sequence of character. + + Parametric (\c _if) variants use a predicate (functor) to select which characters + are to be trimmed.. + Functions take a selection predicate as a parameter, which is used to determine + whether a character is a space. Common predicates are provided in classification.hpp header. + +*/ + +namespace boost { + namespace algorithm { + + // multi line trim ----------------------------------------------- // + + //! Trim All - parametric + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The result is a trimmed copy of the input + + \param Input An input sequence + \param IsSpace A unary predicate identifying spaces + \return A trimmed copy of the input + */ + template<typename SequenceT, typename PredicateT> + inline SequenceT trim_all_copy_if(const SequenceT& Input, PredicateT IsSpace) + { + return + ::boost::find_format_all_copy( + ::boost::trim_copy_if(Input, IsSpace), + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::dissect_formatter(::boost::head_finder(1))); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The input sequence is modified in-place. + + \param Input An input sequence + \param IsSpace A unary predicate identifying spaces + */ + template<typename SequenceT, typename PredicateT> + inline void trim_all_if(SequenceT& Input, PredicateT IsSpace) + { + ::boost::trim_if(Input, IsSpace); + ::boost::find_format_all( + Input, + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::dissect_formatter(::boost::head_finder(1))); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template<typename SequenceT> + inline SequenceT trim_all_copy(const SequenceT& Input, const std::locale& Loc =std::locale()) + { + return trim_all_copy_if(Input, ::boost::is_space(Loc)); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The input sequence is modified in-place. + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template<typename SequenceT> + inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale()) + { + trim_all_if(Input, ::boost::is_space(Loc)); + } + + + //! Trim Fill - parametric + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param IsSpace A unary predicate identifying spaces + \return A trimmed copy of the input + */ + template<typename SequenceT, typename RangeT, typename PredicateT> + inline SequenceT trim_fill_copy_if(const SequenceT& Input, const RangeT& Fill, PredicateT IsSpace) + { + return + ::boost::find_format_all_copy( + ::boost::trim_copy_if(Input, IsSpace), + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::const_formatter(::boost::as_literal(Fill))); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The input sequence is modified in-place. + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param IsSpace A unary predicate identifying spaces + */ + template<typename SequenceT, typename RangeT, typename PredicateT> + inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace) + { + ::boost::trim_if(Input, IsSpace); + ::boost::find_format_all( + Input, + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::const_formatter(::boost::as_literal(Fill))); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template<typename SequenceT, typename RangeT> + inline SequenceT trim_fill_copy(const SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale()) + { + return trim_fill_copy_if(Input, Fill, ::boost::is_space(Loc)); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The input sequence is modified in-place. + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template<typename SequenceT, typename RangeT> + inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale()) + { + trim_fill_if(Input, Fill, ::boost::is_space(Loc)); + } + + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::trim_all; + using algorithm::trim_all_if; + using algorithm::trim_all_copy; + using algorithm::trim_all_copy_if; + using algorithm::trim_fill; + using algorithm::trim_fill_if; + using algorithm::trim_fill_copy; + using algorithm::trim_fill_copy_if; + +} // namespace boost + +#endif // BOOST_STRING_TRIM_ALL_HPP diff --git a/contrib/restricted/boost/algorithm/include/boost/algorithm/string_regex.hpp b/contrib/restricted/boost/algorithm/include/boost/algorithm/string_regex.hpp new file mode 100644 index 00000000000..791aa18481c --- /dev/null +++ b/contrib/restricted/boost/algorithm/include/boost/algorithm/string_regex.hpp @@ -0,0 +1,23 @@ +// Boost string_algo library string_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2004. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_ALGO_REGEX_HPP +#define BOOST_STRING_ALGO_REGEX_HPP + +/*! \file + Cumulative include for string_algo library. + In addition to string.hpp contains also regex-related stuff. +*/ + +#include <boost/regex.hpp> +#include <boost/algorithm/string.hpp> +#include <boost/algorithm/string/regex.hpp> + +#endif // BOOST_STRING_ALGO_REGEX_HPP diff --git a/contrib/restricted/boost/algorithm/ya.make b/contrib/restricted/boost/algorithm/ya.make new file mode 100644 index 00000000000..fa504d88f9f --- /dev/null +++ b/contrib/restricted/boost/algorithm/ya.make @@ -0,0 +1,46 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +OWNER( + g:cpp-contrib + g:taxi-common +) + +VERSION(1.81.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/algorithm/archive/boost-1.81.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/array + contrib/restricted/boost/assert + contrib/restricted/boost/bind + contrib/restricted/boost/concept_check + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/exception + contrib/restricted/boost/function + contrib/restricted/boost/iterator + contrib/restricted/boost/mpl + contrib/restricted/boost/range + contrib/restricted/boost/regex + contrib/restricted/boost/static_assert + contrib/restricted/boost/throw_exception + contrib/restricted/boost/tuple + contrib/restricted/boost/type_traits + contrib/restricted/boost/unordered +) + +ADDINCL( + GLOBAL contrib/restricted/boost/algorithm/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +END() |