diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 72a755c..88abe9c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,43 +21,43 @@ jobs: rust: [nightly] steps: - - uses: hecrj/setup-rust-action@v2 - with: - rust-version: ${{ matrix.rust }} - targets: ${{ matrix.target }} - components: 'rustfmt, clippy' + # - uses: hecrj/setup-rust-action@v2 + # with: + # rust-version: ${{ matrix.rust }} + # targets: ${{ matrix.target }} + # components: 'rustfmt, clippy' - uses: actions/checkout@v4 - - name: Install LLVM - if: matrix.os == 'windows-latest' - run: choco upgrade llvm -y + # - name: Install LLVM + # if: matrix.os == 'windows-latest' + # run: choco upgrade llvm -y - - name: Set clang path - if: matrix.os =='windows-latest' - run: echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV - shell: bash + # - name: Set clang path + # if: matrix.os =='windows-latest' + # run: echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV + # shell: bash - - name: Run c roaring + - name: cmake msvc roaring if: matrix.os == 'windows-latest' run: | - clang --version || true - clang -O3 -o c_roaring.exe roaring_fast_or.c - ./c_roaring.exe - - shell: bash + mkdir build + cd build && cmake -G "Visual Studio 17 2022" -A x64 .. && cmake --build . --config RelWithDebInfo --verbose + echo "running" + RelWithDebInfo/roaring_fast_or.exe + echo "$LASTEXITCODE" + continue-on-error: true - name: msvc c roaring if: matrix.os == 'windows-latest' run: | - $env:LIB="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64;" - $env:PATH="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;D:\a\croaring-rs\croaring-rs\target\release\deps;D:\a\croaring-rs\croaring-rs\target\release;C:\Users\runneradmin\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib;C:\Users\runneradmin\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin;C:\Program Files\PowerShell\7;/c/Users/runneradmin/.cargo/bin;C:\Program Files\MongoDB\Server\5.0\bin;C:\aliyun-cli;C:\vcpkg;C:\Program Files (x86)\NSIS\;C:\tools\zstd;C:\Program Files\Mercurial\;C:\hostedtoolcache\windows\stack\2.13.1\x64;C:\cabal\bin;C:\\ghcup\bin;C:\mingw64\bin;C:\Program Files\dotnet;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\R\R-4.3.2\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\SeleniumWebDrivers\EdgeDriver\;C:\SeleniumWebDrivers\ChromeDriver;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\Program Files (x86)\pipx_bin;C:\npm\prefix;C:\hostedtoolcache\windows\go\1.20.13\x64\bin;C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts;C:\hostedtoolcache\windows\Python\3.9.13\x64;C:\hostedtoolcache\windows\Ruby\3.0.6\x64\bin;C:\Program Files\OpenSSL\bin;C:\tools\kotlinc\bin;C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.402-6\x64\bin;C:\Program Files\ImageMagick-7.1.1-Q16-HDRI;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\ProgramData\Chocolatey\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\PowerShell\7\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\160\DTS\Binn\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\CMake\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.7\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\GitHub CLI\;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files\Amazon\SessionManagerPlugin\bin\;C:\Program Files\Amazon\AWSSAMCLI\bin\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\LLVM\bin;C:\Users\runneradmin\.dotnet\tools;C:\Users\runneradmin\.cargo\bin;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps" $env:INCLUDE="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared;" - & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe" -nologo -MD -O2 -Brepro /Fe:roaring_fast_or.exe /Zi /DEBUG /D "ROARING_DISABLE_AVX=1" ./roaring_fast_or.c + $env:LIB="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64;" + & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe" -nologo -MD -O2 -Brepro /Ob2 /Fe:roaring_fast_or.exe /Zi /DEBUG ./roaring_fast_or.c echo "running" ./roaring_fast_or.exe echo "$LASTEXITCODE" - continue-on-error: true + continue-on-error: false # - name: Cargo fmt @@ -74,10 +74,10 @@ jobs: # - name: Test # run: cargo +${{ matrix.rust }} test - - name: Benchmark - if: matrix.rust == 'nightly' - run: cargo +${{ matrix.rust }} bench -- 'or/fast' - continue-on-error: true + # - name: Benchmark + # if: matrix.rust == 'nightly' + # run: cargo +${{ matrix.rust }} bench -- 'or/fast' + # continue-on-error: true - name: Archive artifacts if: matrix.os == 'windows-latest' diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..abddd60 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.0) + +project(roaring_fast_or C) + +add_executable(roaring_fast_or roaring_fast_or.c) diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 1dbf2c9..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[workspace] -members = ["croaring", "croaring-sys"] -resolver = "2" diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f7a430b..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2016 The CRoaring authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 549f7d8..0000000 --- a/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile -working_directory = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) -croaring_source = $(working_directory)/croaring-sys/CRoaring - -release: - cargo build --release - -lint: - cargo fmt --all -- --check - cargo clippy - -test: - cargo test - -croaring_release_url_base = https://github.com/RoaringBitmap/CRoaring/releases/download - -# Fetch the c source amalgamation from a tagged CRoaring release (like `make version=0.9.3 update_croaring`) -update_croaring: download_croaring bindgen - -download_croaring: - rm -f '$(croaring_source)/roaring.c' '$(croaring_source)/roaring.h' '$(croaring_source)/roaring.hh' - curl -L --output-dir '$(croaring_source)' \ - -O '$(croaring_release_url_base)/v$(version)/roaring.c' \ - -O '$(croaring_release_url_base)/v$(version)/roaring.h' \ - -O '$(croaring_release_url_base)/v$(version)/roaring.hh' - -# Regenerate bindgen bindings -bindgen: - cd '$(croaring_source)' && \ - bindgen --generate-inline-functions \ - --allowlist-function 'roaring.*|bitset.*' \ - --allowlist-type 'roaring.*|bitset.*' \ - --allowlist-var '(?i:roaring|bitset).*' \ - --no-layout-tests \ - -o bindgen_bundled_version.rs \ - roaring.h - -# Build a c program to (re)generate the example serialized files for testing -test_serialization_files: - cd croaring/tests/data/ && \ - cc create_serialization.c '$(croaring_source)/roaring.c' -I '$(croaring_source)' -Wall -o create_serialization && \ - ./create_serialization - -_get_cargo_fuzz: - command -v cargo-fuzz >/dev/null 2>&1 || cargo install cargo-fuzz - -fuzz: _get_cargo_fuzz - cd fuzz && \ - cargo fuzz check && \ - ASAN_OPTIONS="detect_leaks=1 detect_stack_use_after_return=1" \ - CC=clang CFLAGS=-fsanitize=address \ - cargo fuzz run fuzz_ops -s address -- -max_len=10000 -rss_limit_mb=4096 diff --git a/README.md b/README.md deleted file mode 100644 index 52dc988..0000000 --- a/README.md +++ /dev/null @@ -1,126 +0,0 @@ -# croaring-rs [![https://travis-ci.org/RoaringBitmap/croaring-rs](https://travis-ci.org/RoaringBitmap/croaring-rs.svg?branch=master)](https://travis-ci.org/RoaringBitmap/croaring-rs) -A [Rust](https://www.rust-lang.org) wrapper for CRoaring (a C/C++ implementation at https://github.com/RoaringBitmap/CRoaring) - -The original java version can be found at https://github.com/RoaringBitmap/RoaringBitmap - -### Bitmap usage example - -```rust -use croaring::Bitmap; - -let mut rb1 = Bitmap::new(); -rb1.add(1); -rb1.add(2); -rb1.add(3); -rb1.add(4); -rb1.add(5); -rb1.add(100); -rb1.add(1000); -rb1.run_optimize(); - -let mut rb2 = Bitmap::new(); -rb2.add(3); -rb2.add(4); -rb2.add(1000); -rb2.run_optimize(); - -let mut rb3 = Bitmap::new(); - -assert_eq!(rb1.cardinality(), 7); -assert!(rb1.contains(3)); - -rb1.and_inplace(&rb2); -rb3.add(5); -rb3.or_inplace(&rb1); - -let mut rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); - -rb1.and_inplace(&rb2); -println!("{:?}", rb1); - -rb3.add(5); -rb3.or_inplace(&rb1); - -println!("{:?}", rb1); - -rb3.add(5); -rb3.or_inplace(&rb1); - -println!("{:?}", rb3.to_vec()); -println!("{:?}", rb3); -println!("{:?}", rb4); - -rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); - -println!("{:?}", rb4); -``` - -For 64bit Bitmap support, checkout the [`Treemap`](https://docs.rs/croaring/0.4.0/croaring/treemap/struct.Treemap.html). `Treemap` is not API-compatible with `Bitmap`, yet most the functionality is overlapping. - -### Treemap usage example - -```rust -use std::u64; -use croaring::Treemap; - -let mut treemap = Treemap::new(); -treemap.add(u64::MAX); -treemap.remove(u64::MAX); - -/// Serialization compatible with croaring Treemap version at https://github.com/RoaringBitmap/CRoaring/blob/b88b002407b42fafaea23ea5009a54a24d1c1ed4/cpp/roaring64map.hh - -use croaring::treemap::NativeSerializer; - -let mut treemap1 = Treemap::new(); - -for i in 100..1000 { - treemap1.add(i); -} - -treemap1.add(std::u32::MAX as u64); -treemap1.add(std::u64::MAX); - -/// Serialization compatible with JVM Treemap version at https://github.com/RoaringBitmap/RoaringBitmap/blob/34654b2d5c3e75e7f9bca1672f4c0b5800d60cf3/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java -use croaring::treemap::JvmSerializer; - -let mut treemap2 = Treemap::new(); - -for i in 100..1000 { - treemap2.add(i); -} - -treemap2.add(std::u32::MAX as u64); -treemap2.add(std::u64::MAX); -``` - -### Building - -``` -git clone --recursive https://github.com/RoaringBitmap/croaring-rs/ -cd croaring-rs -cargo build -``` - -In `croaring-rs`, just like in [CRoaring](https://github.com/RoaringBitmap/CRoaring/), -some CPU related code optimizations are enabled dynamically at runtime. If you are -building binaries for specific CPU architectures you can specify `ROARING_ARCH` environment -variable to control enabled code optimizations, e.g. -`ROARING_ARCH=ivybridge cargo build --release`. - -### Testing - -Running unit tests and doc tests: - -``` -cargo test -``` - -Running benchmark suite (currently on Rust nightly toolchain only): - -``` -cargo bench -``` - -### Documentation - -Current documentation is available at https://docs.rs/croaring/latest/croaring/ diff --git a/cmake-build-debug/.cmake/api/v1/query/cache-v2 b/cmake-build-debug/.cmake/api/v1/query/cache-v2 new file mode 100644 index 0000000..e69de29 diff --git a/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 b/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 new file mode 100644 index 0000000..e69de29 diff --git a/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 b/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 new file mode 100644 index 0000000..e69de29 diff --git a/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 b/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 new file mode 100644 index 0000000..e69de29 diff --git a/cmake-build-debug/.cmake/api/v1/reply/cache-v2-2a80ea20e2433af95e40.json b/cmake-build-debug/.cmake/api/v1/reply/cache-v2-2a80ea20e2433af95e40.json new file mode 100644 index 0000000..8ae68ba --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/cache-v2-2a80ea20e2433af95e40.json @@ -0,0 +1,1199 @@ +{ + "entries" : + [ + { + "name" : "CMAKE_ADDR2LINE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "CMAKE_ADDR2LINE-NOTFOUND" + }, + { + "name" : "CMAKE_AR", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar" + }, + { + "name" : "CMAKE_BUILD_TYPE", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ..." + } + ], + "type" : "STRING", + "value" : "Debug" + }, + { + "name" : "CMAKE_CACHEFILE_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "This is the directory where this CMakeCache.txt was created" + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug" + }, + { + "name" : "CMAKE_CACHE_MAJOR_VERSION", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Major version of cmake used to create the current loaded cache" + } + ], + "type" : "INTERNAL", + "value" : "3" + }, + { + "name" : "CMAKE_CACHE_MINOR_VERSION", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Minor version of cmake used to create the current loaded cache" + } + ], + "type" : "INTERNAL", + "value" : "27" + }, + { + "name" : "CMAKE_CACHE_PATCH_VERSION", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Patch version of cmake used to create the current loaded cache" + } + ], + "type" : "INTERNAL", + "value" : "8" + }, + { + "name" : "CMAKE_COLOR_DIAGNOSTICS", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Enable colored diagnostics throughout." + } + ], + "type" : "BOOL", + "value" : "ON" + }, + { + "name" : "CMAKE_COMMAND", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Path to CMake executable." + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake" + }, + { + "name" : "CMAKE_CPACK_COMMAND", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Path to cpack program executable." + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cpack" + }, + { + "name" : "CMAKE_CTEST_COMMAND", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Path to ctest program executable." + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/ctest" + }, + { + "name" : "CMAKE_CXX_COMPILER", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "CXX compiler" + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++" + }, + { + "name" : "CMAKE_CXX_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the CXX compiler during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_CXX_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the CXX compiler during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "-g" + }, + { + "name" : "CMAKE_CXX_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the CXX compiler during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "-Os -DNDEBUG" + }, + { + "name" : "CMAKE_CXX_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the CXX compiler during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "-O3 -DNDEBUG" + }, + { + "name" : "CMAKE_CXX_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the CXX compiler during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "-O2 -g -DNDEBUG" + }, + { + "name" : "CMAKE_C_COMPILER", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "C compiler" + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" + }, + { + "name" : "CMAKE_C_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the C compiler during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_C_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the C compiler during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "-g" + }, + { + "name" : "CMAKE_C_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the C compiler during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "-Os -DNDEBUG" + }, + { + "name" : "CMAKE_C_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the C compiler during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "-O3 -DNDEBUG" + }, + { + "name" : "CMAKE_C_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the C compiler during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "-O2 -g -DNDEBUG" + }, + { + "name" : "CMAKE_DLLTOOL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "CMAKE_DLLTOOL-NOTFOUND" + }, + { + "name" : "CMAKE_EXECUTABLE_FORMAT", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Executable file format" + } + ], + "type" : "INTERNAL", + "value" : "MACHO" + }, + { + "name" : "CMAKE_EXE_LINKER_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_EXE_LINKER_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_EXE_LINKER_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_EXE_LINKER_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_EXPORT_COMPILE_COMMANDS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Enable/Disable output of compile commands during generation." + } + ], + "type" : "BOOL", + "value" : "" + }, + { + "name" : "CMAKE_EXTRA_GENERATOR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Name of external makefile project generator." + } + ], + "type" : "INTERNAL", + "value" : "" + }, + { + "name" : "CMAKE_FIND_PACKAGE_REDIRECTS_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake." + } + ], + "type" : "STATIC", + "value" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/pkgRedirects" + }, + { + "name" : "CMAKE_GENERATOR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Name of generator." + } + ], + "type" : "INTERNAL", + "value" : "Ninja" + }, + { + "name" : "CMAKE_GENERATOR_INSTANCE", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Generator instance identifier." + } + ], + "type" : "INTERNAL", + "value" : "" + }, + { + "name" : "CMAKE_GENERATOR_PLATFORM", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Name of generator platform." + } + ], + "type" : "INTERNAL", + "value" : "" + }, + { + "name" : "CMAKE_GENERATOR_TOOLSET", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Name of generator toolset." + } + ], + "type" : "INTERNAL", + "value" : "" + }, + { + "name" : "CMAKE_HOME_DIRECTORY", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Source directory with the top level CMakeLists.txt file for this project" + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Development/tmp/croaring-msvc" + }, + { + "name" : "CMAKE_INSTALL_NAME_TOOL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/usr/bin/install_name_tool" + }, + { + "name" : "CMAKE_INSTALL_PREFIX", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Install path prefix, prepended onto install directories." + } + ], + "type" : "PATH", + "value" : "/usr/local" + }, + { + "name" : "CMAKE_LINKER", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" + }, + { + "name" : "CMAKE_MAKE_PROGRAM", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "No help, variable specified on the command line." + } + ], + "type" : "UNINITIALIZED", + "value" : "/Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja" + }, + { + "name" : "CMAKE_MODULE_LINKER_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of modules during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_MODULE_LINKER_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of modules during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of modules during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_MODULE_LINKER_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of modules during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of modules during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_NM", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm" + }, + { + "name" : "CMAKE_NUMBER_OF_MAKEFILES", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "number of local generators" + } + ], + "type" : "INTERNAL", + "value" : "1" + }, + { + "name" : "CMAKE_OBJCOPY", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "CMAKE_OBJCOPY-NOTFOUND" + }, + { + "name" : "CMAKE_OBJDUMP", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump" + }, + { + "name" : "CMAKE_OSX_ARCHITECTURES", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Build architectures for OSX" + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_OSX_DEPLOYMENT_TARGET", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_OSX_SYSROOT", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "The product will be built against the headers and libraries located inside the indicated SDK." + } + ], + "type" : "PATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk" + }, + { + "name" : "CMAKE_PLATFORM_INFO_INITIALIZED", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Platform information initialized" + } + ], + "type" : "INTERNAL", + "value" : "1" + }, + { + "name" : "CMAKE_PROJECT_DESCRIPTION", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "" + }, + { + "name" : "CMAKE_PROJECT_HOMEPAGE_URL", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "" + }, + { + "name" : "CMAKE_PROJECT_NAME", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "roaring_fast_or" + }, + { + "name" : "CMAKE_RANLIB", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" + }, + { + "name" : "CMAKE_READELF", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "CMAKE_READELF-NOTFOUND" + }, + { + "name" : "CMAKE_ROOT", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Path to CMake installation." + } + ], + "type" : "INTERNAL", + "value" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27" + }, + { + "name" : "CMAKE_SHARED_LINKER_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of shared libraries during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_SHARED_LINKER_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of shared libraries during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of shared libraries during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_SHARED_LINKER_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of shared libraries during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of shared libraries during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_SKIP_INSTALL_RPATH", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "If set, runtime paths are not added when installing shared libraries, but are added when building." + } + ], + "type" : "BOOL", + "value" : "NO" + }, + { + "name" : "CMAKE_SKIP_RPATH", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "If set, runtime paths are not added when using shared libraries." + } + ], + "type" : "BOOL", + "value" : "NO" + }, + { + "name" : "CMAKE_STATIC_LINKER_FLAGS", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of static libraries during all build types." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_STATIC_LINKER_FLAGS_DEBUG", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of static libraries during DEBUG builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of static libraries during MINSIZEREL builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_STATIC_LINKER_FLAGS_RELEASE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of static libraries during RELEASE builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Flags used by the linker during the creation of static libraries during RELWITHDEBINFO builds." + } + ], + "type" : "STRING", + "value" : "" + }, + { + "name" : "CMAKE_STRIP", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip" + }, + { + "name" : "CMAKE_TAPI", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "Path to a program." + } + ], + "type" : "FILEPATH", + "value" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi" + }, + { + "name" : "CMAKE_UNAME", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "uname command" + } + ], + "type" : "INTERNAL", + "value" : "/usr/bin/uname" + }, + { + "name" : "CMAKE_VERBOSE_MAKEFILE", + "properties" : + [ + { + "name" : "ADVANCED", + "value" : "1" + }, + { + "name" : "HELPSTRING", + "value" : "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo." + } + ], + "type" : "BOOL", + "value" : "FALSE" + }, + { + "name" : "Project_BINARY_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug" + }, + { + "name" : "Project_IS_TOP_LEVEL", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "ON" + }, + { + "name" : "Project_SOURCE_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "/Users/zach/Development/tmp/croaring-msvc" + }, + { + "name" : "roaring_fast_or_BINARY_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug" + }, + { + "name" : "roaring_fast_or_IS_TOP_LEVEL", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "ON" + }, + { + "name" : "roaring_fast_or_SOURCE_DIR", + "properties" : + [ + { + "name" : "HELPSTRING", + "value" : "Value Computed by CMake" + } + ], + "type" : "STATIC", + "value" : "/Users/zach/Development/tmp/croaring-msvc" + } + ], + "kind" : "cache", + "version" : + { + "major" : 2, + "minor" : 0 + } +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-7ef9780769d67b4a8a6d.json b/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-7ef9780769d67b4a8a6d.json new file mode 100644 index 0000000..b566c62 --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-7ef9780769d67b4a8a6d.json @@ -0,0 +1,117 @@ +{ + "inputs" : + [ + { + "path" : "CMakeLists.txt" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeSystem.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInitialize.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin-Initialize.cmake" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeCCompiler.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeGenericSystem.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeInitializeConfigs.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/UnixPaths.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeLanguageInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/AppleClang-C.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/Clang.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/CMakeCommonCompilerMacros.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/CMakeCommonCompilerMacros.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-AppleClang-C.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang-C.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCommonLanguageInclude.cmake" + } + ], + "kind" : "cmakeFiles", + "paths" : + { + "build" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug", + "source" : "/Users/zach/Development/tmp/croaring-msvc" + }, + "version" : + { + "major" : 1, + "minor" : 0 + } +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-f168cd644439447f0089.json b/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-f168cd644439447f0089.json new file mode 100644 index 0000000..f93c5d2 --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-f168cd644439447f0089.json @@ -0,0 +1,60 @@ +{ + "configurations" : + [ + { + "directories" : + [ + { + "build" : ".", + "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", + "minimumCMakeVersion" : + { + "string" : "3.0" + }, + "projectIndex" : 0, + "source" : ".", + "targetIndexes" : + [ + 0 + ] + } + ], + "name" : "Debug", + "projects" : + [ + { + "directoryIndexes" : + [ + 0 + ], + "name" : "roaring_fast_or", + "targetIndexes" : + [ + 0 + ] + } + ], + "targets" : + [ + { + "directoryIndex" : 0, + "id" : "roaring_fast_or::@6890427a1f51a3e7e1df", + "jsonFile" : "target-roaring_fast_or-Debug-1f69037d90c137ef09f2.json", + "name" : "roaring_fast_or", + "projectIndex" : 0 + } + ] + } + ], + "kind" : "codemodel", + "paths" : + { + "build" : "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug", + "source" : "/Users/zach/Development/tmp/croaring-msvc" + }, + "version" : + { + "major" : 2, + "minor" : 6 + } +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json b/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json new file mode 100644 index 0000000..3a67af9 --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json @@ -0,0 +1,14 @@ +{ + "backtraceGraph" : + { + "commands" : [], + "files" : [], + "nodes" : [] + }, + "installers" : [], + "paths" : + { + "build" : ".", + "source" : "." + } +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/index-2024-01-29T03-57-29-0369.json b/cmake-build-debug/.cmake/api/v1/reply/index-2024-01-29T03-57-29-0369.json new file mode 100644 index 0000000..684ecd9 --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/index-2024-01-29T03-57-29-0369.json @@ -0,0 +1,108 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "Ninja" + }, + "paths" : + { + "cmake" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake", + "cpack" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cpack", + "ctest" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/ctest", + "root" : "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27" + }, + "version" : + { + "isDirty" : false, + "major" : 3, + "minor" : 27, + "patch" : 8, + "string" : "3.27.8", + "suffix" : "" + } + }, + "objects" : + [ + { + "jsonFile" : "codemodel-v2-f168cd644439447f0089.json", + "kind" : "codemodel", + "version" : + { + "major" : 2, + "minor" : 6 + } + }, + { + "jsonFile" : "cache-v2-2a80ea20e2433af95e40.json", + "kind" : "cache", + "version" : + { + "major" : 2, + "minor" : 0 + } + }, + { + "jsonFile" : "cmakeFiles-v1-7ef9780769d67b4a8a6d.json", + "kind" : "cmakeFiles", + "version" : + { + "major" : 1, + "minor" : 0 + } + }, + { + "jsonFile" : "toolchains-v1-5f001e191be648574954.json", + "kind" : "toolchains", + "version" : + { + "major" : 1, + "minor" : 0 + } + } + ], + "reply" : + { + "cache-v2" : + { + "jsonFile" : "cache-v2-2a80ea20e2433af95e40.json", + "kind" : "cache", + "version" : + { + "major" : 2, + "minor" : 0 + } + }, + "cmakeFiles-v1" : + { + "jsonFile" : "cmakeFiles-v1-7ef9780769d67b4a8a6d.json", + "kind" : "cmakeFiles", + "version" : + { + "major" : 1, + "minor" : 0 + } + }, + "codemodel-v2" : + { + "jsonFile" : "codemodel-v2-f168cd644439447f0089.json", + "kind" : "codemodel", + "version" : + { + "major" : 2, + "minor" : 6 + } + }, + "toolchains-v1" : + { + "jsonFile" : "toolchains-v1-5f001e191be648574954.json", + "kind" : "toolchains", + "version" : + { + "major" : 1, + "minor" : 0 + } + } + } +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/target-roaring_fast_or-Debug-1f69037d90c137ef09f2.json b/cmake-build-debug/.cmake/api/v1/reply/target-roaring_fast_or-Debug-1f69037d90c137ef09f2.json new file mode 100644 index 0000000..862e95e --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/target-roaring_fast_or-Debug-1f69037d90c137ef09f2.json @@ -0,0 +1,91 @@ +{ + "artifacts" : + [ + { + "path" : "roaring_fast_or" + } + ], + "backtrace" : 1, + "backtraceGraph" : + { + "commands" : + [ + "add_executable" + ], + "files" : + [ + "CMakeLists.txt" + ], + "nodes" : + [ + { + "file" : 0 + }, + { + "command" : 0, + "file" : 0, + "line" : 5, + "parent" : 0 + } + ] + }, + "compileGroups" : + [ + { + "compileCommandFragments" : + [ + { + "fragment" : "-g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics" + } + ], + "language" : "C", + "sourceIndexes" : + [ + 0 + ] + } + ], + "id" : "roaring_fast_or::@6890427a1f51a3e7e1df", + "link" : + { + "commandFragments" : + [ + { + "fragment" : "-g", + "role" : "flags" + }, + { + "fragment" : "", + "role" : "flags" + } + ], + "language" : "C" + }, + "name" : "roaring_fast_or", + "nameOnDisk" : "roaring_fast_or", + "paths" : + { + "build" : ".", + "source" : "." + }, + "sourceGroups" : + [ + { + "name" : "Source Files", + "sourceIndexes" : + [ + 0 + ] + } + ], + "sources" : + [ + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "roaring_fast_or.c", + "sourceGroupIndex" : 0 + } + ], + "type" : "EXECUTABLE" +} diff --git a/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-5f001e191be648574954.json b/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-5f001e191be648574954.json new file mode 100644 index 0000000..6e4c570 --- /dev/null +++ b/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-5f001e191be648574954.json @@ -0,0 +1,37 @@ +{ + "kind" : "toolchains", + "toolchains" : + [ + { + "compiler" : + { + "id" : "AppleClang", + "implicit" : + { + "includeDirectories" : + [ + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include", + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" + ], + "linkDirectories" : [], + "linkFrameworkDirectories" : [], + "linkLibraries" : [] + }, + "path" : "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc", + "version" : "15.0.0.15000100" + }, + "language" : "C", + "sourceFileExtensions" : + [ + "c", + "m" + ] + } + ], + "version" : + { + "major" : 1, + "minor" : 0 + } +} diff --git a/cmake-build-debug/CMakeCache.txt b/cmake-build-debug/CMakeCache.txt new file mode 100644 index 0000000..0a19ca8 --- /dev/null +++ b/cmake-build-debug/CMakeCache.txt @@ -0,0 +1,372 @@ +# This is the CMakeCache file. +# For build in directory: /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug +# It was generated by CMake: /opt/homebrew/Cellar/cmake/3.28.1/bin/cmake +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a variable in the cache. +# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//Path to a program. +CMAKE_ADDR2LINE:FILEPATH=CMAKE_ADDR2LINE-NOTFOUND + +//Path to a program. +CMAKE_AR:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar + +//Choose the type of build, options are: None Debug Release RelWithDebInfo +// MinSizeRel ... +CMAKE_BUILD_TYPE:STRING=Debug + +//Enable colored diagnostics throughout. +CMAKE_COLOR_DIAGNOSTICS:BOOL=ON + +//CXX compiler +CMAKE_CXX_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ + +//Flags used by the CXX compiler during all build types. +CMAKE_CXX_FLAGS:STRING= + +//Flags used by the CXX compiler during DEBUG builds. +CMAKE_CXX_FLAGS_DEBUG:STRING=-g + +//Flags used by the CXX compiler during MINSIZEREL builds. +CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the CXX compiler during RELEASE builds. +CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the CXX compiler during RELWITHDEBINFO builds. +CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG + +//C compiler +CMAKE_C_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc + +//Flags used by the C compiler during all build types. +CMAKE_C_FLAGS:STRING= + +//Flags used by the C compiler during DEBUG builds. +CMAKE_C_FLAGS_DEBUG:STRING=-g + +//Flags used by the C compiler during MINSIZEREL builds. +CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the C compiler during RELEASE builds. +CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the C compiler during RELWITHDEBINFO builds. +CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG + +//Path to a program. +CMAKE_DLLTOOL:FILEPATH=CMAKE_DLLTOOL-NOTFOUND + +//Flags used by the linker during all build types. +CMAKE_EXE_LINKER_FLAGS:STRING= + +//Flags used by the linker during DEBUG builds. +CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during MINSIZEREL builds. +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during RELEASE builds. +CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during RELWITHDEBINFO builds. +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Enable/Disable output of compile commands during generation. +CMAKE_EXPORT_COMPILE_COMMANDS:BOOL= + +//Value Computed by CMake. +CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/pkgRedirects + +//Path to a program. +CMAKE_INSTALL_NAME_TOOL:FILEPATH=/usr/bin/install_name_tool + +//Install path prefix, prepended onto install directories. +CMAKE_INSTALL_PREFIX:PATH=/usr/local + +//Path to a program. +CMAKE_LINKER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld + +//No help, variable specified on the command line. +CMAKE_MAKE_PROGRAM:UNINITIALIZED=/Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja + +//Flags used by the linker during the creation of modules during +// all build types. +CMAKE_MODULE_LINKER_FLAGS:STRING= + +//Flags used by the linker during the creation of modules during +// DEBUG builds. +CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during the creation of modules during +// MINSIZEREL builds. +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during the creation of modules during +// RELEASE builds. +CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during the creation of modules during +// RELWITHDEBINFO builds. +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_NM:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm + +//Path to a program. +CMAKE_OBJCOPY:FILEPATH=CMAKE_OBJCOPY-NOTFOUND + +//Path to a program. +CMAKE_OBJDUMP:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump + +//Build architectures for OSX +CMAKE_OSX_ARCHITECTURES:STRING= + +//Minimum OS X version to target for deployment (at runtime); newer +// APIs weak linked. Set to empty string for default value. +CMAKE_OSX_DEPLOYMENT_TARGET:STRING= + +//The product will be built against the headers and libraries located +// inside the indicated SDK. +CMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk + +//Value Computed by CMake +CMAKE_PROJECT_DESCRIPTION:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_HOMEPAGE_URL:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_NAME:STATIC=roaring_fast_or + +//Path to a program. +CMAKE_RANLIB:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib + +//Path to a program. +CMAKE_READELF:FILEPATH=CMAKE_READELF-NOTFOUND + +//Flags used by the linker during the creation of shared libraries +// during all build types. +CMAKE_SHARED_LINKER_FLAGS:STRING= + +//Flags used by the linker during the creation of shared libraries +// during DEBUG builds. +CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during the creation of shared libraries +// during MINSIZEREL builds. +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during the creation of shared libraries +// during RELEASE builds. +CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during the creation of shared libraries +// during RELWITHDEBINFO builds. +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//If set, runtime paths are not added when installing shared libraries, +// but are added when building. +CMAKE_SKIP_INSTALL_RPATH:BOOL=NO + +//If set, runtime paths are not added when using shared libraries. +CMAKE_SKIP_RPATH:BOOL=NO + +//Flags used by the linker during the creation of static libraries +// during all build types. +CMAKE_STATIC_LINKER_FLAGS:STRING= + +//Flags used by the linker during the creation of static libraries +// during DEBUG builds. +CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during the creation of static libraries +// during MINSIZEREL builds. +CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during the creation of static libraries +// during RELEASE builds. +CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during the creation of static libraries +// during RELWITHDEBINFO builds. +CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_STRIP:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip + +//Path to a program. +CMAKE_TAPI:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi + +//If this value is on, makefiles will be generated without the +// .SILENT directive, and all commands will be echoed to the console +// during the make. This is useful for debugging only. With Visual +// Studio IDE projects all commands are done without /nologo. +CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE + +//Value Computed by CMake +Project_BINARY_DIR:STATIC=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug + +//Value Computed by CMake +Project_IS_TOP_LEVEL:STATIC=ON + +//Value Computed by CMake +Project_SOURCE_DIR:STATIC=/Users/zach/Development/tmp/croaring-msvc + +//Value Computed by CMake +roaring_fast_or_BINARY_DIR:STATIC=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug + +//Value Computed by CMake +roaring_fast_or_IS_TOP_LEVEL:STATIC=ON + +//Value Computed by CMake +roaring_fast_or_SOURCE_DIR:STATIC=/Users/zach/Development/tmp/croaring-msvc + + +######################## +# INTERNAL cache entries +######################## + +//ADVANCED property for variable: CMAKE_ADDR2LINE +CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_AR +CMAKE_AR-ADVANCED:INTERNAL=1 +//This is the directory where this CMakeCache.txt was created +CMAKE_CACHEFILE_DIR:INTERNAL=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3 +//Minor version of cmake used to create the current loaded cache +CMAKE_CACHE_MINOR_VERSION:INTERNAL=28 +//Patch version of cmake used to create the current loaded cache +CMAKE_CACHE_PATCH_VERSION:INTERNAL=1 +//Path to CMake executable. +CMAKE_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake +//Path to cpack program executable. +CMAKE_CPACK_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.28.1/bin/cpack +//Path to ctest program executable. +CMAKE_CTEST_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.28.1/bin/ctest +//ADVANCED property for variable: CMAKE_CXX_COMPILER +CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS +CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG +CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL +CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE +CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO +CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_COMPILER +CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS +CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG +CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL +CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE +CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO +CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_DLLTOOL +CMAKE_DLLTOOL-ADVANCED:INTERNAL=1 +//Executable file format +CMAKE_EXECUTABLE_FORMAT:INTERNAL=MACHO +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS +CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG +CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE +CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS +CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1 +//Name of external makefile project generator. +CMAKE_EXTRA_GENERATOR:INTERNAL= +//Name of generator. +CMAKE_GENERATOR:INTERNAL=Ninja +//Generator instance identifier. +CMAKE_GENERATOR_INSTANCE:INTERNAL= +//Name of generator platform. +CMAKE_GENERATOR_PLATFORM:INTERNAL= +//Name of generator toolset. +CMAKE_GENERATOR_TOOLSET:INTERNAL= +//Source directory with the top level CMakeLists.txt file for this +// project +CMAKE_HOME_DIRECTORY:INTERNAL=/Users/zach/Development/tmp/croaring-msvc +//ADVANCED property for variable: CMAKE_INSTALL_NAME_TOOL +CMAKE_INSTALL_NAME_TOOL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_LINKER +CMAKE_LINKER-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS +CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG +CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE +CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_NM +CMAKE_NM-ADVANCED:INTERNAL=1 +//number of local generators +CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1 +//ADVANCED property for variable: CMAKE_OBJCOPY +CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_OBJDUMP +CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 +//Platform information initialized +CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_RANLIB +CMAKE_RANLIB-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_READELF +CMAKE_READELF-ADVANCED:INTERNAL=1 +//Path to CMake installation. +CMAKE_ROOT:INTERNAL=/opt/homebrew/Cellar/cmake/3.28.1/share/cmake +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS +CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG +CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE +CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH +CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_SKIP_RPATH +CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS +CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG +CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL +CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE +CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_STRIP +CMAKE_STRIP-ADVANCED:INTERNAL=1 +//ADVANCED property for variable: CMAKE_TAPI +CMAKE_TAPI-ADVANCED:INTERNAL=1 +//uname command +CMAKE_UNAME:INTERNAL=/usr/bin/uname +//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE +CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 + diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CMakeCCompiler.cmake b/cmake-build-debug/CMakeFiles/3.27.8/CMakeCCompiler.cmake new file mode 100644 index 0000000..cd8bd95 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/3.27.8/CMakeCCompiler.cmake @@ -0,0 +1,74 @@ +set(CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc") +set(CMAKE_C_COMPILER_ARG1 "") +set(CMAKE_C_COMPILER_ID "AppleClang") +set(CMAKE_C_COMPILER_VERSION "15.0.0.15000100") +set(CMAKE_C_COMPILER_VERSION_INTERNAL "") +set(CMAKE_C_COMPILER_WRAPPER "") +set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "17") +set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "ON") +set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert;c_std_17;c_std_23") +set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") +set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") +set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") +set(CMAKE_C17_COMPILE_FEATURES "c_std_17") +set(CMAKE_C23_COMPILE_FEATURES "c_std_23") + +set(CMAKE_C_PLATFORM_ID "Darwin") +set(CMAKE_C_SIMULATE_ID "") +set(CMAKE_C_COMPILER_FRONTEND_VARIANT "GNU") +set(CMAKE_C_SIMULATE_VERSION "") + + + + +set(CMAKE_AR "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar") +set(CMAKE_C_COMPILER_AR "") +set(CMAKE_RANLIB "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib") +set(CMAKE_C_COMPILER_RANLIB "") +set(CMAKE_LINKER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld") +set(CMAKE_MT "") +set(CMAKE_TAPI "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi") +set(CMAKE_COMPILER_IS_GNUCC ) +set(CMAKE_C_COMPILER_LOADED 1) +set(CMAKE_C_COMPILER_WORKS TRUE) +set(CMAKE_C_ABI_COMPILED TRUE) + +set(CMAKE_C_COMPILER_ENV_VAR "CC") + +set(CMAKE_C_COMPILER_ID_RUN 1) +set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) +set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +set(CMAKE_C_LINKER_PREFERENCE 10) +set(CMAKE_C_LINKER_DEPFILE_SUPPORTED FALSE) + +# Save compiler ABI information. +set(CMAKE_C_SIZEOF_DATA_PTR "8") +set(CMAKE_C_COMPILER_ABI "") +set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN") +set(CMAKE_C_LIBRARY_ARCHITECTURE "") + +if(CMAKE_C_SIZEOF_DATA_PTR) + set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") +endif() + +if(CMAKE_C_COMPILER_ABI) + set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") +endif() + +if(CMAKE_C_LIBRARY_ARCHITECTURE) + set(CMAKE_LIBRARY_ARCHITECTURE "") +endif() + +set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") +if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) + set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") +endif() + + + + + +set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include") +set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "") +set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "") +set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CMakeCXXCompiler.cmake b/cmake-build-debug/CMakeFiles/3.27.8/CMakeCXXCompiler.cmake new file mode 100644 index 0000000..d3d0e76 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/3.27.8/CMakeCXXCompiler.cmake @@ -0,0 +1,85 @@ +set(CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++") +set(CMAKE_CXX_COMPILER_ARG1 "") +set(CMAKE_CXX_COMPILER_ID "AppleClang") +set(CMAKE_CXX_COMPILER_VERSION "15.0.0.15000100") +set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "") +set(CMAKE_CXX_COMPILER_WRAPPER "") +set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "98") +set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "ON") +set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20;cxx_std_23") +set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters") +set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") +set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates") +set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17") +set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20") +set(CMAKE_CXX23_COMPILE_FEATURES "cxx_std_23") + +set(CMAKE_CXX_PLATFORM_ID "Darwin") +set(CMAKE_CXX_SIMULATE_ID "") +set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "GNU") +set(CMAKE_CXX_SIMULATE_VERSION "") + + + + +set(CMAKE_AR "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar") +set(CMAKE_CXX_COMPILER_AR "") +set(CMAKE_RANLIB "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib") +set(CMAKE_CXX_COMPILER_RANLIB "") +set(CMAKE_LINKER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld") +set(CMAKE_MT "") +set(CMAKE_TAPI "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi") +set(CMAKE_COMPILER_IS_GNUCXX ) +set(CMAKE_CXX_COMPILER_LOADED 1) +set(CMAKE_CXX_COMPILER_WORKS TRUE) +set(CMAKE_CXX_ABI_COMPILED TRUE) + +set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") + +set(CMAKE_CXX_COMPILER_ID_RUN 1) +set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm;ccm;cxxm;c++m) +set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) + +foreach (lang C OBJC OBJCXX) + if (CMAKE_${lang}_COMPILER_ID_RUN) + foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS) + list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension}) + endforeach() + endif() +endforeach() + +set(CMAKE_CXX_LINKER_PREFERENCE 30) +set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) +set(CMAKE_CXX_LINKER_DEPFILE_SUPPORTED FALSE) + +# Save compiler ABI information. +set(CMAKE_CXX_SIZEOF_DATA_PTR "8") +set(CMAKE_CXX_COMPILER_ABI "") +set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN") +set(CMAKE_CXX_LIBRARY_ARCHITECTURE "") + +if(CMAKE_CXX_SIZEOF_DATA_PTR) + set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") +endif() + +if(CMAKE_CXX_COMPILER_ABI) + set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") +endif() + +if(CMAKE_CXX_LIBRARY_ARCHITECTURE) + set(CMAKE_LIBRARY_ARCHITECTURE "") +endif() + +set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "") +if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX) + set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}") +endif() + + + + + +set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include") +set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "c++") +set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "") +set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_C.bin b/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_C.bin new file mode 100755 index 0000000..3f0256b Binary files /dev/null and b/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_C.bin differ diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_CXX.bin b/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_CXX.bin new file mode 100755 index 0000000..5262686 Binary files /dev/null and b/cmake-build-debug/CMakeFiles/3.27.8/CMakeDetermineCompilerABI_CXX.bin differ diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CMakeSystem.cmake b/cmake-build-debug/CMakeFiles/3.27.8/CMakeSystem.cmake new file mode 100644 index 0000000..d0903e1 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/3.27.8/CMakeSystem.cmake @@ -0,0 +1,15 @@ +set(CMAKE_HOST_SYSTEM "Darwin-23.2.0") +set(CMAKE_HOST_SYSTEM_NAME "Darwin") +set(CMAKE_HOST_SYSTEM_VERSION "23.2.0") +set(CMAKE_HOST_SYSTEM_PROCESSOR "arm64") + + + +set(CMAKE_SYSTEM "Darwin-23.2.0") +set(CMAKE_SYSTEM_NAME "Darwin") +set(CMAKE_SYSTEM_VERSION "23.2.0") +set(CMAKE_SYSTEM_PROCESSOR "arm64") + +set(CMAKE_CROSSCOMPILING "FALSE") + +set(CMAKE_SYSTEM_LOADED 1) diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdC/CMakeCCompilerId.c b/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdC/CMakeCCompilerId.c new file mode 100644 index 0000000..66be365 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdC/CMakeCCompilerId.c @@ -0,0 +1,866 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +#if defined(__18CXX) +# define ID_VOID_MAIN +#endif +#if defined(__CLASSIC_C__) +/* cv-qualifiers did not exist in K&R C */ +# define const +# define volatile +#endif + +#if !defined(__has_include) +/* If the compiler does not have __has_include, pretend the answer is + always no. */ +# define __has_include(x) 0 +#endif + + +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# if defined(__GNUC__) +# define SIMULATE_ID "GNU" +# endif + /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, + except that a few beta releases use the old format with V=2021. */ +# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif +# else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) + /* The third version component from --version is an update index, + but no macro is provided for it. */ +# define COMPILER_VERSION_PATCH DEC(0) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) +# define COMPILER_ID "IntelLLVM" +#if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +#endif +#if defined(__GNUC__) +# define SIMULATE_ID "GNU" +#endif +/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and + * later. Look for 6 digit vs. 8 digit version number to decide encoding. + * VVVV is no smaller than the current year when a version is released. + */ +#if __INTEL_LLVM_COMPILER < 1000000L +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) +#else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) +#endif +#if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +#endif +#if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +#elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +#endif +#if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +#endif +#if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +#endif + +#elif defined(__PATHCC__) +# define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif + +#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) +# define COMPILER_ID "Embarcadero" +# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) +# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) +# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) + +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__WATCOMC__) +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__SUNPRO_C) +# define COMPILER_ID "SunPro" +# if __SUNPRO_C >= 0x5100 + /* __SUNPRO_C = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# endif + +#elif defined(__HP_cc) +# define COMPILER_ID "HP" + /* __HP_cc = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) + +#elif defined(__DECC) +# define COMPILER_ID "Compaq" + /* __DECC_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) + +#elif defined(__IBMC__) && defined(__COMPILER_VER__) +# define COMPILER_ID "zOS" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__open_xl__) && defined(__clang__) +# define COMPILER_ID "IBMClang" +# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__) +# define COMPILER_VERSION_MINOR DEC(__open_xl_release__) +# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__) + + +#elif defined(__ibmxl__) && defined(__clang__) +# define COMPILER_ID "XLClang" +# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) +# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) +# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) + + +#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 +# define COMPILER_ID "XL" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 +# define COMPILER_ID "VisualAge" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__NVCOMPILER) +# define COMPILER_ID "NVHPC" +# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) +# if defined(__NVCOMPILER_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) +# endif + +#elif defined(__PGI) +# define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif + +#elif defined(_CRAYC) +# define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) + +#elif defined(__TI_COMPILER_VERSION__) +# define COMPILER_ID "TI" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) + +#elif defined(__CLANG_FUJITSU) +# define COMPILER_ID "FujitsuClang" +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(__FUJITSU) +# define COMPILER_ID "Fujitsu" +# if defined(__FCC_version__) +# define COMPILER_VERSION __FCC_version__ +# elif defined(__FCC_major__) +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# endif +# if defined(__fcc_version) +# define COMPILER_VERSION_INTERNAL DEC(__fcc_version) +# elif defined(__FCC_VERSION) +# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) +# endif + + +#elif defined(__ghs__) +# define COMPILER_ID "GHS" +/* __GHS_VERSION_NUMBER = VVVVRP */ +# ifdef __GHS_VERSION_NUMBER +# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) +# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) +# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) +# endif + +#elif defined(__TASKING__) +# define COMPILER_ID "Tasking" + # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000) + # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100) +# define COMPILER_VERSION_INTERNAL DEC(__VERSION__) + +#elif defined(__TINYC__) +# define COMPILER_ID "TinyCC" + +#elif defined(__BCC__) +# define COMPILER_ID "Bruce" + +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + +#elif defined(__ARMCC_VERSION) && !defined(__clang__) +# define COMPILER_ID "ARMCC" +#if __ARMCC_VERSION >= 1000000 + /* __ARMCC_VERSION = VRRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#else + /* __ARMCC_VERSION = VRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#endif + + +#elif defined(__clang__) && defined(__apple_build_version__) +# define COMPILER_ID "AppleClang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) + +#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) +# define COMPILER_ID "ARMClang" + # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100) +# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) + +#elif defined(__clang__) +# define COMPILER_ID "Clang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif + +#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) +# define COMPILER_ID "LCC" +# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100) +# if defined(__LCC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) +# endif +# if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define SIMULATE_ID "GNU" +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif +# endif + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# if defined(__GNUC_MINOR__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif + +#elif defined(_ADI_COMPILER) +# define COMPILER_ID "ADSP" +#if defined(__VERSIONNUM__) + /* __VERSIONNUM__ = 0xVVRRPPTT */ +# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF) +# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF) +# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF) +# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF) +#endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# define COMPILER_ID "IAR" +# if defined(__VER__) && defined(__ICCARM__) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) +# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) +# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) +# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) +# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# endif + +#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) +# define COMPILER_ID "SDCC" +# if defined(__SDCC_VERSION_MAJOR) +# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) +# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) +# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) +# else + /* SDCC = VRP */ +# define COMPILER_VERSION_MAJOR DEC(SDCC/100) +# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) +# define COMPILER_VERSION_PATCH DEC(SDCC % 10) +# endif + + +/* These compilers are either not known or too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) +char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; +#endif + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__MSYS__) +# define PLATFORM_ID "MSYS" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU__) +# define PLATFORM_ID "Haiku" + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# elif defined(__VXWORKS__) +# define PLATFORM_ID "VxWorks" + +# else /* unknown platform */ +# define PLATFORM_ID +# endif + +#elif defined(__INTEGRITY) +# if defined(INT_178B) +# define PLATFORM_ID "Integrity178" + +# else /* regular Integrity */ +# define PLATFORM_ID "Integrity" +# endif + +# elif defined(_ADI_COMPILER) +# define PLATFORM_ID "ADSP" + +#else /* unknown platform */ +# define PLATFORM_ID + +#endif + +/* For windows compilers MSVC and Intel we can determine + the architecture of the compiler being used. This is because + the compilers do not have flags that can change the architecture, + but rather depend on which compiler is being used +*/ +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(_M_IA64) +# define ARCHITECTURE_ID "IA64" + +# elif defined(_M_ARM64EC) +# define ARCHITECTURE_ID "ARM64EC" + +# elif defined(_M_X64) || defined(_M_AMD64) +# define ARCHITECTURE_ID "x64" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# elif defined(_M_ARM64) +# define ARCHITECTURE_ID "ARM64" + +# elif defined(_M_ARM) +# if _M_ARM == 4 +# define ARCHITECTURE_ID "ARMV4I" +# elif _M_ARM == 5 +# define ARCHITECTURE_ID "ARMV5I" +# else +# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) +# endif + +# elif defined(_M_MIPS) +# define ARCHITECTURE_ID "MIPS" + +# elif defined(_M_SH) +# define ARCHITECTURE_ID "SHx" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# if defined(__ICCARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + +# elif defined(__ICCRH850__) +# define ARCHITECTURE_ID "RH850" + +# elif defined(__ICCRL78__) +# define ARCHITECTURE_ID "RL78" + +# elif defined(__ICCRISCV__) +# define ARCHITECTURE_ID "RISCV" + +# elif defined(__ICCAVR__) +# define ARCHITECTURE_ID "AVR" + +# elif defined(__ICC430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__ICCV850__) +# define ARCHITECTURE_ID "V850" + +# elif defined(__ICC8051__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__ICCSTM8__) +# define ARCHITECTURE_ID "STM8" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__ghs__) +# if defined(__PPC64__) +# define ARCHITECTURE_ID "PPC64" + +# elif defined(__ppc__) +# define ARCHITECTURE_ID "PPC" + +# elif defined(__ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__x86_64__) +# define ARCHITECTURE_ID "x64" + +# elif defined(__i386__) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__TI_COMPILER_VERSION__) +# if defined(__TI_ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__MSP430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__TMS320C28XX__) +# define ARCHITECTURE_ID "TMS320C28x" + +# elif defined(__TMS320C6X__) || defined(_TMS320C6X) +# define ARCHITECTURE_ID "TMS320C6x" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +# elif defined(__ADSPSHARC__) +# define ARCHITECTURE_ID "SHARC" + +# elif defined(__ADSPBLACKFIN__) +# define ARCHITECTURE_ID "Blackfin" + +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + +#else +# define ARCHITECTURE_ID +#endif + +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number. */ +#ifdef COMPILER_VERSION +char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; + +/* Construct a string literal encoding the version number components. */ +#elif defined(COMPILER_VERSION_MAJOR) +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct a string literal encoding the internal version number. */ +#ifdef COMPILER_VERSION_INTERNAL +char const info_version_internal[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', + 'i','n','t','e','r','n','a','l','[', + COMPILER_VERSION_INTERNAL,']','\0'}; +#elif defined(COMPILER_VERSION_INTERNAL_STR) +char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; +#endif + +/* Construct a string literal encoding the version number components. */ +#ifdef SIMULATE_VERSION_MAJOR +char const info_simulate_version[] = { + 'I', 'N', 'F', 'O', ':', + 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', + SIMULATE_VERSION_MAJOR, +# ifdef SIMULATE_VERSION_MINOR + '.', SIMULATE_VERSION_MINOR, +# ifdef SIMULATE_VERSION_PATCH + '.', SIMULATE_VERSION_PATCH, +# ifdef SIMULATE_VERSION_TWEAK + '.', SIMULATE_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; +char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; + + + +#if !defined(__STDC__) && !defined(__clang__) +# if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) +# define C_VERSION "90" +# else +# define C_VERSION +# endif +#elif __STDC_VERSION__ > 201710L +# define C_VERSION "23" +#elif __STDC_VERSION__ >= 201710L +# define C_VERSION "17" +#elif __STDC_VERSION__ >= 201000L +# define C_VERSION "11" +#elif __STDC_VERSION__ >= 199901L +# define C_VERSION "99" +#else +# define C_VERSION "90" +#endif +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + +/*--------------------------------------------------------------------------*/ + +#ifdef ID_VOID_MAIN +void main() {} +#else +# if defined(__CLASSIC_C__) +int main(argc, argv) int argc; char *argv[]; +# else +int main(int argc, char* argv[]) +# endif +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) + require += info_cray[argc]; +#endif + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; + (void)argv; + return require; +} +#endif diff --git a/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdCXX/CMakeCXXCompilerId.cpp b/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdCXX/CMakeCXXCompilerId.cpp new file mode 100644 index 0000000..52d56e2 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdCXX/CMakeCXXCompilerId.cpp @@ -0,0 +1,855 @@ +/* This source file must have a .cpp extension so that all C++ compilers + recognize the extension without flags. Borland does not know .cxx for + example. */ +#ifndef __cplusplus +# error "A C compiler has been selected for C++." +#endif + +#if !defined(__has_include) +/* If the compiler does not have __has_include, pretend the answer is + always no. */ +# define __has_include(x) 0 +#endif + + +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + +#if defined(__COMO__) +# define COMPILER_ID "Comeau" + /* __COMO_VERSION__ = VRR */ +# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) +# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) + +#elif defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# if defined(__GNUC__) +# define SIMULATE_ID "GNU" +# endif + /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, + except that a few beta releases use the old format with V=2021. */ +# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif +# else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) + /* The third version component from --version is an update index, + but no macro is provided for it. */ +# define COMPILER_VERSION_PATCH DEC(0) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) +# define COMPILER_ID "IntelLLVM" +#if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +#endif +#if defined(__GNUC__) +# define SIMULATE_ID "GNU" +#endif +/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and + * later. Look for 6 digit vs. 8 digit version number to decide encoding. + * VVVV is no smaller than the current year when a version is released. + */ +#if __INTEL_LLVM_COMPILER < 1000000L +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) +#else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) +#endif +#if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +#endif +#if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +#elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +#endif +#if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +#endif +#if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +#endif + +#elif defined(__PATHCC__) +# define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif + +#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) +# define COMPILER_ID "Embarcadero" +# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) +# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) +# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) + +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__WATCOMC__) +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__SUNPRO_CC) +# define COMPILER_ID "SunPro" +# if __SUNPRO_CC >= 0x5100 + /* __SUNPRO_CC = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# endif + +#elif defined(__HP_aCC) +# define COMPILER_ID "HP" + /* __HP_aCC = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) + +#elif defined(__DECCXX) +# define COMPILER_ID "Compaq" + /* __DECCXX_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) + +#elif defined(__IBMCPP__) && defined(__COMPILER_VER__) +# define COMPILER_ID "zOS" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__open_xl__) && defined(__clang__) +# define COMPILER_ID "IBMClang" +# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__) +# define COMPILER_VERSION_MINOR DEC(__open_xl_release__) +# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__) + + +#elif defined(__ibmxl__) && defined(__clang__) +# define COMPILER_ID "XLClang" +# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) +# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) +# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) + + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 +# define COMPILER_ID "XL" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 +# define COMPILER_ID "VisualAge" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__NVCOMPILER) +# define COMPILER_ID "NVHPC" +# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) +# if defined(__NVCOMPILER_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) +# endif + +#elif defined(__PGI) +# define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif + +#elif defined(_CRAYC) +# define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) + +#elif defined(__TI_COMPILER_VERSION__) +# define COMPILER_ID "TI" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) + +#elif defined(__CLANG_FUJITSU) +# define COMPILER_ID "FujitsuClang" +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(__FUJITSU) +# define COMPILER_ID "Fujitsu" +# if defined(__FCC_version__) +# define COMPILER_VERSION __FCC_version__ +# elif defined(__FCC_major__) +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# endif +# if defined(__fcc_version) +# define COMPILER_VERSION_INTERNAL DEC(__fcc_version) +# elif defined(__FCC_VERSION) +# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) +# endif + + +#elif defined(__ghs__) +# define COMPILER_ID "GHS" +/* __GHS_VERSION_NUMBER = VVVVRP */ +# ifdef __GHS_VERSION_NUMBER +# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) +# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) +# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) +# endif + +#elif defined(__TASKING__) +# define COMPILER_ID "Tasking" + # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000) + # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100) +# define COMPILER_VERSION_INTERNAL DEC(__VERSION__) + +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + +#elif defined(__ARMCC_VERSION) && !defined(__clang__) +# define COMPILER_ID "ARMCC" +#if __ARMCC_VERSION >= 1000000 + /* __ARMCC_VERSION = VRRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#else + /* __ARMCC_VERSION = VRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#endif + + +#elif defined(__clang__) && defined(__apple_build_version__) +# define COMPILER_ID "AppleClang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) + +#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) +# define COMPILER_ID "ARMClang" + # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100) +# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) + +#elif defined(__clang__) +# define COMPILER_ID "Clang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif + +#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) +# define COMPILER_ID "LCC" +# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100) +# if defined(__LCC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) +# endif +# if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define SIMULATE_ID "GNU" +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif +# endif + +#elif defined(__GNUC__) || defined(__GNUG__) +# define COMPILER_ID "GNU" +# if defined(__GNUC__) +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# else +# define COMPILER_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif + +#elif defined(_ADI_COMPILER) +# define COMPILER_ID "ADSP" +#if defined(__VERSIONNUM__) + /* __VERSIONNUM__ = 0xVVRRPPTT */ +# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF) +# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF) +# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF) +# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF) +#endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# define COMPILER_ID "IAR" +# if defined(__VER__) && defined(__ICCARM__) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) +# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) +# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) +# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) +# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# endif + + +/* These compilers are either not known or too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) +char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; +#endif + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__MSYS__) +# define PLATFORM_ID "MSYS" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU__) +# define PLATFORM_ID "Haiku" + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# elif defined(__VXWORKS__) +# define PLATFORM_ID "VxWorks" + +# else /* unknown platform */ +# define PLATFORM_ID +# endif + +#elif defined(__INTEGRITY) +# if defined(INT_178B) +# define PLATFORM_ID "Integrity178" + +# else /* regular Integrity */ +# define PLATFORM_ID "Integrity" +# endif + +# elif defined(_ADI_COMPILER) +# define PLATFORM_ID "ADSP" + +#else /* unknown platform */ +# define PLATFORM_ID + +#endif + +/* For windows compilers MSVC and Intel we can determine + the architecture of the compiler being used. This is because + the compilers do not have flags that can change the architecture, + but rather depend on which compiler is being used +*/ +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(_M_IA64) +# define ARCHITECTURE_ID "IA64" + +# elif defined(_M_ARM64EC) +# define ARCHITECTURE_ID "ARM64EC" + +# elif defined(_M_X64) || defined(_M_AMD64) +# define ARCHITECTURE_ID "x64" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# elif defined(_M_ARM64) +# define ARCHITECTURE_ID "ARM64" + +# elif defined(_M_ARM) +# if _M_ARM == 4 +# define ARCHITECTURE_ID "ARMV4I" +# elif _M_ARM == 5 +# define ARCHITECTURE_ID "ARMV5I" +# else +# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) +# endif + +# elif defined(_M_MIPS) +# define ARCHITECTURE_ID "MIPS" + +# elif defined(_M_SH) +# define ARCHITECTURE_ID "SHx" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# if defined(__ICCARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + +# elif defined(__ICCRH850__) +# define ARCHITECTURE_ID "RH850" + +# elif defined(__ICCRL78__) +# define ARCHITECTURE_ID "RL78" + +# elif defined(__ICCRISCV__) +# define ARCHITECTURE_ID "RISCV" + +# elif defined(__ICCAVR__) +# define ARCHITECTURE_ID "AVR" + +# elif defined(__ICC430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__ICCV850__) +# define ARCHITECTURE_ID "V850" + +# elif defined(__ICC8051__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__ICCSTM8__) +# define ARCHITECTURE_ID "STM8" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__ghs__) +# if defined(__PPC64__) +# define ARCHITECTURE_ID "PPC64" + +# elif defined(__ppc__) +# define ARCHITECTURE_ID "PPC" + +# elif defined(__ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__x86_64__) +# define ARCHITECTURE_ID "x64" + +# elif defined(__i386__) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__TI_COMPILER_VERSION__) +# if defined(__TI_ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__MSP430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__TMS320C28XX__) +# define ARCHITECTURE_ID "TMS320C28x" + +# elif defined(__TMS320C6X__) || defined(_TMS320C6X) +# define ARCHITECTURE_ID "TMS320C6x" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +# elif defined(__ADSPSHARC__) +# define ARCHITECTURE_ID "SHARC" + +# elif defined(__ADSPBLACKFIN__) +# define ARCHITECTURE_ID "Blackfin" + +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + +#else +# define ARCHITECTURE_ID +#endif + +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number. */ +#ifdef COMPILER_VERSION +char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; + +/* Construct a string literal encoding the version number components. */ +#elif defined(COMPILER_VERSION_MAJOR) +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct a string literal encoding the internal version number. */ +#ifdef COMPILER_VERSION_INTERNAL +char const info_version_internal[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', + 'i','n','t','e','r','n','a','l','[', + COMPILER_VERSION_INTERNAL,']','\0'}; +#elif defined(COMPILER_VERSION_INTERNAL_STR) +char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; +#endif + +/* Construct a string literal encoding the version number components. */ +#ifdef SIMULATE_VERSION_MAJOR +char const info_simulate_version[] = { + 'I', 'N', 'F', 'O', ':', + 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', + SIMULATE_VERSION_MAJOR, +# ifdef SIMULATE_VERSION_MINOR + '.', SIMULATE_VERSION_MINOR, +# ifdef SIMULATE_VERSION_PATCH + '.', SIMULATE_VERSION_PATCH, +# ifdef SIMULATE_VERSION_TWEAK + '.', SIMULATE_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; +char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; + + + +#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L +# if defined(__INTEL_CXX11_MODE__) +# if defined(__cpp_aggregate_nsdmi) +# define CXX_STD 201402L +# else +# define CXX_STD 201103L +# endif +# else +# define CXX_STD 199711L +# endif +#elif defined(_MSC_VER) && defined(_MSVC_LANG) +# define CXX_STD _MSVC_LANG +#else +# define CXX_STD __cplusplus +#endif + +const char* info_language_standard_default = "INFO" ":" "standard_default[" +#if CXX_STD > 202002L + "23" +#elif CXX_STD > 201703L + "20" +#elif CXX_STD >= 201703L + "17" +#elif CXX_STD >= 201402L + "14" +#elif CXX_STD >= 201103L + "11" +#else + "98" +#endif +"]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) + require += info_cray[argc]; +#endif + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; + (void)argv; + return require; +} diff --git a/cmake-build-debug/CMakeFiles/CMakeConfigureLog.yaml b/cmake-build-debug/CMakeFiles/CMakeConfigureLog.yaml new file mode 100644 index 0000000..1bf15ce --- /dev/null +++ b/cmake-build-debug/CMakeFiles/CMakeConfigureLog.yaml @@ -0,0 +1,378 @@ + +--- +events: + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineSystem.cmake:211 (message)" + - "CMakeLists.txt" + message: | + The system is: Darwin - 23.2.0 - arm64 + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:17 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCCompiler.cmake:123 (CMAKE_DETERMINE_COMPILER_ID)" + - "CMakeLists.txt" + message: | + Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. + Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc + Build flags: + Id flags: + + The output was: + 1 + ld: library 'System' not found + clang: error: linker command failed with exit code 1 (use -v to see invocation) + + + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:17 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCCompiler.cmake:123 (CMAKE_DETERMINE_COMPILER_ID)" + - "CMakeLists.txt" + message: | + Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. + Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc + Build flags: + Id flags: -c + + The output was: + 0 + + + Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o" + + The C compiler identification is AppleClang, found in: + /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdC/CMakeCCompilerId.o + + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:17 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCXXCompiler.cmake:126 (CMAKE_DETERMINE_COMPILER_ID)" + - "CMakeLists.txt" + message: | + Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. + Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ + Build flags: + Id flags: + + The output was: + 1 + ld: library 'c++' not found + clang: error: linker command failed with exit code 1 (use -v to see invocation) + + + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:17 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCXXCompiler.cmake:126 (CMAKE_DETERMINE_COMPILER_ID)" + - "CMakeLists.txt" + message: | + Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. + Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ + Build flags: + Id flags: -c + + The output was: + 0 + + + Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o" + + The CXX compiler identification is AppleClang, found in: + /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/3.27.8/CompilerIdCXX/CMakeCXXCompilerId.o + + - + kind: "try_compile-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + checks: + - "Detecting C compiler ABI info" + directories: + source: "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx" + binary: "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx" + cmakeVariables: + CMAKE_C_FLAGS: "" + CMAKE_OSX_ARCHITECTURES: "" + CMAKE_OSX_DEPLOYMENT_TARGET: "" + CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk" + buildResult: + variable: "CMAKE_C_ABI_COMPILED" + cached: true + stdout: | + Change Dir: '/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx' + + Run Build Command(s): /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -v cmTC_1fb50 + [1/2] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics -v -Wl,-v -MD -MT CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -MF CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o.d -o CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCCompilerABI.c + Apple clang version 15.0.0 (clang-1500.1.0.2.5) + Target: arm64-apple-darwin23.2.0 + Thread model: posix + InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + clang: warning: -Wl,-v: 'linker' input unused [-Wunused-command-line-argument] + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fobjc-msgsend-selector-stubs -target-sdk-version=14.2 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0 -dependency-file CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o.d -skip-unused-modulemap-deps -MT CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdebug-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -x c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCCompilerABI.c + clang -cc1 version 15.0.0 (clang-1500.1.0.2.5) default target arm64-apple-darwin23.2.0 + ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include" + ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/Library/Frameworks" + #include "..." search starts here: + #include <...> search starts here: + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks (framework directory) + End of search list. + [2/2] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -o cmTC_1fb50 && : + Apple clang version 15.0.0 (clang-1500.1.0.2.5) + Target: arm64-apple-darwin23.2.0 + Thread model: posix + InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 14.0.0 14.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -o cmTC_1fb50 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a + @(#)PROGRAM:ld PROJECT:dyld-1022.1 + BUILD 05:27:37 Dec 7 2023 + configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h + will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em + LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) + TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.8) + Library search paths: + Framework search paths: + + exitCode: 0 + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:127 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + message: | + Parsed C implicit include dir info: rv=done + found start of include info + found start of implicit include info + add: [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + add: [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + add: [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + end of search list found + collapse include dir [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] ==> [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + collapse include dir [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] ==> [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + collapse include dir [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] ==> [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + implicit include dirs: [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + + + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:152 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + message: | + Parsed C implicit link information: + link line regex: [^( *|.*[/\\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\\]+-)?ld|collect2)[^/\\]*( |$)] + ignore line: [Change Dir: '/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx'] + ignore line: [] + ignore line: [Run Build Command(s): /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -v cmTC_1fb50] + ignore line: [[1/2] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics -v -Wl -v -MD -MT CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -MF CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o.d -o CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCCompilerABI.c] + ignore line: [Apple clang version 15.0.0 (clang-1500.1.0.2.5)] + ignore line: [Target: arm64-apple-darwin23.2.0] + ignore line: [Thread model: posix] + ignore line: [InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin] + ignore line: [clang: warning: -Wl -v: 'linker' input unused [-Wunused-command-line-argument]] + ignore line: [ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fobjc-msgsend-selector-stubs -target-sdk-version=14.2 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0 -dependency-file CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o.d -skip-unused-modulemap-deps -MT CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdebug-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-4IFHEx -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -x c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCCompilerABI.c] + ignore line: [clang -cc1 version 15.0.0 (clang-1500.1.0.2.5) default target arm64-apple-darwin23.2.0] + ignore line: [ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include"] + ignore line: [ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/Library/Frameworks"] + ignore line: [#include "..." search starts here:] + ignore line: [#include <...> search starts here:] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks (framework directory)] + ignore line: [End of search list.] + ignore line: [[2/2] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl -search_paths_first -Wl -headerpad_max_install_names -v -Wl -v CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -o cmTC_1fb50 && :] + ignore line: [Apple clang version 15.0.0 (clang-1500.1.0.2.5)] + ignore line: [Target: arm64-apple-darwin23.2.0] + ignore line: [Thread model: posix] + ignore line: [InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin] + link line: [ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 14.0.0 14.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -o cmTC_1fb50 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld] ==> ignore + arg [-demangle] ==> ignore + arg [-lto_library] ==> ignore, skip following value + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib] ==> skip value of -lto_library + arg [-dynamic] ==> ignore + arg [-arch] ==> ignore + arg [arm64] ==> ignore + arg [-platform_version] ==> ignore + arg [macos] ==> ignore + arg [14.0.0] ==> ignore + arg [14.2] ==> ignore + arg [-syslibroot] ==> ignore + arg [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk] ==> ignore + arg [-o] ==> ignore + arg [cmTC_1fb50] ==> ignore + arg [-search_paths_first] ==> ignore + arg [-headerpad_max_install_names] ==> ignore + arg [-v] ==> ignore + arg [CMakeFiles/cmTC_1fb50.dir/CMakeCCompilerABI.c.o] ==> ignore + arg [-lSystem] ==> lib [System] + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + remove lib [System] + remove lib [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + implicit libs: [] + implicit objs: [] + implicit dirs: [] + implicit fwks: [] + + + - + kind: "try_compile-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + checks: + - "Detecting CXX compiler ABI info" + directories: + source: "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4" + binary: "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4" + cmakeVariables: + CMAKE_CXX_FLAGS: "" + CMAKE_OSX_ARCHITECTURES: "" + CMAKE_OSX_DEPLOYMENT_TARGET: "" + CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk" + buildResult: + variable: "CMAKE_CXX_ABI_COMPILED" + cached: true + stdout: | + Change Dir: '/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4' + + Run Build Command(s): /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -v cmTC_647fe + [1/2] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics -v -Wl,-v -MD -MT CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -MF CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o.d -o CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCXXCompilerABI.cpp + Apple clang version 15.0.0 (clang-1500.1.0.2.5) + Target: arm64-apple-darwin23.2.0 + Thread model: posix + InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + clang: warning: -Wl,-v: 'linker' input unused [-Wunused-command-line-argument] + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fobjc-msgsend-selector-stubs -target-sdk-version=14.2 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0 -dependency-file CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o.d -skip-unused-modulemap-deps -MT CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdeprecated-macro -fdebug-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4 -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -x c++ /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCXXCompilerABI.cpp + clang -cc1 version 15.0.0 (clang-1500.1.0.2.5) default target arm64-apple-darwin23.2.0 + ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include" + ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/Library/Frameworks" + #include "..." search starts here: + #include <...> search starts here: + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1 + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks (framework directory) + End of search list. + [2/2] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_647fe && : + Apple clang version 15.0.0 (clang-1500.1.0.2.5) + Target: arm64-apple-darwin23.2.0 + Thread model: posix + InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 14.0.0 14.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -o cmTC_647fe -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a + @(#)PROGRAM:ld PROJECT:dyld-1022.1 + BUILD 05:27:37 Dec 7 2023 + configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h + will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em + LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) + TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.8) + Library search paths: + Framework search paths: + + exitCode: 0 + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:127 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + message: | + Parsed CXX implicit include dir info: rv=done + found start of include info + found start of implicit include info + add: [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1] + add: [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + add: [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + add: [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + end of search list found + collapse include dir [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1] ==> [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1] + collapse include dir [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] ==> [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + collapse include dir [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] ==> [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + collapse include dir [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] ==> [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + implicit include dirs: [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + + + - + kind: "message-v1" + backtrace: + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:152 (message)" + - "/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt" + message: | + Parsed CXX implicit link information: + link line regex: [^( *|.*[/\\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\\]+-)?ld|collect2)[^/\\]*( |$)] + ignore line: [Change Dir: '/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4'] + ignore line: [] + ignore line: [Run Build Command(s): /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -v cmTC_647fe] + ignore line: [[1/2] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics -v -Wl -v -MD -MT CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -MF CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o.d -o CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -c /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCXXCompilerABI.cpp] + ignore line: [Apple clang version 15.0.0 (clang-1500.1.0.2.5)] + ignore line: [Target: arm64-apple-darwin23.2.0] + ignore line: [Thread model: posix] + ignore line: [InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin] + ignore line: [clang: warning: -Wl -v: 'linker' input unused [-Wunused-command-line-argument]] + ignore line: [ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fobjc-msgsend-selector-stubs -target-sdk-version=14.2 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0 -dependency-file CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o.d -skip-unused-modulemap-deps -MT CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdeprecated-macro -fdebug-compilation-dir=/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-Og5hD4 -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -x c++ /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCXXCompilerABI.cpp] + ignore line: [clang -cc1 version 15.0.0 (clang-1500.1.0.2.5) default target arm64-apple-darwin23.2.0] + ignore line: [ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include"] + ignore line: [ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/Library/Frameworks"] + ignore line: [#include "..." search starts here:] + ignore line: [#include <...> search starts here:] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include] + ignore line: [ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks (framework directory)] + ignore line: [End of search list.] + ignore line: [[2/2] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl -search_paths_first -Wl -headerpad_max_install_names -v -Wl -v CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_647fe && :] + ignore line: [Apple clang version 15.0.0 (clang-1500.1.0.2.5)] + ignore line: [Target: arm64-apple-darwin23.2.0] + ignore line: [Thread model: posix] + ignore line: [InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin] + link line: [ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 14.0.0 14.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -o cmTC_647fe -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld] ==> ignore + arg [-demangle] ==> ignore + arg [-lto_library] ==> ignore, skip following value + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib] ==> skip value of -lto_library + arg [-dynamic] ==> ignore + arg [-arch] ==> ignore + arg [arm64] ==> ignore + arg [-platform_version] ==> ignore + arg [macos] ==> ignore + arg [14.0.0] ==> ignore + arg [14.2] ==> ignore + arg [-syslibroot] ==> ignore + arg [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk] ==> ignore + arg [-o] ==> ignore + arg [cmTC_647fe] ==> ignore + arg [-search_paths_first] ==> ignore + arg [-headerpad_max_install_names] ==> ignore + arg [-v] ==> ignore + arg [CMakeFiles/cmTC_647fe.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore + arg [-lc++] ==> lib [c++] + arg [-lSystem] ==> lib [System] + arg [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + remove lib [System] + remove lib [/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a] + implicit libs: [c++] + implicit objs: [] + implicit dirs: [] + implicit fwks: [] + + +... diff --git a/cmake-build-debug/CMakeFiles/TargetDirectories.txt b/cmake-build-debug/CMakeFiles/TargetDirectories.txt new file mode 100644 index 0000000..6b1e665 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/TargetDirectories.txt @@ -0,0 +1,3 @@ +/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/roaring_fast_or.dir +/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/edit_cache.dir +/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/CMakeFiles/rebuild_cache.dir diff --git a/cmake-build-debug/CMakeFiles/clion-Debug-log.txt b/cmake-build-debug/CMakeFiles/clion-Debug-log.txt new file mode 100644 index 0000000..649f905 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/clion-Debug-log.txt @@ -0,0 +1,12 @@ +/Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -G Ninja -S /Users/zach/Development/tmp/croaring-msvc -B /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug +CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): + Compatibility with CMake < 3.5 will be removed from a future version of + CMake. + + Update the VERSION argument value or use a ... suffix to tell + CMake that the project does not need compatibility with older versions. + + +-- Configuring done (0.0s) +-- Generating done (0.0s) +-- Build files have been written to: /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug diff --git a/cmake-build-debug/CMakeFiles/clion-environment.txt b/cmake-build-debug/CMakeFiles/clion-environment.txt new file mode 100644 index 0000000..2a77dfd --- /dev/null +++ b/cmake-build-debug/CMakeFiles/clion-environment.txt @@ -0,0 +1,3 @@ +ToolSet: 1.0 (local)Options: + +Options:-DCMAKE_MAKE_PROGRAM=/Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja \ No newline at end of file diff --git a/cmake-build-debug/CMakeFiles/cmake.check_cache b/cmake-build-debug/CMakeFiles/cmake.check_cache new file mode 100644 index 0000000..3dccd73 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/cmake.check_cache @@ -0,0 +1 @@ +# This file is generated by cmake for dependency checking of the CMakeCache.txt file diff --git a/cmake-build-debug/CMakeFiles/rules.ninja b/cmake-build-debug/CMakeFiles/rules.ninja new file mode 100644 index 0000000..36817c7 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/rules.ninja @@ -0,0 +1,64 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Ninja" Generator, CMake Version 3.27 + +# This file contains all the rules used to get the outputs files +# built from the input files. +# It is included in the main 'build.ninja'. + +# ============================================================================= +# Project: roaring_fast_or +# Configurations: Debug +# ============================================================================= +# ============================================================================= + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__roaring_fast_or_unscanned_Debug + depfile = $DEP_FILE + deps = gcc + command = ${LAUNCHER}${CODE_CHECK}/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C executable. + +rule C_EXECUTABLE_LINKER__roaring_fast_or_Debug + command = $PRE_LINK && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc $FLAGS -Wl,-search_paths_first -Wl,-headerpad_max_install_names $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C executable $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for running custom commands. + +rule CUSTOM_COMMAND + command = $COMMAND + description = $DESC + + +############################################# +# Rule for re-running cmake. + +rule RERUN_CMAKE + command = /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --regenerate-during-build -S/Users/zach/Development/tmp/croaring-msvc -B/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug + description = Re-running CMake... + generator = 1 + + +############################################# +# Rule for cleaning all built files. + +rule CLEAN + command = /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja $FILE_ARG -t clean $TARGETS + description = Cleaning all built files... + + +############################################# +# Rule for printing all primary targets available. + +rule HELP + command = /Users/zach/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -t targets + description = All primary targets available: + diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log new file mode 100644 index 0000000..9017a5a --- /dev/null +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -0,0 +1,3 @@ +Start testing: Jan 28 22:57 EST +---------------------------------------------------------- +End testing: Jan 28 22:57 EST diff --git a/cmake-build-debug/build.ninja b/cmake-build-debug/build.ninja new file mode 100644 index 0000000..a67342c --- /dev/null +++ b/cmake-build-debug/build.ninja @@ -0,0 +1,147 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Ninja" Generator, CMake Version 3.27 + +# This file contains all the build statements describing the +# compilation DAG. + +# ============================================================================= +# Write statements declared in CMakeLists.txt: +# +# Which is the root file. +# ============================================================================= + +# ============================================================================= +# Project: roaring_fast_or +# Configurations: Debug +# ============================================================================= + +############################################# +# Minimal version of Ninja required by this file + +ninja_required_version = 1.5 + + +############################################# +# Set configuration variable for custom commands. + +CONFIGURATION = Debug +# ============================================================================= +# Include auxiliary files. + + +############################################# +# Include rules file. + +include CMakeFiles/rules.ninja + +# ============================================================================= + +############################################# +# Logical path to working directory; prefix for absolute paths. + +cmake_ninja_workdir = /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/ +# ============================================================================= +# Object build statements for EXECUTABLE target roaring_fast_or + + +############################################# +# Order-only phony target for roaring_fast_or + +build cmake_object_order_depends_target_roaring_fast_or: phony || CMakeFiles/roaring_fast_or.dir + +build CMakeFiles/roaring_fast_or.dir/roaring_fast_or.c.o: C_COMPILER__roaring_fast_or_unscanned_Debug /Users/zach/Development/tmp/croaring-msvc/roaring_fast_or.c || cmake_object_order_depends_target_roaring_fast_or + DEP_FILE = CMakeFiles/roaring_fast_or.dir/roaring_fast_or.c.o.d + FLAGS = -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fcolor-diagnostics + OBJECT_DIR = CMakeFiles/roaring_fast_or.dir + OBJECT_FILE_DIR = CMakeFiles/roaring_fast_or.dir + + +# ============================================================================= +# Link build statements for EXECUTABLE target roaring_fast_or + + +############################################# +# Link the executable roaring_fast_or + +build roaring_fast_or: C_EXECUTABLE_LINKER__roaring_fast_or_Debug CMakeFiles/roaring_fast_or.dir/roaring_fast_or.c.o + FLAGS = -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk + OBJECT_DIR = CMakeFiles/roaring_fast_or.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = roaring_fast_or + TARGET_PDB = roaring_fast_or.dbg + + +############################################# +# Utility command for edit_cache + +build CMakeFiles/edit_cache.util: CUSTOM_COMMAND + COMMAND = cd /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug && /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. + DESC = No interactive CMake dialog available... + restat = 1 + +build edit_cache: phony CMakeFiles/edit_cache.util + + +############################################# +# Utility command for rebuild_cache + +build CMakeFiles/rebuild_cache.util: CUSTOM_COMMAND + COMMAND = cd /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug && /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --regenerate-during-build -S/Users/zach/Development/tmp/croaring-msvc -B/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug + DESC = Running CMake to regenerate build system... + pool = console + restat = 1 + +build rebuild_cache: phony CMakeFiles/rebuild_cache.util + +# ============================================================================= +# Target aliases. + +# ============================================================================= +# Folder targets. + +# ============================================================================= + +############################################# +# Folder: /Users/zach/Development/tmp/croaring-msvc/cmake-build-debug + +build all: phony roaring_fast_or + +# ============================================================================= +# Unknown Build Time Dependencies. +# Tell Ninja that they may appear as side effects of build rules +# otherwise ordered by order-only dependencies. + +# ============================================================================= +# Built-in targets + + +############################################# +# Re-run CMake if any of its inputs changed. + +build build.ninja: RERUN_CMAKE | /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCommonLanguageInclude.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeGenericSystem.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeInitializeConfigs.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeLanguageInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInitialize.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/AppleClang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/CMakeCommonCompilerMacros.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/Clang.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-AppleClang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin-Initialize.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/UnixPaths.cmake /Users/zach/Development/tmp/croaring-msvc/CMakeLists.txt CMakeCache.txt CMakeFiles/3.27.8/CMakeCCompiler.cmake CMakeFiles/3.27.8/CMakeSystem.cmake + pool = console + + +############################################# +# A missing CMake input file is not an error. + +build /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCommonLanguageInclude.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeGenericSystem.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeInitializeConfigs.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeLanguageInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInformation.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInitialize.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/AppleClang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/CMakeCommonCompilerMacros.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/Clang.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-AppleClang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang-C.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Apple-Clang.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin-Initialize.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Darwin.cmake /Users/zach/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/UnixPaths.cmake /Users/zach/Development/tmp/croaring-msvc/CMakeLists.txt CMakeCache.txt CMakeFiles/3.27.8/CMakeCCompiler.cmake CMakeFiles/3.27.8/CMakeSystem.cmake: phony + + +############################################# +# Clean all the built files. + +build clean: CLEAN + + +############################################# +# Print all primary targets available. + +build help: HELP + + +############################################# +# Make the all target the default. + +default all diff --git a/cmake-build-debug/cmake_install.cmake b/cmake-build-debug/cmake_install.cmake new file mode 100644 index 0000000..448ea67 --- /dev/null +++ b/cmake-build-debug/cmake_install.cmake @@ -0,0 +1,49 @@ +# Install script for directory: /Users/zach/Development/tmp/croaring-msvc + +# Set the install prefix +if(NOT DEFINED CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "/usr/local") +endif() +string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + if(BUILD_TYPE) + string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + else() + set(CMAKE_INSTALL_CONFIG_NAME "Debug") + endif() + message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +endif() + +# Set the component getting installed. +if(NOT CMAKE_INSTALL_COMPONENT) + if(COMPONENT) + message(STATUS "Install component: \"${COMPONENT}\"") + set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + else() + set(CMAKE_INSTALL_COMPONENT) + endif() +endif() + +# Is this installation the result of a crosscompile? +if(NOT DEFINED CMAKE_CROSSCOMPILING) + set(CMAKE_CROSSCOMPILING "FALSE") +endif() + +# Set default install directory permissions. +if(NOT DEFINED CMAKE_OBJDUMP) + set(CMAKE_OBJDUMP "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump") +endif() + +if(CMAKE_INSTALL_COMPONENT) + set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") +else() + set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") +endif() + +string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT + "${CMAKE_INSTALL_MANIFEST_FILES}") +file(WRITE "/Users/zach/Development/tmp/croaring-msvc/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" + "${CMAKE_INSTALL_MANIFEST_CONTENT}") diff --git a/croaring-sys/CRoaring/bindgen_bundled_version.rs b/croaring-sys/CRoaring/bindgen_bundled_version.rs deleted file mode 100644 index ac27fe0..0000000 --- a/croaring-sys/CRoaring/bindgen_bundled_version.rs +++ /dev/null @@ -1,782 +0,0 @@ -/* automatically generated by rust-bindgen 0.68.1 */ - -pub const ROARING_VERSION: &[u8; 6] = b"2.0.2\0"; -pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 2; -pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 0; -pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 2; -pub type _bindgen_ty_1 = ::std::os::raw::c_uint; -#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_array_s { - pub size: i32, - pub allocation_size: i32, - pub containers: *mut *mut ::std::os::raw::c_void, - pub keys: *mut u16, - pub typecodes: *mut u8, - pub flags: u8, -} -#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."] -pub type roaring_array_t = roaring_array_s; -pub type roaring_iterator = ::std::option::Option< - unsafe extern "C" fn(value: u32, param: *mut ::std::os::raw::c_void) -> bool, ->; -pub type roaring_iterator64 = ::std::option::Option< - unsafe extern "C" fn(value: u64, param: *mut ::std::os::raw::c_void) -> bool, ->; -#[doc = " (For advanced users.)\n The roaring_statistics_t can be used to collect detailed statistics about\n the composition of a roaring bitmap."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_statistics_s { - pub n_containers: u32, - pub n_array_containers: u32, - pub n_run_containers: u32, - pub n_bitset_containers: u32, - pub n_values_array_containers: u32, - pub n_values_run_containers: u32, - pub n_values_bitset_containers: u32, - pub n_bytes_array_containers: u32, - pub n_bytes_run_containers: u32, - pub n_bytes_bitset_containers: u32, - pub max_value: u32, - pub min_value: u32, - pub sum_value: u64, - pub cardinality: u64, -} -#[doc = " (For advanced users.)\n The roaring_statistics_t can be used to collect detailed statistics about\n the composition of a roaring bitmap."] -pub type roaring_statistics_t = roaring_statistics_s; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct bitset_s { - pub array: *mut u64, - pub arraysize: usize, - pub capacity: usize, -} -pub type bitset_t = bitset_s; -extern "C" { - pub fn bitset_create() -> *mut bitset_t; -} -extern "C" { - pub fn bitset_create_with_capacity(size: usize) -> *mut bitset_t; -} -extern "C" { - pub fn bitset_free(bitset: *mut bitset_t); -} -extern "C" { - pub fn bitset_clear(bitset: *mut bitset_t); -} -extern "C" { - pub fn bitset_fill(bitset: *mut bitset_t); -} -extern "C" { - pub fn bitset_copy(bitset: *const bitset_t) -> *mut bitset_t; -} -extern "C" { - pub fn bitset_resize(bitset: *mut bitset_t, newarraysize: usize, padwithzeroes: bool) -> bool; -} -extern "C" { - pub fn bitset_size_in_bytes(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_size_in_bits(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_size_in_words(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_grow(bitset: *mut bitset_t, newarraysize: usize) -> bool; -} -extern "C" { - pub fn bitset_trim(bitset: *mut bitset_t) -> bool; -} -extern "C" { - pub fn bitset_shift_left(bitset: *mut bitset_t, s: usize); -} -extern "C" { - pub fn bitset_shift_right(bitset: *mut bitset_t, s: usize); -} -extern "C" { - pub fn bitset_set(bitset: *mut bitset_t, i: usize); -} -extern "C" { - pub fn bitset_set_to_value(bitset: *mut bitset_t, i: usize, flag: bool); -} -extern "C" { - pub fn bitset_get(bitset: *const bitset_t, i: usize) -> bool; -} -extern "C" { - pub fn bitset_count(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_minimum(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_maximum(bitset: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_inplace_union(b1: *mut bitset_t, b2: *const bitset_t) -> bool; -} -extern "C" { - pub fn bitset_union_count(b1: *const bitset_t, b2: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_inplace_intersection(b1: *mut bitset_t, b2: *const bitset_t); -} -extern "C" { - pub fn bitset_intersection_count(b1: *const bitset_t, b2: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitsets_disjoint(b1: *const bitset_t, b2: *const bitset_t) -> bool; -} -extern "C" { - pub fn bitsets_intersect(b1: *const bitset_t, b2: *const bitset_t) -> bool; -} -extern "C" { - pub fn bitset_contains_all(b1: *const bitset_t, b2: *const bitset_t) -> bool; -} -extern "C" { - pub fn bitset_inplace_difference(b1: *mut bitset_t, b2: *const bitset_t); -} -extern "C" { - pub fn bitset_difference_count(b1: *const bitset_t, b2: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_inplace_symmetric_difference(b1: *mut bitset_t, b2: *const bitset_t) -> bool; -} -extern "C" { - pub fn bitset_symmetric_difference_count(b1: *const bitset_t, b2: *const bitset_t) -> usize; -} -extern "C" { - pub fn bitset_next_set_bit(bitset: *const bitset_t, i: *mut usize) -> bool; -} -extern "C" { - pub fn bitset_next_set_bits( - bitset: *const bitset_t, - buffer: *mut usize, - capacity: usize, - startfrom: *mut usize, - ) -> usize; -} -pub type bitset_iterator = ::std::option::Option< - unsafe extern "C" fn(value: usize, param: *mut ::std::os::raw::c_void) -> bool, ->; -extern "C" { - pub fn bitset_for_each( - b: *const bitset_t, - iterator: bitset_iterator, - ptr: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - pub fn bitset_print(b: *const bitset_t); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_bitmap_s { - pub high_low_container: roaring_array_t, -} -pub type roaring_bitmap_t = roaring_bitmap_s; -extern "C" { - #[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Client is responsible for calling `roaring_bitmap_free()`."] - pub fn roaring_bitmap_create_with_capacity(cap: u32) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Client is responsible for calling `roaring_bitmap_free()`."] - pub fn roaring_bitmap_create() -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Can return false if auxiliary allocations fail when capacity greater than 0."] - pub fn roaring_bitmap_init_with_capacity(r: *mut roaring_bitmap_t, cap: u32) -> bool; -} -extern "C" { - #[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n The bitmap will be in a \"clear\" state, with no auxiliary allocations.\n Since this performs no allocations, the function will not fail."] - pub fn roaring_bitmap_init_cleared(r: *mut roaring_bitmap_t); -} -extern "C" { - #[doc = " Add all the values between min (included) and max (excluded) that are at a\n distance k*step from min."] - pub fn roaring_bitmap_from_range(min: u64, max: u64, step: u32) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Creates a new bitmap from a pointer of uint32_t integers"] - pub fn roaring_bitmap_of_ptr(n_args: usize, vals: *const u32) -> *mut roaring_bitmap_t; -} -extern "C" { - pub fn roaring_bitmap_get_copy_on_write(r: *const roaring_bitmap_t) -> bool; -} -extern "C" { - pub fn roaring_bitmap_set_copy_on_write(r: *mut roaring_bitmap_t, cow: bool); -} -extern "C" { - pub fn roaring_bitmap_add_offset( - bm: *const roaring_bitmap_t, - offset: i64, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Describe the inner structure of the bitmap."] - pub fn roaring_bitmap_printf_describe(r: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Creates a new bitmap from a list of uint32_t integers"] - pub fn roaring_bitmap_of(n: usize, ...) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Copies a bitmap (this does memory allocation).\n The caller is responsible for memory management."] - pub fn roaring_bitmap_copy(r: *const roaring_bitmap_t) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Copies a bitmap from src to dest. It is assumed that the pointer dest\n is to an already allocated bitmap. The content of the dest bitmap is\n freed/deleted.\n\n It might be preferable and simpler to call roaring_bitmap_copy except\n that roaring_bitmap_overwrite can save on memory allocations.\n\n Returns true if successful, or false if there was an error. On failure,\n the dest bitmap is left in a valid, empty state (even if it was not empty before)."] - pub fn roaring_bitmap_overwrite( - dest: *mut roaring_bitmap_t, - src: *const roaring_bitmap_t, - ) -> bool; -} -extern "C" { - #[doc = " Print the content of the bitmap."] - pub fn roaring_bitmap_printf(r: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Computes the intersection between two bitmaps and returns new bitmap. The\n caller is responsible for memory management.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmap.\n You may also rely on roaring_bitmap_and_inplace to avoid creating\n many temporary bitmaps."] - pub fn roaring_bitmap_and( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Computes the size of the intersection between two bitmaps."] - pub fn roaring_bitmap_and_cardinality( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> u64; -} -extern "C" { - #[doc = " Check whether two bitmaps intersect."] - pub fn roaring_bitmap_intersect( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> bool; -} -extern "C" { - #[doc = " Check whether a bitmap and a closed range intersect."] - pub fn roaring_bitmap_intersect_with_range(bm: *const roaring_bitmap_t, x: u64, y: u64) - -> bool; -} -extern "C" { - #[doc = " Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto\n distance, or the Jaccard similarity coefficient)\n\n The Jaccard index is undefined if both bitmaps are empty."] - pub fn roaring_bitmap_jaccard_index( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> f64; -} -extern "C" { - #[doc = " Computes the size of the union between two bitmaps."] - pub fn roaring_bitmap_or_cardinality( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> u64; -} -extern "C" { - #[doc = " Computes the size of the difference (andnot) between two bitmaps."] - pub fn roaring_bitmap_andnot_cardinality( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> u64; -} -extern "C" { - #[doc = " Computes the size of the symmetric difference (xor) between two bitmaps."] - pub fn roaring_bitmap_xor_cardinality( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> u64; -} -extern "C" { - #[doc = " Inplace version of `roaring_bitmap_and()`, modifies r1\n r1 == r2 is allowed.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmap."] - pub fn roaring_bitmap_and_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Computes the union between two bitmaps and returns new bitmap. The caller is\n responsible for memory management."] - pub fn roaring_bitmap_or( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Inplace version of `roaring_bitmap_or(), modifies r1.\n TODO: decide whether r1 == r2 ok"] - pub fn roaring_bitmap_or_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Compute the union of 'number' bitmaps.\n Caller is responsible for freeing the result.\n See also `roaring_bitmap_or_many_heap()`"] - pub fn roaring_bitmap_or_many( - number: usize, - rs: *mut *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Compute the union of 'number' bitmaps using a heap. This can sometimes be\n faster than `roaring_bitmap_or_many() which uses a naive algorithm.\n Caller is responsible for freeing the result."] - pub fn roaring_bitmap_or_many_heap( - number: u32, - rs: *mut *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Computes the symmetric difference (xor) between two bitmaps\n and returns new bitmap. The caller is responsible for memory management."] - pub fn roaring_bitmap_xor( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Inplace version of roaring_bitmap_xor, modifies r1, r1 != r2."] - pub fn roaring_bitmap_xor_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Compute the xor of 'number' bitmaps.\n Caller is responsible for freeing the result."] - pub fn roaring_bitmap_xor_many( - number: usize, - rs: *mut *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Computes the difference (andnot) between two bitmaps and returns new bitmap.\n Caller is responsible for freeing the result."] - pub fn roaring_bitmap_andnot( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Inplace version of roaring_bitmap_andnot, modifies r1, r1 != r2."] - pub fn roaring_bitmap_andnot_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Frees the memory."] - pub fn roaring_bitmap_free(r: *const roaring_bitmap_t); -} -#[doc = " A bit of context usable with `roaring_bitmap_*_bulk()` functions\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap\n (unless re-initialized to zero), and any modification to a bitmap\n (other than modifications performed with `_bulk()` functions with the context\n passed) will invalidate any contexts associated with that bitmap."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_bulk_context_s { - pub container: *mut ::std::os::raw::c_void, - pub idx: ::std::os::raw::c_int, - pub key: u16, - pub typecode: u8, -} -#[doc = " A bit of context usable with `roaring_bitmap_*_bulk()` functions\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap\n (unless re-initialized to zero), and any modification to a bitmap\n (other than modifications performed with `_bulk()` functions with the context\n passed) will invalidate any contexts associated with that bitmap."] -pub type roaring_bulk_context_t = roaring_bulk_context_s; -extern "C" { - #[doc = " Add an item, using context from a previous insert for speed optimization.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same \"key\" (high 16 bits of the value) consecutively."] - pub fn roaring_bitmap_add_bulk( - r: *mut roaring_bitmap_t, - context: *mut roaring_bulk_context_t, - val: u32, - ); -} -extern "C" { - #[doc = " Add value n_args from pointer vals, faster than repeatedly calling\n `roaring_bitmap_add()`\n\n In order to exploit this optimization, the caller should attempt to keep\n values with the same \"key\" (high 16 bits of the value) as consecutive\n elements in `vals`"] - pub fn roaring_bitmap_add_many(r: *mut roaring_bitmap_t, n_args: usize, vals: *const u32); -} -extern "C" { - #[doc = " Add value x"] - pub fn roaring_bitmap_add(r: *mut roaring_bitmap_t, x: u32); -} -extern "C" { - #[doc = " Add value x\n Returns true if a new value was added, false if the value already existed."] - pub fn roaring_bitmap_add_checked(r: *mut roaring_bitmap_t, x: u32) -> bool; -} -extern "C" { - #[doc = " Add all values in range [min, max]"] - pub fn roaring_bitmap_add_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32); -} -extern "C" { - #[doc = " Add all values in range [min, max)"] - pub fn roaring_bitmap_add_range(r: *mut roaring_bitmap_t, min: u64, max: u64); -} -extern "C" { - #[doc = " Remove value x"] - pub fn roaring_bitmap_remove(r: *mut roaring_bitmap_t, x: u32); -} -extern "C" { - #[doc = " Remove all values in range [min, max]"] - pub fn roaring_bitmap_remove_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32); -} -extern "C" { - #[doc = " Remove all values in range [min, max)"] - pub fn roaring_bitmap_remove_range(r: *mut roaring_bitmap_t, min: u64, max: u64); -} -extern "C" { - #[doc = " Remove multiple values"] - pub fn roaring_bitmap_remove_many(r: *mut roaring_bitmap_t, n_args: usize, vals: *const u32); -} -extern "C" { - #[doc = " Remove value x\n Returns true if a new value was removed, false if the value was not existing."] - pub fn roaring_bitmap_remove_checked(r: *mut roaring_bitmap_t, x: u32) -> bool; -} -extern "C" { - #[doc = " Check if value is present"] - pub fn roaring_bitmap_contains(r: *const roaring_bitmap_t, val: u32) -> bool; -} -extern "C" { - #[doc = " Check whether a range of values from range_start (included)\n to range_end (excluded) is present"] - pub fn roaring_bitmap_contains_range( - r: *const roaring_bitmap_t, - range_start: u64, - range_end: u64, - ) -> bool; -} -extern "C" { - #[doc = " Check if an items is present, using context from a previous insert or search\n for speed optimization.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same \"key\" (high 16 bits of the value) consecutively."] - pub fn roaring_bitmap_contains_bulk( - r: *const roaring_bitmap_t, - context: *mut roaring_bulk_context_t, - val: u32, - ) -> bool; -} -extern "C" { - #[doc = " Get the cardinality of the bitmap (number of elements)."] - pub fn roaring_bitmap_get_cardinality(r: *const roaring_bitmap_t) -> u64; -} -extern "C" { - #[doc = " Returns the number of elements in the range [range_start, range_end)."] - pub fn roaring_bitmap_range_cardinality( - r: *const roaring_bitmap_t, - range_start: u64, - range_end: u64, - ) -> u64; -} -extern "C" { - #[doc = " Returns true if the bitmap is empty (cardinality is zero)."] - pub fn roaring_bitmap_is_empty(r: *const roaring_bitmap_t) -> bool; -} -extern "C" { - #[doc = " Empties the bitmap. It will have no auxiliary allocations (so if the bitmap\n was initialized in client memory via roaring_bitmap_init(), then a call to\n roaring_bitmap_clear() would be enough to \"free\" it)"] - pub fn roaring_bitmap_clear(r: *mut roaring_bitmap_t); -} -extern "C" { - #[doc = " Convert the bitmap to a sorted array, output in `ans`.\n\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n\n ans = malloc(roaring_bitmap_get_cardinality(bitmap) * sizeof(uint32_t));"] - pub fn roaring_bitmap_to_uint32_array(r: *const roaring_bitmap_t, ans: *mut u32); -} -extern "C" { - #[doc = " Store the bitmap to a bitset. This can be useful for people\n who need the performance and simplicity of a standard bitset.\n We assume that the input bitset is originally empty (does not\n have any set bit).\n\n bitset_t * out = bitset_create();\n // if the bitset has content in it, call \"bitset_clear(out)\"\n bool success = roaring_bitmap_to_bitset(mybitmap, out);\n // on failure, success will be false.\n // You can then query the bitset:\n bool is_present = bitset_get(out, 10011 );\n // you must free the memory:\n bitset_free(out);\n"] - pub fn roaring_bitmap_to_bitset(r: *const roaring_bitmap_t, bitset: *mut bitset_t) -> bool; -} -extern "C" { - #[doc = " Convert the bitmap to a sorted array from `offset` by `limit`, output in `ans`.\n\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n\n ans = malloc(roaring_bitmap_get_cardinality(limit) * sizeof(uint32_t));\n\n Return false in case of failure (e.g., insufficient memory)"] - pub fn roaring_bitmap_range_uint32_array( - r: *const roaring_bitmap_t, - offset: usize, - limit: usize, - ans: *mut u32, - ) -> bool; -} -extern "C" { - #[doc = " Remove run-length encoding even when it is more space efficient.\n Return whether a change was applied."] - pub fn roaring_bitmap_remove_run_compression(r: *mut roaring_bitmap_t) -> bool; -} -extern "C" { - #[doc = " Convert array and bitmap containers to run containers when it is more\n efficient; also convert from run containers when more space efficient.\n\n Returns true if the result has at least one run container.\n Additional savings might be possible by calling `shrinkToFit()`."] - pub fn roaring_bitmap_run_optimize(r: *mut roaring_bitmap_t) -> bool; -} -extern "C" { - #[doc = " If needed, reallocate memory to shrink the memory usage.\n Returns the number of bytes saved."] - pub fn roaring_bitmap_shrink_to_fit(r: *mut roaring_bitmap_t) -> usize; -} -extern "C" { - #[doc = " Write the bitmap to an output pointer, this output buffer should refer to\n at least `roaring_bitmap_size_in_bytes(r)` allocated bytes.\n\n See `roaring_bitmap_portable_serialize()` if you want a format that's\n compatible with Java and Go implementations. This format can sometimes be\n more space efficient than the portable form, e.g. when the data is sparse.\n\n Returns how many bytes written, should be `roaring_bitmap_size_in_bytes(r)`.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_serialize( - r: *const roaring_bitmap_t, - buf: *mut ::std::os::raw::c_char, - ) -> usize; -} -extern "C" { - #[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_deserialize(buf: *const ::std::os::raw::c_void) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize_safe()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems.\n\n The difference with `roaring_bitmap_deserialize()` is that this function checks that the input buffer\n is a valid bitmap. If the buffer is too small, NULL is returned."] - pub fn roaring_bitmap_deserialize_safe( - buf: *const ::std::os::raw::c_void, - maxbytes: usize, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " How many bytes are required to serialize this bitmap (NOT compatible\n with Java and Go versions)"] - pub fn roaring_bitmap_size_in_bytes(r: *const roaring_bitmap_t) -> usize; -} -extern "C" { - #[doc = " Read bitmap from a serialized buffer.\n In case of failure, NULL is returned.\n\n This function is unsafe in the sense that if there is no valid serialized\n bitmap at the pointer, then many bytes could be read, possibly causing a\n buffer overflow. See also roaring_bitmap_portable_deserialize_safe().\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_portable_deserialize( - buf: *const ::std::os::raw::c_char, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Read bitmap from a serialized buffer safely (reading up to maxbytes).\n In case of failure, NULL is returned.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n The function itself is safe in the sense that it will not cause buffer overflows.\n However, for correct operations, it is assumed that the bitmap read was once\n serialized from a valid bitmap (i.e., it follows the format specification).\n If you provided an incorrect input (garbage), then the bitmap read may not be in\n a valid state and following operations may not lead to sensible results.\n In particular, the serialized array containers need to be in sorted order, and the\n run containers should be in sorted non-overlapping order. This is is guaranteed to\n happen when serializing an existing bitmap, but not for random inputs.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_portable_deserialize_safe( - buf: *const ::std::os::raw::c_char, - maxbytes: usize, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Read bitmap from a serialized buffer.\n In case of failure, NULL is returned.\n\n Bitmap returned by this function can be used in all readonly contexts.\n Bitmap must be freed as usual, by calling roaring_bitmap_free().\n Underlying buffer must not be freed or modified while it backs any bitmaps.\n\n The function is unsafe in the following ways:\n 1) It may execute unaligned memory accesses.\n 2) A buffer overflow may occur if buf does not point to a valid serialized\n bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_portable_deserialize_frozen( - buf: *const ::std::os::raw::c_char, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " Check how many bytes would be read (up to maxbytes) at this pointer if there\n is a bitmap, returns zero if there is no valid bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec"] - pub fn roaring_bitmap_portable_deserialize_size( - buf: *const ::std::os::raw::c_char, - maxbytes: usize, - ) -> usize; -} -extern "C" { - #[doc = " How many bytes are required to serialize this bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec"] - pub fn roaring_bitmap_portable_size_in_bytes(r: *const roaring_bitmap_t) -> usize; -} -extern "C" { - #[doc = " Write a bitmap to a char buffer. The output buffer should refer to at least\n `roaring_bitmap_portable_size_in_bytes(r)` bytes of allocated memory.\n\n Returns how many bytes were written which should match\n `roaring_bitmap_portable_size_in_bytes(r)`.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_portable_serialize( - r: *const roaring_bitmap_t, - buf: *mut ::std::os::raw::c_char, - ) -> usize; -} -extern "C" { - #[doc = " Returns number of bytes required to serialize bitmap using frozen format."] - pub fn roaring_bitmap_frozen_size_in_bytes(r: *const roaring_bitmap_t) -> usize; -} -extern "C" { - #[doc = " Serializes bitmap using frozen format.\n Buffer size must be at least roaring_bitmap_frozen_size_in_bytes().\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_frozen_serialize( - r: *const roaring_bitmap_t, - buf: *mut ::std::os::raw::c_char, - ); -} -extern "C" { - #[doc = " Creates constant bitmap that is a view of a given buffer.\n Buffer data should have been written by `roaring_bitmap_frozen_serialize()`\n Its beginning must also be aligned by 32 bytes.\n Length must be equal exactly to `roaring_bitmap_frozen_size_in_bytes()`.\n In case of failure, NULL is returned.\n\n Bitmap returned by this function can be used in all readonly contexts.\n Bitmap must be freed as usual, by calling roaring_bitmap_free().\n Underlying buffer must not be freed or modified while it backs any bitmaps.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."] - pub fn roaring_bitmap_frozen_view( - buf: *const ::std::os::raw::c_char, - length: usize, - ) -> *const roaring_bitmap_t; -} -extern "C" { - #[doc = " Iterate over the bitmap elements. The function iterator is called once for\n all the values with ptr (can be NULL) as the second parameter of each call.\n\n `roaring_iterator` is simply a pointer to a function that returns bool\n (true means that the iteration should continue while false means that it\n should stop), and takes (uint32_t,void*) as inputs.\n\n Returns true if the roaring_iterator returned true throughout (so that all\n data points were necessarily visited).\n\n Iteration is ordered: from the smallest to the largest elements."] - pub fn roaring_iterate( - r: *const roaring_bitmap_t, - iterator: roaring_iterator, - ptr: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - pub fn roaring_iterate64( - r: *const roaring_bitmap_t, - iterator: roaring_iterator64, - high_bits: u64, - ptr: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - #[doc = " Return true if the two bitmaps contain the same elements."] - pub fn roaring_bitmap_equals(r1: *const roaring_bitmap_t, r2: *const roaring_bitmap_t) -> bool; -} -extern "C" { - #[doc = " Return true if all the elements of r1 are also in r2."] - pub fn roaring_bitmap_is_subset( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> bool; -} -extern "C" { - #[doc = " Return true if all the elements of r1 are also in r2, and r2 is strictly\n greater than r1."] - pub fn roaring_bitmap_is_strict_subset( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> bool; -} -extern "C" { - #[doc = " (For expert users who seek high performance.)\n\n Computes the union between two bitmaps and returns new bitmap. The caller is\n responsible for memory management.\n\n The lazy version defers some computations such as the maintenance of the\n cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`\n after executing \"lazy\" computations.\n\n It is safe to repeatedly call roaring_bitmap_lazy_or_inplace on the result.\n\n `bitsetconversion` is a flag which determines whether container-container\n operations force a bitset conversion."] - pub fn roaring_bitmap_lazy_or( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - bitsetconversion: bool, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " (For expert users who seek high performance.)\n\n Inplace version of roaring_bitmap_lazy_or, modifies r1.\n\n `bitsetconversion` is a flag which determines whether container-container\n operations force a bitset conversion."] - pub fn roaring_bitmap_lazy_or_inplace( - r1: *mut roaring_bitmap_t, - r2: *const roaring_bitmap_t, - bitsetconversion: bool, - ); -} -extern "C" { - #[doc = " (For expert users who seek high performance.)\n\n Execute maintenance on a bitmap created from `roaring_bitmap_lazy_or()`\n or modified with `roaring_bitmap_lazy_or_inplace()`."] - pub fn roaring_bitmap_repair_after_lazy(r1: *mut roaring_bitmap_t); -} -extern "C" { - #[doc = " Computes the symmetric difference between two bitmaps and returns new bitmap.\n The caller is responsible for memory management.\n\n The lazy version defers some computations such as the maintenance of the\n cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`\n after executing \"lazy\" computations.\n\n It is safe to repeatedly call `roaring_bitmap_lazy_xor_inplace()` on\n the result."] - pub fn roaring_bitmap_lazy_xor( - r1: *const roaring_bitmap_t, - r2: *const roaring_bitmap_t, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " (For expert users who seek high performance.)\n\n Inplace version of roaring_bitmap_lazy_xor, modifies r1. r1 != r2"] - pub fn roaring_bitmap_lazy_xor_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t); -} -extern "C" { - #[doc = " Compute the negation of the bitmap in the interval [range_start, range_end).\n The number of negated values is range_end - range_start.\n Areas outside the range are passed through unchanged."] - pub fn roaring_bitmap_flip( - r1: *const roaring_bitmap_t, - range_start: u64, - range_end: u64, - ) -> *mut roaring_bitmap_t; -} -extern "C" { - #[doc = " compute (in place) the negation of the roaring bitmap within a specified\n interval: [range_start, range_end). The number of negated values is\n range_end - range_start.\n Areas outside the range are passed through unchanged."] - pub fn roaring_bitmap_flip_inplace(r1: *mut roaring_bitmap_t, range_start: u64, range_end: u64); -} -extern "C" { - #[doc = " Selects the element at index 'rank' where the smallest element is at index 0.\n If the size of the roaring bitmap is strictly greater than rank, then this\n function returns true and sets element to the element of given rank.\n Otherwise, it returns false."] - pub fn roaring_bitmap_select(r: *const roaring_bitmap_t, rank: u32, element: *mut u32) -> bool; -} -extern "C" { - #[doc = " roaring_bitmap_rank returns the number of integers that are smaller or equal\n to x. Thus if x is the first element, this function will return 1. If\n x is smaller than the smallest element, this function will return 0.\n\n The indexing convention differs between roaring_bitmap_select and\n roaring_bitmap_rank: roaring_bitmap_select refers to the smallest value\n as having index 0, whereas roaring_bitmap_rank returns 1 when ranking\n the smallest value."] - pub fn roaring_bitmap_rank(r: *const roaring_bitmap_t, x: u32) -> u64; -} -extern "C" { - #[doc = " Returns the index of x in the given roaring bitmap.\n If the roaring bitmap doesn't contain x , this function will return -1.\n The difference with rank function is that this function will return -1 when x\n is not the element of roaring bitmap, but the rank function will return a\n non-negative number."] - pub fn roaring_bitmap_get_index(r: *const roaring_bitmap_t, x: u32) -> i64; -} -extern "C" { - #[doc = " Returns the smallest value in the set, or UINT32_MAX if the set is empty."] - pub fn roaring_bitmap_minimum(r: *const roaring_bitmap_t) -> u32; -} -extern "C" { - #[doc = " Returns the greatest value in the set, or 0 if the set is empty."] - pub fn roaring_bitmap_maximum(r: *const roaring_bitmap_t) -> u32; -} -extern "C" { - #[doc = " (For advanced users.)\n\n Collect statistics about the bitmap, see roaring_types.h for\n a description of roaring_statistics_t"] - pub fn roaring_bitmap_statistics(r: *const roaring_bitmap_t, stat: *mut roaring_statistics_t); -} -extern "C" { - #[doc = " Perform internal consistency checks. Returns true if the bitmap is consistent.\n\n Note that some operations intentionally leave bitmaps in an inconsistent state temporarily,\n for example, `roaring_bitmap_lazy_*` functions, until `roaring_bitmap_repair_after_lazy` is called.\n\n If reason is non-null, it will be set to a string describing the first inconsistency found if any."] - pub fn roaring_bitmap_internal_validate( - r: *const roaring_bitmap_t, - reason: *mut *const ::std::os::raw::c_char, - ) -> bool; -} -#[doc = " What follows is code use to iterate through values in a roaring bitmap\n\nroaring_bitmap_t *r =...\nroaring_uint32_iterator_t i;\nroaring_create_iterator(r, &i);\nwhile(i.has_value) {\nprintf(\"value = %d\\n\", i.current_value);\nroaring_advance_uint32_iterator(&i);\n}\n\nObviously, if you modify the underlying bitmap, the iterator\nbecomes invalid. So don't."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_uint32_iterator_s { - pub parent: *const roaring_bitmap_t, - pub container_index: i32, - pub in_container_index: i32, - pub run_index: i32, - pub current_value: u32, - pub has_value: bool, - pub container: *const ::std::os::raw::c_void, - pub typecode: u8, - pub highbits: u32, -} -#[doc = " What follows is code use to iterate through values in a roaring bitmap\n\nroaring_bitmap_t *r =...\nroaring_uint32_iterator_t i;\nroaring_create_iterator(r, &i);\nwhile(i.has_value) {\nprintf(\"value = %d\\n\", i.current_value);\nroaring_advance_uint32_iterator(&i);\n}\n\nObviously, if you modify the underlying bitmap, the iterator\nbecomes invalid. So don't."] -pub type roaring_uint32_iterator_t = roaring_uint32_iterator_s; -extern "C" { - #[doc = " Initialize an iterator object that can be used to iterate through the\n values. If there is a value, then this iterator points to the first value\n and `it->has_value` is true. The value is in `it->current_value`."] - pub fn roaring_init_iterator(r: *const roaring_bitmap_t, newit: *mut roaring_uint32_iterator_t); -} -extern "C" { - #[doc = " Initialize an iterator object that can be used to iterate through the\n values. If there is a value, then this iterator points to the last value\n and `it->has_value` is true. The value is in `it->current_value`."] - pub fn roaring_init_iterator_last( - r: *const roaring_bitmap_t, - newit: *mut roaring_uint32_iterator_t, - ); -} -extern "C" { - #[doc = " Create an iterator object that can be used to iterate through the values.\n Caller is responsible for calling `roaring_free_iterator()`.\n\n The iterator is initialized (this function calls `roaring_init_iterator()`)\n If there is a value, then this iterator points to the first value and\n `it->has_value` is true. The value is in `it->current_value`."] - pub fn roaring_create_iterator(r: *const roaring_bitmap_t) -> *mut roaring_uint32_iterator_t; -} -extern "C" { - #[doc = " Advance the iterator. If there is a new value, then `it->has_value` is true.\n The new value is in `it->current_value`. Values are traversed in increasing\n orders. For convenience, returns `it->has_value`."] - pub fn roaring_advance_uint32_iterator(it: *mut roaring_uint32_iterator_t) -> bool; -} -extern "C" { - #[doc = " Decrement the iterator. If there's a new value, then `it->has_value` is true.\n The new value is in `it->current_value`. Values are traversed in decreasing\n order. For convenience, returns `it->has_value`."] - pub fn roaring_previous_uint32_iterator(it: *mut roaring_uint32_iterator_t) -> bool; -} -extern "C" { - #[doc = " Move the iterator to the first value >= `val`. If there is a such a value,\n then `it->has_value` is true. The new value is in `it->current_value`.\n For convenience, returns `it->has_value`."] - pub fn roaring_move_uint32_iterator_equalorlarger( - it: *mut roaring_uint32_iterator_t, - val: u32, - ) -> bool; -} -extern "C" { - #[doc = " Creates a copy of an iterator.\n Caller must free it."] - pub fn roaring_copy_uint32_iterator( - it: *const roaring_uint32_iterator_t, - ) -> *mut roaring_uint32_iterator_t; -} -extern "C" { - #[doc = " Free memory following `roaring_create_iterator()`"] - pub fn roaring_free_uint32_iterator(it: *mut roaring_uint32_iterator_t); -} -extern "C" { - pub fn roaring_read_uint32_iterator( - it: *mut roaring_uint32_iterator_t, - buf: *mut u32, - count: u32, - ) -> u32; -} -pub type roaring_malloc_p = - ::std::option::Option *mut ::std::os::raw::c_void>; -pub type roaring_realloc_p = ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: usize, - ) -> *mut ::std::os::raw::c_void, ->; -pub type roaring_calloc_p = ::std::option::Option< - unsafe extern "C" fn(arg1: usize, arg2: usize) -> *mut ::std::os::raw::c_void, ->; -pub type roaring_free_p = - ::std::option::Option; -pub type roaring_aligned_malloc_p = ::std::option::Option< - unsafe extern "C" fn(arg1: usize, arg2: usize) -> *mut ::std::os::raw::c_void, ->; -pub type roaring_aligned_free_p = - ::std::option::Option; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct roaring_memory_s { - pub malloc: roaring_malloc_p, - pub realloc: roaring_realloc_p, - pub calloc: roaring_calloc_p, - pub free: roaring_free_p, - pub aligned_malloc: roaring_aligned_malloc_p, - pub aligned_free: roaring_aligned_free_p, -} -pub type roaring_memory_t = roaring_memory_s; -extern "C" { - pub fn roaring_init_memory_hook(memory_hook: roaring_memory_t); -} -extern "C" { - pub fn roaring_malloc(arg1: usize) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn roaring_realloc( - arg1: *mut ::std::os::raw::c_void, - arg2: usize, - ) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn roaring_calloc(arg1: usize, arg2: usize) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn roaring_free(arg1: *mut ::std::os::raw::c_void); -} -extern "C" { - pub fn roaring_aligned_malloc(arg1: usize, arg2: usize) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn roaring_aligned_free(arg1: *mut ::std::os::raw::c_void); -} diff --git a/croaring-sys/CRoaring/roaring.hh b/croaring-sys/CRoaring/roaring.hh deleted file mode 100644 index afffef1..0000000 --- a/croaring-sys/CRoaring/roaring.hh +++ /dev/null @@ -1,2881 +0,0 @@ -// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2023-09-27T16:30:23Z - -/* - * The CRoaring project is under a dual license (Apache/MIT). - * Users of the library may choose one or the other license. - */ -/* - * Copyright 2016-2022 The CRoaring authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -/* - * MIT License - * - * Copyright 2016-2022 The CRoaring authors - * - * Permission is hereby granted, free of charge, to any - * person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the - * Software without restriction, including without - * limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software - * is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice - * shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF - * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED - * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT - * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR - * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * SPDX-License-Identifier: MIT - */ - -#define ROARING_API_NOT_IN_GLOBAL_NAMESPACE // see remarks in roaring.h -#include "roaring.h" -#undef ROARING_API_NOT_IN_GLOBAL_NAMESPACE -/* begin file cpp/roaring.hh */ -/* -A C++ header for Roaring Bitmaps. -*/ -#ifndef INCLUDE_ROARING_HH_ -#define INCLUDE_ROARING_HH_ - -#include - -#include -#include -#include -#include -#include - -#if !defined(ROARING_EXCEPTIONS) -// __cpp_exceptions is required by C++98 and we require C++11 or better. -#ifndef __cpp_exceptions -#error "__cpp_exceptions should be defined" -#endif -# if __cpp_exceptions -# define ROARING_EXCEPTIONS 1 -# else -# define ROARING_EXCEPTIONS 0 -# endif -#endif - -#ifndef ROARING_TERMINATE -# if ROARING_EXCEPTIONS -# define ROARING_TERMINATE(_s) throw std::runtime_error(_s) -# else -# define ROARING_TERMINATE(_s) std::terminate() -# endif -#endif - -#define ROARING_API_NOT_IN_GLOBAL_NAMESPACE // see remarks in roaring.h -#undef ROARING_API_NOT_IN_GLOBAL_NAMESPACE - - -namespace roaring { - -class RoaringSetBitForwardIterator; - -/** - * A bit of context usable with `*Bulk()` functions. - * - * A context may only be used with a single bitmap, and any modification to a bitmap - * (other than modifications performed with `Bulk()` functions with the context - * passed) will invalidate any contexts associated with that bitmap. - */ -class BulkContext { - public: - friend class Roaring; - using roaring_bitmap_bulk_context_t = api::roaring_bulk_context_t; - BulkContext() : context_{nullptr, 0, 0, 0} {} - - BulkContext(const BulkContext&) = delete; - BulkContext& operator=(const BulkContext&) = delete; - BulkContext(BulkContext&&) noexcept = default; - BulkContext& operator=(BulkContext&&) noexcept = default; - - private: - roaring_bitmap_bulk_context_t context_; -}; - -class Roaring { - typedef api::roaring_bitmap_t roaring_bitmap_t; // class-local name alias - -public: - /** - * Create an empty bitmap in the existing memory for the class. - * The bitmap will be in the "clear" state with no auxiliary allocations. - */ - Roaring() : roaring{} { - // The empty constructor roaring{} silences warnings from pedantic static analyzers. - api::roaring_bitmap_init_cleared(&roaring); - } - - /** - * Construct a bitmap from a list of 32-bit integer values. - */ - Roaring(size_t n, const uint32_t *data) : Roaring() { - api::roaring_bitmap_add_many(&roaring, n, data); - } - - /** - * Construct a bitmap from an initializer list. - */ - Roaring(std::initializer_list l) : Roaring() { - addMany(l.size(), l.begin()); - } - - /** - * Copy constructor. - * It may throw std::runtime_error if there is insufficient memory. - */ - Roaring(const Roaring &r) : Roaring() { - if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) { - ROARING_TERMINATE("failed roaring_bitmap_overwrite in constructor"); - } - api::roaring_bitmap_set_copy_on_write( - &roaring, - api::roaring_bitmap_get_copy_on_write(&r.roaring)); - } - - /** - * Move constructor. The moved-from object remains valid but empty, i.e. - * it behaves as though it was just freshly constructed. - */ - Roaring(Roaring &&r) noexcept : roaring(r.roaring) { - // - // !!! This clones the bits of the roaring structure to a new location - // and then overwrites the old bits...assuming that this will still - // work. There are scenarios where this could break; e.g. if some of - // those bits were pointers into the structure memory itself. If such - // things were possible, a roaring_bitmap_move() API would be needed. - // - api::roaring_bitmap_init_cleared(&r.roaring); - } - - /** - * Construct a roaring object by taking control of a malloc()'d C struct. - * - * Passing a NULL pointer is unsafe. - * The pointer to the C struct will be invalid after the call. - */ - explicit Roaring(roaring_bitmap_t *s) noexcept : roaring (*s) { - roaring_free(s); // deallocate the passed-in pointer - } - - /** - * Construct a bitmap from a list of uint32_t values. - */ - static Roaring bitmapOf(size_t n, ...) { - Roaring ans; - va_list vl; - va_start(vl, n); - for (size_t i = 0; i < n; i++) { - ans.add(va_arg(vl, uint32_t)); - } - va_end(vl); - return ans; - } - - /** - * Construct a bitmap from a list of uint32_t values. - * E.g., bitmapOfList({1,2,3}). - */ - static Roaring bitmapOfList(std::initializer_list l) { - Roaring ans; - ans.addMany(l.size(), l.begin()); - return ans; - } - - /** - * Add value x - */ - void add(uint32_t x) noexcept { api::roaring_bitmap_add(&roaring, x); } - - /** - * Add value x - * Returns true if a new value was added, false if the value was already - * existing. - */ - bool addChecked(uint32_t x) noexcept { - return api::roaring_bitmap_add_checked(&roaring, x); - } - - /** - * Add all values in range [min, max) - */ - void addRange(const uint64_t min, const uint64_t max) noexcept { - return api::roaring_bitmap_add_range(&roaring, min, max); - } - - /** - * Add all values in range [min, max] - */ - void addRangeClosed(const uint32_t min, const uint32_t max) noexcept { - return api::roaring_bitmap_add_range_closed(&roaring, min, max); - } - - /** - * Add value n_args from pointer vals - */ - void addMany(size_t n_args, const uint32_t *vals) noexcept { - api::roaring_bitmap_add_many(&roaring, n_args, vals); - } - - /** - * Add value val, using context from a previous insert for speed - * optimization. - * - * `context` will be used to store information between calls to make bulk - * operations faster. `context` should be default-initialized before the - * first call to this function. - */ - void addBulk(BulkContext &context, uint32_t x) noexcept { - api::roaring_bitmap_add_bulk(&roaring, &context.context_, x); - } - - /** - * Check if item x is present, using context from a previous insert or search - * for speed optimization. - * - * `context` will be used to store information between calls to make bulk - * operations faster. `context` should be default-initialized before the - * first call to this function. - */ - bool containsBulk(BulkContext& context, uint32_t x) const noexcept { - return api::roaring_bitmap_contains_bulk(&roaring, &context.context_, x); - } - - /** - * Remove value x - */ - void remove(uint32_t x) noexcept { api::roaring_bitmap_remove(&roaring, x); } - - /** - * Remove value x - * Returns true if a new value was removed, false if the value was not - * existing. - */ - bool removeChecked(uint32_t x) noexcept { - return api::roaring_bitmap_remove_checked(&roaring, x); - } - - /** - * Remove all values in range [min, max) - */ - void removeRange(uint64_t min, uint64_t max) noexcept { - return api::roaring_bitmap_remove_range(&roaring, min, max); - } - - /** - * Remove all values in range [min, max] - */ - void removeRangeClosed(uint32_t min, uint32_t max) noexcept { - return api::roaring_bitmap_remove_range_closed(&roaring, min, max); - } - - /** - * Return the largest value (if not empty) - */ - uint32_t maximum() const noexcept { return api::roaring_bitmap_maximum(&roaring); } - - /** - * Return the smallest value (if not empty) - */ - uint32_t minimum() const noexcept { return api::roaring_bitmap_minimum(&roaring); } - - /** - * Check if value x is present - */ - bool contains(uint32_t x) const noexcept { - return api::roaring_bitmap_contains(&roaring, x); - } - - /** - * Check if all values from x (included) to y (excluded) are present - */ - bool containsRange(const uint64_t x, const uint64_t y) const noexcept { - return api::roaring_bitmap_contains_range(&roaring, x, y); - } - - /** - * Destructor. By contract, calling roaring_bitmap_clear() is enough to - * release all auxiliary memory used by the structure. - */ - ~Roaring() { - if (!(roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) { - api::roaring_bitmap_clear(&roaring); - } else { - // The roaring member variable copies the `roaring_bitmap_t` and - // nested `roaring_array_t` structures by value and is freed in the - // constructor, however the underlying memory arena used for the - // container data is not freed with it. Here we derive the arena - // pointer from the second arena allocation in - // `roaring_bitmap_frozen_view` and free it as well. - roaring_bitmap_free( - (roaring_bitmap_t *)((char *) - roaring.high_low_container.containers - - sizeof(roaring_bitmap_t))); - } - } - - /** - * Copies the content of the provided bitmap, and - * discard the current content. - * It may throw std::runtime_error if there is insufficient memory. - */ - Roaring &operator=(const Roaring &r) { - if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) { - ROARING_TERMINATE("failed memory alloc in assignment"); - } - api::roaring_bitmap_set_copy_on_write( - &roaring, - api::roaring_bitmap_get_copy_on_write(&r.roaring)); - return *this; - } - - /** - * Moves the content of the provided bitmap, and - * discard the current content. - */ - Roaring &operator=(Roaring &&r) noexcept { - api::roaring_bitmap_clear(&roaring); // free this class's allocations - - // !!! See notes in the Move Constructor regarding roaring_bitmap_move() - // - roaring = r.roaring; - api::roaring_bitmap_init_cleared(&r.roaring); - - return *this; - } - - /** - * Assignment from an initializer list. - */ - Roaring &operator=(std::initializer_list l) { - // Delegate to move assignment operator - *this = Roaring(l); - return *this; - } - - /** - * Compute the intersection between the current bitmap and the provided - * bitmap, writing the result in the current bitmap. The provided bitmap - * is not modified. - * - * Performance hint: if you are computing the intersection between several - * bitmaps, two-by-two, it is best to start with the smallest bitmap. - */ - Roaring &operator&=(const Roaring &r) noexcept { - api::roaring_bitmap_and_inplace(&roaring, &r.roaring); - return *this; - } - - /** - * Compute the difference between the current bitmap and the provided - * bitmap, writing the result in the current bitmap. The provided bitmap - * is not modified. - */ - Roaring &operator-=(const Roaring &r) noexcept { - api::roaring_bitmap_andnot_inplace(&roaring, &r.roaring); - return *this; - } - - /** - * Compute the union between the current bitmap and the provided bitmap, - * writing the result in the current bitmap. The provided bitmap is not - * modified. - * - * See also the fastunion function to aggregate many bitmaps more quickly. - */ - Roaring &operator|=(const Roaring &r) noexcept { - api::roaring_bitmap_or_inplace(&roaring, &r.roaring); - return *this; - } - - /** - * Compute the symmetric union between the current bitmap and the provided - * bitmap, writing the result in the current bitmap. The provided bitmap - * is not modified. - */ - Roaring &operator^=(const Roaring &r) noexcept { - api::roaring_bitmap_xor_inplace(&roaring, &r.roaring); - return *this; - } - - /** - * Exchange the content of this bitmap with another. - */ - void swap(Roaring &r) noexcept { std::swap(r.roaring, roaring); } - - /** - * Get the cardinality of the bitmap (number of elements). - */ - uint64_t cardinality() const noexcept { - return api::roaring_bitmap_get_cardinality(&roaring); - } - - /** - * Returns true if the bitmap is empty (cardinality is zero). - */ - bool isEmpty() const noexcept { return api::roaring_bitmap_is_empty(&roaring); } - - /** - * Returns true if the bitmap is subset of the other. - */ - bool isSubset(const Roaring &r) const noexcept { - return api::roaring_bitmap_is_subset(&roaring, &r.roaring); - } - - /** - * Returns true if the bitmap is strict subset of the other. - */ - bool isStrictSubset(const Roaring &r) const noexcept { - return api::roaring_bitmap_is_strict_subset(&roaring, &r.roaring); - } - - /** - * Convert the bitmap to an array. Write the output to "ans", caller is - * responsible to ensure that there is enough memory allocated - * (e.g., ans = new uint32[mybitmap.cardinality()];) - */ - void toUint32Array(uint32_t *ans) const noexcept { - api::roaring_bitmap_to_uint32_array(&roaring, ans); - } - /** - * To int array with pagination - */ - void rangeUint32Array(uint32_t *ans, size_t offset, size_t limit) const noexcept { - api::roaring_bitmap_range_uint32_array(&roaring, offset, limit, ans); - } - - /** - * Return true if the two bitmaps contain the same elements. - */ - bool operator==(const Roaring &r) const noexcept { - return api::roaring_bitmap_equals(&roaring, &r.roaring); - } - - /** - * Compute the negation of the roaring bitmap within the half-open interval - * [range_start, range_end). Areas outside the interval are unchanged. - */ - void flip(uint64_t range_start, uint64_t range_end) noexcept { - api::roaring_bitmap_flip_inplace(&roaring, range_start, range_end); - } - - /** - * Compute the negation of the roaring bitmap within the closed interval - * [range_start, range_end]. Areas outside the interval are unchanged. - */ - void flipClosed(uint32_t range_start, uint32_t range_end) noexcept { - api::roaring_bitmap_flip_inplace( - &roaring, range_start, uint64_t(range_end) + 1); - } - - /** - * Remove run-length encoding even when it is more space efficient. - * Return whether a change was applied. - */ - bool removeRunCompression() noexcept { - return api::roaring_bitmap_remove_run_compression(&roaring); - } - - /** - * Convert array and bitmap containers to run containers when it is more - * efficient; also convert from run containers when more space efficient. - * Returns true if the result has at least one run container. Additional - * savings might be possible by calling shrinkToFit(). - */ - bool runOptimize() noexcept { return api::roaring_bitmap_run_optimize(&roaring); } - - /** - * If needed, reallocate memory to shrink the memory usage. Returns - * the number of bytes saved. - */ - size_t shrinkToFit() noexcept { return api::roaring_bitmap_shrink_to_fit(&roaring); } - - /** - * Iterate over the bitmap elements. The function iterator is called once - * for all the values with ptr (can be NULL) as the second parameter of - * each call. - * - * roaring_iterator is simply a pointer to a function that returns bool - * (true means that the iteration should continue while false means that it - * should stop), and takes (uint32_t,void*) as inputs. - */ - void iterate(api::roaring_iterator iterator, void *ptr) const { - api::roaring_iterate(&roaring, iterator, ptr); - } - - /** - * Selects the value at index rnk in the bitmap, where the smallest value - * is at index 0. - * - * If the size of the roaring bitmap is strictly greater than rank, then - * this function returns true and sets element to the element of given rank. - * Otherwise, it returns false. - */ - bool select(uint32_t rnk, uint32_t *element) const noexcept { - return api::roaring_bitmap_select(&roaring, rnk, element); - } - - /** - * Computes the size of the intersection between two bitmaps. - */ - uint64_t and_cardinality(const Roaring &r) const noexcept { - return api::roaring_bitmap_and_cardinality(&roaring, &r.roaring); - } - - /** - * Check whether the two bitmaps intersect. - */ - bool intersect(const Roaring &r) const noexcept { - return api::roaring_bitmap_intersect(&roaring, &r.roaring); - } - - /** - * Computes the Jaccard index between two bitmaps. (Also known as the - * Tanimoto distance, - * or the Jaccard similarity coefficient) - * - * The Jaccard index is undefined if both bitmaps are empty. - */ - double jaccard_index(const Roaring &r) const noexcept { - return api::roaring_bitmap_jaccard_index(&roaring, &r.roaring); - } - - /** - * Computes the size of the union between two bitmaps. - */ - uint64_t or_cardinality(const Roaring &r) const noexcept { - return api::roaring_bitmap_or_cardinality(&roaring, &r.roaring); - } - - /** - * Computes the size of the difference (andnot) between two bitmaps. - */ - uint64_t andnot_cardinality(const Roaring &r) const noexcept { - return api::roaring_bitmap_andnot_cardinality(&roaring, &r.roaring); - } - - /** - * Computes the size of the symmetric difference (andnot) between two - * bitmaps. - */ - uint64_t xor_cardinality(const Roaring &r) const noexcept { - return api::roaring_bitmap_xor_cardinality(&roaring, &r.roaring); - } - - /** - * Returns the number of integers that are smaller or equal to x. - * Thus the rank of the smallest element is one. If - * x is smaller than the smallest element, this function will return 0. - * The rank and select functions differ in convention: this function returns - * 1 when ranking the smallest value, but the select function returns the - * smallest value when using index 0. - */ - uint64_t rank(uint32_t x) const noexcept { - return api::roaring_bitmap_rank(&roaring, x); - } - - /** - * Returns the index of x in the set, index start from 0. - * If the set doesn't contain x , this function will return -1. - * The difference with rank function is that this function will return -1 - * when x isn't in the set, but the rank function will return a - * non-negative number. - */ - int64_t getIndex(uint32_t x) const noexcept { - return api::roaring_bitmap_get_index(&roaring, x); - } - - /** - * Write a bitmap to a char buffer. This is meant to be compatible with - * the Java and Go versions. Returns how many bytes were written which - * should be getSizeInBytes(). - * - * Setting the portable flag to false enable a custom format that - * can save space compared to the portable format (e.g., for very - * sparse bitmaps). - * - * Boost users can serialize bitmaps in this manner: - * - * BOOST_SERIALIZATION_SPLIT_FREE(Roaring) - * namespace boost { - * namespace serialization { - * - * template - * void save(Archive& ar, const Roaring& bitmask, - * const unsigned int version) { - * std::size_t expected_size_in_bytes = bitmask.getSizeInBytes(); - * std::vector buffer(expected_size_in_bytes); - * std::size_t size_in_bytes = bitmask.write(buffer.data()); - * - * ar& size_in_bytes; - * ar& boost::serialization::make_binary_object(buffer.data(), - * size_in_bytes); - * } - * template - * void load(Archive& ar, Roaring& bitmask, - * const unsigned int version) { - * std::size_t size_in_bytes = 0; - * ar& size_in_bytes; - * std::vector buffer(size_in_bytes); - * ar& boost::serialization::make_binary_object(buffer.data(), - * size_in_bytes); - * bitmask = Roaring::readSafe(buffer.data(), size_in_bytes); - * } - * } // namespace serialization - * } // namespace boost - */ - size_t write(char *buf, bool portable = true) const noexcept { - if (portable) { - return api::roaring_bitmap_portable_serialize(&roaring, buf); - } else { - return api::roaring_bitmap_serialize(&roaring, buf); - } - } - - /** - * Read a bitmap from a serialized version. This is meant to be compatible - * with the Java and Go versions. - * - * Setting the portable flag to false enable a custom format that - * can save space compared to the portable format (e.g., for very - * sparse bitmaps). - * - * This function is unsafe in the sense that if you provide bad data, - * many, many bytes could be read. See also readSafe. - * - * The function may throw std::runtime_error if a bitmap could not be read. Not that even - * if it does not throw, the bitmap could still be unusable if the loaded - * data does not match the portable Roaring specification: you should - * ensure that the data you load come from a serialized bitmap. - */ - static Roaring read(const char *buf, bool portable = true) { - roaring_bitmap_t * r = portable - ? api::roaring_bitmap_portable_deserialize(buf) - : api::roaring_bitmap_deserialize(buf); - if (r == NULL) { - ROARING_TERMINATE("failed alloc while reading"); - } - return Roaring(r); - } - - /** - * Read a bitmap from a serialized version, reading no more than maxbytes - * bytes. This is meant to be compatible with the Java and Go versions. - * The function itself is safe in the sense that it will not cause buffer overflows. - * However, for correct operations, it is assumed that the bitmap read was once - * serialized from a valid bitmap. If you provided an incorrect input (garbage), then the - * bitmap read may not be in a valid state and following operations may not lead - * to sensible results. It is your responsability to ensure that the input bytes - * follow the format specification if you want a usable bitmap: - * https://github.com/RoaringBitmap/RoaringFormatSpec - * In particular, the serialized array containers need to be in sorted order, and the - * run containers should be in sorted non-overlapping order. This is is guaranteed to - * happen when serializing an existing bitmap, but not for random inputs. - * Note that this function assumes that your bitmap was serialized in *portable* mode - * (which is the default with the 'write' method). - * - * The function may throw std::runtime_error if a bitmap could not be read. Not that even - * if it does not throw, the bitmap could still be unusable if the loaded - * data does not match the portable Roaring specification: you should - * ensure that the data you load come from a serialized bitmap. - */ - static Roaring readSafe(const char *buf, size_t maxbytes) { - roaring_bitmap_t * r = - api::roaring_bitmap_portable_deserialize_safe(buf,maxbytes); - if (r == NULL) { - ROARING_TERMINATE("failed alloc while reading"); - } - return Roaring(r); - } - - /** - * How many bytes are required to serialize this bitmap (meant to be - * compatible with Java and Go versions) - * - * Setting the portable flag to false enable a custom format that - * can save space compared to the portable format (e.g., for very - * sparse bitmaps). - */ - size_t getSizeInBytes(bool portable = true) const noexcept { - if (portable) { - return api::roaring_bitmap_portable_size_in_bytes(&roaring); - } else { - return api::roaring_bitmap_size_in_bytes(&roaring); - } - } - - /** - * For advanced users. - * This function may throw std::runtime_error. - */ - static const Roaring frozenView(const char *buf, size_t length) { - const roaring_bitmap_t *s = - api::roaring_bitmap_frozen_view(buf, length); - if (s == NULL) { - ROARING_TERMINATE("failed to read frozen bitmap"); - } - Roaring r; - r.roaring = *s; - return r; - } - - /** - * For advanced users. - */ - void writeFrozen(char *buf) const noexcept { - roaring_bitmap_frozen_serialize(&roaring, buf); - } - - /** - * For advanced users. - */ - size_t getFrozenSizeInBytes() const noexcept { - return roaring_bitmap_frozen_size_in_bytes(&roaring); - } - - /** - * Computes the intersection between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - * - * Performance hint: if you are computing the intersection between several - * bitmaps, two-by-two, it is best to start with the smallest bitmap. - * Consider also using the operator &= to avoid needlessly creating - * many temporary bitmaps. - * This function may throw std::runtime_error. - */ - Roaring operator&(const Roaring &o) const { - roaring_bitmap_t *r = api::roaring_bitmap_and(&roaring, &o.roaring); - if (r == NULL) { - ROARING_TERMINATE("failed materalization in and"); - } - return Roaring(r); - } - - /** - * Computes the difference between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - * This function may throw std::runtime_error. - */ - Roaring operator-(const Roaring &o) const { - roaring_bitmap_t *r = api::roaring_bitmap_andnot(&roaring, &o.roaring); - if (r == NULL) { - ROARING_TERMINATE("failed materalization in andnot"); - } - return Roaring(r); - } - - /** - * Computes the union between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - * This function may throw std::runtime_error. - */ - Roaring operator|(const Roaring &o) const { - roaring_bitmap_t *r = api::roaring_bitmap_or(&roaring, &o.roaring); - if (r == NULL) { - ROARING_TERMINATE("failed materalization in or"); - } - return Roaring(r); - } - - /** - * Computes the symmetric union between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - * This function may throw std::runtime_error. - */ - Roaring operator^(const Roaring &o) const { - roaring_bitmap_t *r = api::roaring_bitmap_xor(&roaring, &o.roaring); - if (r == NULL) { - ROARING_TERMINATE("failed materalization in xor"); - } - return Roaring(r); - } - - /** - * Whether or not we apply copy and write. - */ - void setCopyOnWrite(bool val) noexcept { - api::roaring_bitmap_set_copy_on_write(&roaring, val); - } - - /** - * Print the content of the bitmap - */ - void printf() const noexcept { api::roaring_bitmap_printf(&roaring); } - - /** - * Print the content of the bitmap into a string - */ - std::string toString() const noexcept { - struct iter_data { - std::string str{}; // The empty constructor silences warnings from pedantic static analyzers. - char first_char = '{'; - } outer_iter_data; - if (!isEmpty()) { - iterate( - [](uint32_t value, void *inner_iter_data) -> bool { - ((iter_data *)inner_iter_data)->str += - ((iter_data *)inner_iter_data)->first_char; - ((iter_data *)inner_iter_data)->str += - std::to_string(value); - ((iter_data *)inner_iter_data)->first_char = ','; - return true; - }, - (void *)&outer_iter_data); - } else - outer_iter_data.str = '{'; - outer_iter_data.str += '}'; - return outer_iter_data.str; - } - - /** - * Whether or not copy and write is active. - */ - bool getCopyOnWrite() const noexcept { - return api::roaring_bitmap_get_copy_on_write(&roaring); - } - - /** - * Computes the logical or (union) between "n" bitmaps (referenced by a - * pointer). - * This function may throw std::runtime_error. - */ - static Roaring fastunion(size_t n, const Roaring **inputs) { - const roaring_bitmap_t **x = - (const roaring_bitmap_t **)roaring_malloc(n * sizeof(roaring_bitmap_t *)); - if (x == NULL) { - ROARING_TERMINATE("failed memory alloc in fastunion"); - } - for (size_t k = 0; k < n; ++k) x[k] = &inputs[k]->roaring; - - roaring_bitmap_t *c_ans = api::roaring_bitmap_or_many(n, x); - if (c_ans == NULL) { - roaring_free(x); - ROARING_TERMINATE("failed memory alloc in fastunion"); - } - Roaring ans(c_ans); - roaring_free(x); - return ans; - } - - typedef RoaringSetBitForwardIterator const_iterator; - - /** - * Returns an iterator that can be used to access the position of the set - * bits. The running time complexity of a full scan is proportional to the - * number of set bits: be aware that if you have long strings of 1s, this - * can be very inefficient. - * - * It can be much faster to use the toArray method if you want to retrieve - * the set bits. - */ - const_iterator begin() const; - - /** - * A bogus iterator that can be used together with begin() - * for constructions such as for (auto i = b.begin(); * i!=b.end(); ++i) {} - */ - const_iterator &end() const; - - roaring_bitmap_t roaring; -}; - -/** - * Used to go through the set bits. Not optimally fast, but convenient. - */ -class RoaringSetBitForwardIterator final { -public: - typedef std::forward_iterator_tag iterator_category; - typedef uint32_t *pointer; - typedef uint32_t &reference_type; - typedef uint32_t value_type; - typedef int32_t difference_type; - typedef RoaringSetBitForwardIterator type_of_iterator; - - /** - * Provides the location of the set bit. - */ - value_type operator*() const { return i.current_value; } - - bool operator<(const type_of_iterator &o) const { - if (!i.has_value) return false; - if (!o.i.has_value) return true; - return i.current_value < *o; - } - - bool operator<=(const type_of_iterator &o) const { - if (!o.i.has_value) return true; - if (!i.has_value) return false; - return i.current_value <= *o; - } - - bool operator>(const type_of_iterator &o) const { - if (!o.i.has_value) return false; - if (!i.has_value) return true; - return i.current_value > *o; - } - - bool operator>=(const type_of_iterator &o) const { - if (!i.has_value) return true; - if (!o.i.has_value) return false; - return i.current_value >= *o; - } - - /** - * Move the iterator to the first value >= val. - */ - void equalorlarger(uint32_t val) { - api::roaring_move_uint32_iterator_equalorlarger(&i,val); - } - - type_of_iterator &operator++() { // ++i, must returned inc. value - api::roaring_advance_uint32_iterator(&i); - return *this; - } - - type_of_iterator operator++(int) { // i++, must return orig. value - RoaringSetBitForwardIterator orig(*this); - api::roaring_advance_uint32_iterator(&i); - return orig; - } - - type_of_iterator& operator--() { // prefix -- - api::roaring_previous_uint32_iterator(&i); - return *this; - } - - type_of_iterator operator--(int) { // postfix -- - RoaringSetBitForwardIterator orig(*this); - api::roaring_previous_uint32_iterator(&i); - return orig; - } - - bool operator==(const RoaringSetBitForwardIterator &o) const { - return i.current_value == *o && i.has_value == o.i.has_value; - } - - bool operator!=(const RoaringSetBitForwardIterator &o) const { - return i.current_value != *o || i.has_value != o.i.has_value; - } - - explicit RoaringSetBitForwardIterator(const Roaring &parent, - bool exhausted = false) { - if (exhausted) { - i.parent = &parent.roaring; - i.container_index = INT32_MAX; - i.has_value = false; - i.current_value = UINT32_MAX; - } else { - api::roaring_init_iterator(&parent.roaring, &i); - } - } - - api::roaring_uint32_iterator_t i{}; // The empty constructor silences warnings from pedantic static analyzers. -}; - -inline RoaringSetBitForwardIterator Roaring::begin() const { - return RoaringSetBitForwardIterator(*this); -} - -inline RoaringSetBitForwardIterator &Roaring::end() const { - static RoaringSetBitForwardIterator e(*this, true); - return e; -} - -} // namespace roaring - -#endif /* INCLUDE_ROARING_HH_ */ -/* end file cpp/roaring.hh */ -/* begin file cpp/roaring64map.hh */ -/** - * A C++ header for 64-bit Roaring Bitmaps, - * implemented by way of a map of many - * 32-bit Roaring Bitmaps. - * - * Reference (format specification) : - * https://github.com/RoaringBitmap/RoaringFormatSpec#extention-for-64-bit-implementations -*/ -#ifndef INCLUDE_ROARING_64_MAP_HH_ -#define INCLUDE_ROARING_64_MAP_HH_ - -#include -#include // PRIu64 macro -#include // for va_list handling in bitmapOf() -#include // for std::printf() in the printf() method -#include // for std::memcpy() -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace roaring { - -using roaring::Roaring; - -class Roaring64MapSetBitForwardIterator; -class Roaring64MapSetBitBiDirectionalIterator; - -class Roaring64Map { - typedef api::roaring_bitmap_t roaring_bitmap_t; - -public: - /** - * Create an empty bitmap - */ - Roaring64Map() = default; - - /** - * Construct a bitmap from a list of 32-bit integer values. - */ - Roaring64Map(size_t n, const uint32_t *data) { addMany(n, data); } - - /** - * Construct a bitmap from a list of 64-bit integer values. - */ - Roaring64Map(size_t n, const uint64_t *data) { addMany(n, data); } - - /** - * Construct a bitmap from an initializer list. - */ - Roaring64Map(std::initializer_list l) { - addMany(l.size(), l.begin()); - } - - /** - * Construct a 64-bit map from a 32-bit one - */ - explicit Roaring64Map(const Roaring &r) { emplaceOrInsert(0, r); } - - /** - * Construct a 64-bit map from a 32-bit rvalue - */ - explicit Roaring64Map(Roaring &&r) { emplaceOrInsert(0, std::move(r)); } - - /** - * Construct a roaring object from the C struct. - * - * Passing a NULL point is unsafe. - */ - explicit Roaring64Map(roaring_bitmap_t *s) { - emplaceOrInsert(0, Roaring(s)); - } - - Roaring64Map(const Roaring64Map& r) = default; - - Roaring64Map(Roaring64Map&& r) noexcept = default; - - /** - * Copy assignment operator. - */ - Roaring64Map &operator=(const Roaring64Map &r) = default; - - /** - * Move assignment operator. - */ - Roaring64Map &operator=(Roaring64Map &&r) noexcept = default; - - /** - * Assignment from an initializer list. - */ - Roaring64Map &operator=(std::initializer_list l) { - // Delegate to move assignment operator - *this = Roaring64Map(l); - return *this; - } - - /** - * Construct a bitmap from a list of uint64_t values. - */ - static Roaring64Map bitmapOf(size_t n...) { - Roaring64Map ans; - va_list vl; - va_start(vl, n); - for (size_t i = 0; i < n; i++) { - ans.add(va_arg(vl, uint64_t)); - } - va_end(vl); - return ans; - } - - /** - * Construct a bitmap from a list of uint64_t values. - * E.g., bitmapOfList({1,2,3}). - */ - static Roaring64Map bitmapOfList(std::initializer_list l) { - Roaring64Map ans; - ans.addMany(l.size(), l.begin()); - return ans; - } - - /** - * Adds value x. - */ - void add(uint32_t x) { - lookupOrCreateInner(0).add(x); - } - - /** - * Adds value x. - */ - void add(uint64_t x) { - lookupOrCreateInner(highBytes(x)).add(lowBytes(x)); - } - - /** - * Adds value x. - * Returns true if a new value was added, false if the value was already - * present. - */ - bool addChecked(uint32_t x) { - return lookupOrCreateInner(0).addChecked(x); - } - - /** - * Adds value x. - * Returns true if a new value was added, false if the value was already - * present. - */ - bool addChecked(uint64_t x) { - return lookupOrCreateInner(highBytes(x)).addChecked(lowBytes(x)); - } - - /** - * Adds all values in the half-open interval [min, max). - */ - void addRange(uint64_t min, uint64_t max) { - if (min >= max) { - return; - } - addRangeClosed(min, max - 1); - } - - /** - * Adds all values in the closed interval [min, max]. - */ - void addRangeClosed(uint32_t min, uint32_t max) { - lookupOrCreateInner(0).addRangeClosed(min, max); - } - - /** - * Adds all values in the closed interval [min, max] - */ - void addRangeClosed(uint64_t min, uint64_t max) { - if (min > max) { - return; - } - uint32_t start_high = highBytes(min); - uint32_t start_low = lowBytes(min); - uint32_t end_high = highBytes(max); - uint32_t end_low = lowBytes(max); - - // We put std::numeric_limits<>::max in parentheses to avoid a - // clash with the Windows.h header under Windows. - const uint32_t uint32_max = (std::numeric_limits::max)(); - - // Fill in any nonexistent slots with empty Roarings. This simplifies - // the logic below, allowing it to simply iterate over the map between - // 'start_high' and 'end_high' in a linear fashion. - auto current_iter = ensureRangePopulated(start_high, end_high); - - // If start and end land on the same inner bitmap, then we can do the - // whole operation in one call. - if (start_high == end_high) { - auto &bitmap = current_iter->second; - bitmap.addRangeClosed(start_low, end_low); - return; - } - - // Because start and end don't land on the same inner bitmap, - // we need to do this in multiple steps: - // 1. Partially fill the first bitmap with values from the closed - // interval [start_low, uint32_max] - // 2. Fill intermediate bitmaps completely: [0, uint32_max] - // 3. Partially fill the last bitmap with values from the closed - // interval [0, end_low] - auto num_intermediate_bitmaps = end_high - start_high - 1; - - // Step 1: Partially fill the first bitmap. - { - auto &bitmap = current_iter->second; - bitmap.addRangeClosed(start_low, uint32_max); - ++current_iter; - } - - // Step 2. Fill intermediate bitmaps completely. - if (num_intermediate_bitmaps != 0) { - auto &first_intermediate = current_iter->second; - first_intermediate.addRangeClosed(0, uint32_max); - ++current_iter; - - // Now make (num_intermediate_bitmaps - 1) copies of this. - for (uint32_t i = 1; i != num_intermediate_bitmaps; ++i) { - auto &next_intermediate = current_iter->second; - next_intermediate = first_intermediate; - ++current_iter; - } - } - - // Step 3: Partially fill the last bitmap. - auto &bitmap = current_iter->second; - bitmap.addRangeClosed(0, end_low); - } - - /** - * Adds 'n_args' values from the contiguous memory range starting at 'vals'. - */ - void addMany(size_t n_args, const uint32_t *vals) { - lookupOrCreateInner(0).addMany(n_args, vals); - } - - /** - * Adds 'n_args' values from the contiguous memory range starting at 'vals'. - */ - void addMany(size_t n_args, const uint64_t *vals) { - // Potentially reduce outer map lookups by optimistically - // assuming that adjacent values will belong to the same inner bitmap. - Roaring *last_inner_bitmap = nullptr; - uint32_t last_value_high = 0; - for (size_t lcv = 0; lcv < n_args; lcv++) { - auto value = vals[lcv]; - auto value_high = highBytes(value); - auto value_low = lowBytes(value); - if (last_inner_bitmap == nullptr || value_high != last_value_high) { - last_inner_bitmap = &lookupOrCreateInner(value_high); - last_value_high = value_high; - } - last_inner_bitmap->add(value_low); - } - } - - /** - * Removes value x. - */ - void remove(uint32_t x) { - auto iter = roarings.begin(); - // Since x is a uint32_t, highbytes(x) == 0. The inner bitmap we are - // looking for, if it exists, will be at the first slot of 'roarings'. - if (iter == roarings.end() || iter->first != 0) { - return; - } - auto &bitmap = iter->second; - bitmap.remove(x); - eraseIfEmpty(iter); - } - - /** - * Removes value x. - */ - void remove(uint64_t x) { - auto iter = roarings.find(highBytes(x)); - if (iter == roarings.end()) { - return; - } - auto &bitmap = iter->second; - bitmap.remove(lowBytes(x)); - eraseIfEmpty(iter); - } - - /** - * Removes value x - * Returns true if a new value was removed, false if the value was not - * present. - */ - bool removeChecked(uint32_t x) { - auto iter = roarings.begin(); - // Since x is a uint32_t, highbytes(x) == 0. The inner bitmap we are - // looking for, if it exists, will be at the first slot of 'roarings'. - if (iter == roarings.end() || iter->first != 0) { - return false; - } - auto &bitmap = iter->second; - if (!bitmap.removeChecked(x)) { - return false; - } - eraseIfEmpty(iter); - return true; - } - - /** - * Remove value x - * Returns true if a new value was removed, false if the value was not - * present. - */ - bool removeChecked(uint64_t x) { - auto iter = roarings.find(highBytes(x)); - if (iter == roarings.end()) { - return false; - } - auto &bitmap = iter->second; - if (!bitmap.removeChecked(lowBytes(x))) { - return false; - } - eraseIfEmpty(iter); - return true; - } - - /** - * Removes all values in the half-open interval [min, max). - */ - void removeRange(uint64_t min, uint64_t max) { - if (min >= max) { - return; - } - return removeRangeClosed(min, max - 1); - } - - /** - * Removes all values in the closed interval [min, max]. - */ - void removeRangeClosed(uint32_t min, uint32_t max) { - auto iter = roarings.begin(); - // Since min and max are uint32_t, highbytes(min or max) == 0. The inner - // bitmap we are looking for, if it exists, will be at the first slot of - // 'roarings'. - if (iter == roarings.end() || iter->first != 0) { - return; - } - auto &bitmap = iter->second; - bitmap.removeRangeClosed(min, max); - eraseIfEmpty(iter); - } - - /** - * Removes all values in the closed interval [min, max]. - */ - void removeRangeClosed(uint64_t min, uint64_t max) { - if (min > max) { - return; - } - uint32_t start_high = highBytes(min); - uint32_t start_low = lowBytes(min); - uint32_t end_high = highBytes(max); - uint32_t end_low = lowBytes(max); - - // We put std::numeric_limits<>::max in parentheses to avoid a - // clash with the Windows.h header under Windows. - const uint32_t uint32_max = (std::numeric_limits::max)(); - - // If the outer map is empty, end_high is less than the first key, - // or start_high is greater than the last key, then exit now because - // there is no work to do. - if (roarings.empty() || end_high < roarings.cbegin()->first || - start_high > (roarings.crbegin())->first) { - return; - } - - // If we get here, start_iter points to the first entry in the outer map - // with key >= start_high. Such an entry is known to exist (i.e. the - // iterator will not be equal to end()) because start_high <= the last - // key in the map (thanks to the above if statement). - auto start_iter = roarings.lower_bound(start_high); - // end_iter points to the first entry in the outer map with - // key >= end_high, if such a key exists. Otherwise, it equals end(). - auto end_iter = roarings.lower_bound(end_high); - - // Note that the 'lower_bound' method will find the start and end slots, - // if they exist; otherwise it will find the next-higher slots. - // In the case where 'start' landed on an existing slot, we need to do a - // partial erase of that slot, and likewise for 'end'. But all the slots - // in between can be fully erased. More precisely: - // - // 1. If the start point falls on an existing entry, there are two - // subcases: - // a. if the end point falls on that same entry, remove the closed - // interval [start_low, end_low] from that entry and we are done. - // b. Otherwise, remove the closed interval [start_low, uint32_max] - // from that entry, advance start_iter, and fall through to step 2. - // 2. Completely erase all slots in the half-open interval - // [start_iter, end_iter) - // 3. If the end point falls on an existing entry, remove the closed - // interval [0, end_high] from it. - - // Step 1. If the start point falls on an existing entry... - if (start_iter->first == start_high) { - auto &start_inner = start_iter->second; - // 1a. if the end point falls on that same entry... - if (start_iter == end_iter) { - start_inner.removeRangeClosed(start_low, end_low); - eraseIfEmpty(start_iter); - return; - } - - // 1b. Otherwise, remove the closed range [start_low, uint32_max]... - start_inner.removeRangeClosed(start_low, uint32_max); - // Advance start_iter, but keep the old value so we can check the - // bitmap we just modified for emptiness and erase if it necessary. - auto temp = start_iter++; - eraseIfEmpty(temp); - } - - // 2. Completely erase all slots in the half-open interval... - roarings.erase(start_iter, end_iter); - - // 3. If the end point falls on an existing entry... - if (end_iter != roarings.end() && end_iter->first == end_high) { - auto &end_inner = end_iter->second; - end_inner.removeRangeClosed(0, end_low); - eraseIfEmpty(end_iter); - } - } - - /** - * Clears the bitmap. - */ - void clear() { - roarings.clear(); - } - - /** - * Return the largest value (if not empty) - */ - uint64_t maximum() const { - for (auto roaring_iter = roarings.crbegin(); - roaring_iter != roarings.crend(); ++roaring_iter) { - if (!roaring_iter->second.isEmpty()) { - return uniteBytes(roaring_iter->first, - roaring_iter->second.maximum()); - } - } - // we put std::numeric_limits<>::max/min in parentheses - // to avoid a clash with the Windows.h header under Windows - return (std::numeric_limits::min)(); - } - - /** - * Return the smallest value (if not empty) - */ - uint64_t minimum() const { - for (auto roaring_iter = roarings.cbegin(); - roaring_iter != roarings.cend(); ++roaring_iter) { - if (!roaring_iter->second.isEmpty()) { - return uniteBytes(roaring_iter->first, - roaring_iter->second.minimum()); - } - } - // we put std::numeric_limits<>::max/min in parentheses - // to avoid a clash with the Windows.h header under Windows - return (std::numeric_limits::max)(); - } - - /** - * Check if value x is present - */ - bool contains(uint32_t x) const { - return roarings.count(0) == 0 ? false : roarings.at(0).contains(x); - } - bool contains(uint64_t x) const { - return roarings.count(highBytes(x)) == 0 - ? false - : roarings.at(highBytes(x)).contains(lowBytes(x)); - } - - /** - * Compute the intersection of the current bitmap and the provided bitmap, - * writing the result in the current bitmap. The provided bitmap is not - * modified. - * - * Performance hint: if you are computing the intersection between several - * bitmaps, two-by-two, it is best to start with the smallest bitmap. - */ - Roaring64Map &operator&=(const Roaring64Map &other) { - if (this == &other) { - // ANDing *this with itself is a no-op. - return *this; - } - - // Logic table summarizing what to do when a given outer key is - // present vs. absent from self and other. - // - // self other (self & other) work to do - // -------------------------------------------- - // absent absent empty None - // absent present empty None - // present absent empty Erase self - // present present empty or not Intersect self with other, but - // erase self if result is empty. - // - // Because there is only work to do when a key is present in 'self', the - // main for loop iterates over entries in 'self'. - - decltype(roarings.begin()) self_next; - for (auto self_iter = roarings.begin(); self_iter != roarings.end(); - self_iter = self_next) { - // Do the 'next' operation now, so we don't have to worry about - // invalidation of self_iter down below with the 'erase' operation. - self_next = std::next(self_iter); - - auto self_key = self_iter->first; - auto &self_bitmap = self_iter->second; - - auto other_iter = other.roarings.find(self_key); - if (other_iter == other.roarings.end()) { - // 'other' doesn't have self_key. In the logic table above, - // this reflects the case (self.present & other.absent). - // So, erase self. - roarings.erase(self_iter); - continue; - } - - // Both sides have self_key. In the logic table above, this reflects - // the case (self.present & other.present). So, intersect self with - // other. - const auto &other_bitmap = other_iter->second; - self_bitmap &= other_bitmap; - if (self_bitmap.isEmpty()) { - // ...but if intersection is empty, remove it altogether. - roarings.erase(self_iter); - } - } - return *this; - } - - /** - * Compute the difference between the current bitmap and the provided - * bitmap, writing the result in the current bitmap. The provided bitmap - * is not modified. - */ - Roaring64Map &operator-=(const Roaring64Map &other) { - if (this == &other) { - // Subtracting *this from itself results in the empty map. - roarings.clear(); - return *this; - } - - // Logic table summarizing what to do when a given outer key is - // present vs. absent from self and other. - // - // self other (self - other) work to do - // -------------------------------------------- - // absent absent empty None - // absent present empty None - // present absent unchanged None - // present present empty or not Subtract other from self, but - // erase self if result is empty - // - // Because there is only work to do when a key is present in both 'self' - // and 'other', the main while loop ping-pongs back and forth until it - // finds the next key that is the same on both sides. - - auto self_iter = roarings.begin(); - auto other_iter = other.roarings.cbegin(); - - while (self_iter != roarings.end() && - other_iter != other.roarings.cend()) { - auto self_key = self_iter->first; - auto other_key = other_iter->first; - if (self_key < other_key) { - // Because self_key is < other_key, advance self_iter to the - // first point where self_key >= other_key (or end). - self_iter = roarings.lower_bound(other_key); - continue; - } - - if (self_key > other_key) { - // Because self_key is > other_key, advance other_iter to the - // first point where other_key >= self_key (or end). - other_iter = other.roarings.lower_bound(self_key); - continue; - } - - // Both sides have self_key. In the logic table above, this reflects - // the case (self.present & other.present). So subtract other from - // self. - auto &self_bitmap = self_iter->second; - const auto &other_bitmap = other_iter->second; - self_bitmap -= other_bitmap; - - if (self_bitmap.isEmpty()) { - // ...but if subtraction is empty, remove it altogether. - self_iter = roarings.erase(self_iter); - } else { - ++self_iter; - } - ++other_iter; - } - return *this; - } - - /** - * Compute the union of the current bitmap and the provided bitmap, - * writing the result in the current bitmap. The provided bitmap is not - * modified. - * - * See also the fastunion function to aggregate many bitmaps more quickly. - */ - Roaring64Map &operator|=(const Roaring64Map &other) { - if (this == &other) { - // ORing *this with itself is a no-op. - return *this; - } - - // Logic table summarizing what to do when a given outer key is - // present vs. absent from self and other. - // - // self other (self | other) work to do - // -------------------------------------------- - // absent absent empty None - // absent present not empty Copy other to self and set flags - // present absent unchanged None - // present present not empty self |= other - // - // Because there is only work to do when a key is present in 'other', - // the main for loop iterates over entries in 'other'. - - for (const auto &other_entry : other.roarings) { - const auto &other_bitmap = other_entry.second; - - // Try to insert other_bitmap into self at other_key. We take - // advantage of the fact that std::map::insert will not overwrite an - // existing entry. - auto insert_result = roarings.insert(other_entry); - auto self_iter = insert_result.first; - auto insert_happened = insert_result.second; - auto &self_bitmap = self_iter->second; - - if (insert_happened) { - // Key was not present in self, so insert was performed above. - // In the logic table above, this reflects the case - // (self.absent | other.present). Because the copy has already - // happened, thanks to the 'insert' operation above, we just - // need to set the copyOnWrite flag. - self_bitmap.setCopyOnWrite(copyOnWrite); - continue; - } - - // Both sides have self_key, and the insert was not performed. In - // the logic table above, this reflects the case - // (self.present & other.present). So OR other into self. - self_bitmap |= other_bitmap; - } - return *this; - } - - /** - * Compute the XOR of the current bitmap and the provided bitmap, writing - * the result in the current bitmap. The provided bitmap is not modified. - */ - Roaring64Map &operator^=(const Roaring64Map &other) { - if (this == &other) { - // XORing *this with itself results in the empty map. - roarings.clear(); - return *this; - } - - // Logic table summarizing what to do when a given outer key is - // present vs. absent from self and other. - // - // self other (self ^ other) work to do - // -------------------------------------------- - // absent absent empty None - // absent present non-empty Copy other to self and set flags - // present absent unchanged None - // present present empty or not XOR other into self, but erase self - // if result is empty. - // - // Because there is only work to do when a key is present in 'other', - // the main for loop iterates over entries in 'other'. - - for (const auto &other_entry : other.roarings) { - const auto &other_bitmap = other_entry.second; - - // Try to insert other_bitmap into self at other_key. We take - // advantage of the fact that std::map::insert will not overwrite an - // existing entry. - auto insert_result = roarings.insert(other_entry); - auto self_iter = insert_result.first; - auto insert_happened = insert_result.second; - auto &self_bitmap = self_iter->second; - - if (insert_happened) { - // Key was not present in self, so insert was performed above. - // In the logic table above, this reflects the case - // (self.absent ^ other.present). Because the copy has already - // happened, thanks to the 'insert' operation above, we just - // need to set the copyOnWrite flag. - self_bitmap.setCopyOnWrite(copyOnWrite); - continue; - } - - // Both sides have self_key, and the insert was not performed. In - // the logic table above, this reflects the case - // (self.present ^ other.present). So XOR other into self. - self_bitmap ^= other_bitmap; - - if (self_bitmap.isEmpty()) { - // ...but if intersection is empty, remove it altogether. - roarings.erase(self_iter); - } - } - return *this; - } - - /** - * Exchange the content of this bitmap with another. - */ - void swap(Roaring64Map &r) { roarings.swap(r.roarings); } - - /** - * Get the cardinality of the bitmap (number of elements). - * Throws std::length_error in the special case where the bitmap is full - * (cardinality() == 2^64). Check isFull() before calling to avoid - * exception. - */ - uint64_t cardinality() const { - if (isFull()) { -#if ROARING_EXCEPTIONS - throw std::length_error("bitmap is full, cardinality is 2^64, " - "unable to represent in a 64-bit integer"); -#else - ROARING_TERMINATE("bitmap is full, cardinality is 2^64, " - "unable to represent in a 64-bit integer"); -#endif - } - return std::accumulate( - roarings.cbegin(), roarings.cend(), (uint64_t)0, - [](uint64_t previous, - const std::pair &map_entry) { - return previous + map_entry.second.cardinality(); - }); - } - - /** - * Returns true if the bitmap is empty (cardinality is zero). - */ - bool isEmpty() const { - return std::all_of(roarings.cbegin(), roarings.cend(), - [](const std::pair &map_entry) { - return map_entry.second.isEmpty(); - }); - } - - /** - * Returns true if the bitmap is full (cardinality is max uint64_t + 1). - */ - bool isFull() const { - // only bother to check if map is fully saturated - // - // we put std::numeric_limits<>::max/min in parentheses - // to avoid a clash with the Windows.h header under Windows - return roarings.size() == - ((uint64_t)(std::numeric_limits::max)()) + 1 - ? std::all_of( - roarings.cbegin(), roarings.cend(), - [](const std::pair &roaring_map_entry) { - // roarings within map are saturated if cardinality - // is uint32_t max + 1 - return roaring_map_entry.second.cardinality() == - ((uint64_t) - (std::numeric_limits::max)()) + - 1; - }) - : false; - } - - /** - * Returns true if the bitmap is subset of the other. - */ - bool isSubset(const Roaring64Map &r) const { - for (const auto &map_entry : roarings) { - if (map_entry.second.isEmpty()) { - continue; - } - auto roaring_iter = r.roarings.find(map_entry.first); - if (roaring_iter == r.roarings.cend()) - return false; - else if (!map_entry.second.isSubset(roaring_iter->second)) - return false; - } - return true; - } - - /** - * Returns true if the bitmap is strict subset of the other. - * Throws std::length_error in the special case where the bitmap is full - * (cardinality() == 2^64). Check isFull() before calling to avoid exception. - */ - bool isStrictSubset(const Roaring64Map &r) const { - return isSubset(r) && cardinality() != r.cardinality(); - } - - /** - * Convert the bitmap to an array. Write the output to "ans", - * caller is responsible to ensure that there is enough memory - * allocated - * (e.g., ans = new uint32[mybitmap.cardinality()];) - */ - void toUint64Array(uint64_t *ans) const { - // Annoyingly, VS 2017 marks std::accumulate() as [[nodiscard]] - (void)std::accumulate(roarings.cbegin(), roarings.cend(), ans, - [](uint64_t *previous, - const std::pair &map_entry) { - for (uint32_t low_bits : map_entry.second) - *previous++ = - uniteBytes(map_entry.first, low_bits); - return previous; - }); - } - - /** - * Return true if the two bitmaps contain the same elements. - */ - bool operator==(const Roaring64Map &r) const { - // we cannot use operator == on the map because either side may contain - // empty Roaring Bitmaps - auto lhs_iter = roarings.cbegin(); - auto lhs_cend = roarings.cend(); - auto rhs_iter = r.roarings.cbegin(); - auto rhs_cend = r.roarings.cend(); - while (lhs_iter != lhs_cend && rhs_iter != rhs_cend) { - auto lhs_key = lhs_iter->first, rhs_key = rhs_iter->first; - const auto &lhs_map = lhs_iter->second, &rhs_map = rhs_iter->second; - if (lhs_map.isEmpty()) { - ++lhs_iter; - continue; - } - if (rhs_map.isEmpty()) { - ++rhs_iter; - continue; - } - if (!(lhs_key == rhs_key)) { - return false; - } - if (!(lhs_map == rhs_map)) { - return false; - } - ++lhs_iter; - ++rhs_iter; - } - while (lhs_iter != lhs_cend) { - if (!lhs_iter->second.isEmpty()) { - return false; - } - ++lhs_iter; - } - while (rhs_iter != rhs_cend) { - if (!rhs_iter->second.isEmpty()) { - return false; - } - ++rhs_iter; - } - return true; - } - - /** - * Computes the negation of the roaring bitmap within the half-open interval - * [min, max). Areas outside the interval are unchanged. - */ - void flip(uint64_t min, uint64_t max) { - if (min >= max) { - return; - } - flipClosed(min, max - 1); - } - - /** - * Computes the negation of the roaring bitmap within the closed interval - * [min, max]. Areas outside the interval are unchanged. - */ - void flipClosed(uint32_t min, uint32_t max) { - auto iter = roarings.begin(); - // Since min and max are uint32_t, highbytes(min or max) == 0. The inner - // bitmap we are looking for, if it exists, will be at the first slot of - // 'roarings'. If it does not exist, we have to create it. - if (iter == roarings.end() || iter->first != 0) { - iter = roarings.emplace_hint(iter, std::piecewise_construct, - std::forward_as_tuple(0), - std::forward_as_tuple()); - auto &bitmap = iter->second; - bitmap.setCopyOnWrite(copyOnWrite); - } - auto &bitmap = iter->second; - bitmap.flipClosed(min, max); - eraseIfEmpty(iter); - } - - /** - * Computes the negation of the roaring bitmap within the closed interval - * [min, max]. Areas outside the interval are unchanged. - */ - void flipClosed(uint64_t min, uint64_t max) { - if (min > max) { - return; - } - uint32_t start_high = highBytes(min); - uint32_t start_low = lowBytes(min); - uint32_t end_high = highBytes(max); - uint32_t end_low = lowBytes(max); - - // We put std::numeric_limits<>::max in parentheses to avoid a - // clash with the Windows.h header under Windows. - const uint32_t uint32_max = (std::numeric_limits::max)(); - - // Fill in any nonexistent slots with empty Roarings. This simplifies - // the logic below, allowing it to simply iterate over the map between - // 'start_high' and 'end_high' in a linear fashion. - auto current_iter = ensureRangePopulated(start_high, end_high); - - // If start and end land on the same inner bitmap, then we can do the - // whole operation in one call. - if (start_high == end_high) { - auto &bitmap = current_iter->second; - bitmap.flipClosed(start_low, end_low); - eraseIfEmpty(current_iter); - return; - } - - // Because start and end don't land on the same inner bitmap, - // we need to do this in multiple steps: - // 1. Partially flip the first bitmap in the closed interval - // [start_low, uint32_max] - // 2. Flip intermediate bitmaps completely: [0, uint32_max] - // 3. Partially flip the last bitmap in the closed interval - // [0, end_low] - - auto num_intermediate_bitmaps = end_high - start_high - 1; - - // 1. Partially flip the first bitmap. - { - auto &bitmap = current_iter->second; - bitmap.flipClosed(start_low, uint32_max); - auto temp = current_iter++; - eraseIfEmpty(temp); - } - - // 2. Flip intermediate bitmaps completely. - for (uint32_t i = 0; i != num_intermediate_bitmaps; ++i) { - auto &bitmap = current_iter->second; - bitmap.flipClosed(0, uint32_max); - auto temp = current_iter++; - eraseIfEmpty(temp); - } - - // 3. Partially flip the last bitmap. - auto &bitmap = current_iter->second; - bitmap.flipClosed(0, end_low); - eraseIfEmpty(current_iter); - } - - /** - * Remove run-length encoding even when it is more space efficient - * return whether a change was applied - */ - bool removeRunCompression() { - return std::accumulate( - roarings.begin(), roarings.end(), true, - [](bool previous, std::pair &map_entry) { - return map_entry.second.removeRunCompression() && previous; - }); - } - - /** - * Convert array and bitmap containers to run containers when it is more - * efficient; also convert from run containers when more space efficient. - * Returns true if the result has at least one run container. - * Additional savings might be possible by calling shrinkToFit(). - */ - bool runOptimize() { - return std::accumulate( - roarings.begin(), roarings.end(), true, - [](bool previous, std::pair &map_entry) { - return map_entry.second.runOptimize() && previous; - }); - } - - /** - * If needed, reallocate memory to shrink the memory usage. - * Returns the number of bytes saved. - */ - size_t shrinkToFit() { - size_t savedBytes = 0; - auto iter = roarings.begin(); - while (iter != roarings.cend()) { - if (iter->second.isEmpty()) { - // empty Roarings are 84 bytes - savedBytes += 88; - roarings.erase(iter++); - } else { - savedBytes += iter->second.shrinkToFit(); - iter++; - } - } - return savedBytes; - } - - /** - * Iterate over the bitmap elements in order(start from the smallest one) - * and call iterator once for every element until the iterator function - * returns false. To iterate over all values, the iterator function should - * always return true. - * - * The roaring_iterator64 parameter is a pointer to a function that - * returns bool (true means that the iteration should continue while false - * means that it should stop), and takes (uint64_t element, void* ptr) as - * inputs. - */ - void iterate(api::roaring_iterator64 iterator, void *ptr) const { - for (const auto &map_entry : roarings) { - bool should_continue = - roaring_iterate64(&map_entry.second.roaring, iterator, - uint64_t(map_entry.first) << 32, ptr); - if (!should_continue) { - break; - } - } - } - - /** - * Selects the value at index 'rank' in the bitmap, where the smallest value - * is at index 0. If 'rank' < cardinality(), returns true with *element set - * to the element of the specified rank. Otherwise, returns false and the - * contents of *element are unspecified. - */ - bool select(uint64_t rank, uint64_t *element) const { - for (const auto &map_entry : roarings) { - auto key = map_entry.first; - const auto &bitmap = map_entry.second; - - uint64_t sub_cardinality = bitmap.cardinality(); - if (rank < sub_cardinality) { - uint32_t low_bytes; - // Casting rank to uint32_t is safe because - // rank < sub_cardinality and sub_cardinality <= 2^32. - if (!bitmap.select((uint32_t)rank, &low_bytes)) { - ROARING_TERMINATE("Logic error: bitmap.select() " - "returned false despite rank < cardinality()"); - } - *element = uniteBytes(key, low_bytes); - return true; - } - rank -= sub_cardinality; - } - return false; - } - - /** - * Returns the number of integers that are smaller or equal to x. - */ - uint64_t rank(uint64_t x) const { - uint64_t result = 0; - // Find the first bitmap >= x's bucket. If that is the bucket x would be in, find it's rank in that bucket. - // Either way, we're left with a range of all buckets strictly smaller than x's bucket, add all their - // cardinalities together. - auto end = roarings.lower_bound(highBytes(x)); - if (end != roarings.cend() && end->first == highBytes(x)) { - result += end->second.rank(lowBytes(x)); - } - for (auto iter = roarings.cbegin(); iter != end; ++iter) { - result += iter->second.cardinality(); - } - return result; - } - - /** - * Returns the index of x in the set, index start from 0. - * If the set doesn't contain x , this function will return -1. - * The difference with rank function is that this function will return -1 - * when x isn't in the set, but the rank function will return a - * non-negative number. - */ - int64_t getIndex(uint64_t x) const { - int64_t index = 0; - auto roaring_destination = roarings.find(highBytes(x)); - if (roaring_destination != roarings.cend()) { - for (auto roaring_iter = roarings.cbegin(); - roaring_iter != roaring_destination; ++roaring_iter) { - index += roaring_iter->second.cardinality(); - } - auto low_idx = roaring_destination->second.getIndex(lowBytes(x)); - if (low_idx < 0) return -1; - index += low_idx; - return index; - } - return -1; - } - - /** - * Write a bitmap to a char buffer. This is meant to be compatible with - * the Java and Go versions. Returns how many bytes were written which - * should be getSizeInBytes(). - * - * Setting the portable flag to false enables a custom format that - * can save space compared to the portable format (e.g., for very - * sparse bitmaps). - */ - size_t write(char *buf, bool portable = true) const { - const char *orig = buf; - // push map size - uint64_t map_size = roarings.size(); - std::memcpy(buf, &map_size, sizeof(uint64_t)); - buf += sizeof(uint64_t); - std::for_each( - roarings.cbegin(), roarings.cend(), - [&buf, portable](const std::pair &map_entry) { - // push map key - std::memcpy(buf, &map_entry.first, sizeof(uint32_t)); - // ^-- Note: `*((uint32_t*)buf) = map_entry.first;` is undefined - - buf += sizeof(uint32_t); - // push map value Roaring - buf += map_entry.second.write(buf, portable); - }); - return buf - orig; - } - - /** - * Read a bitmap from a serialized version. This is meant to be compatible - * with the Java and Go versions. - * - * Setting the portable flag to false enable a custom format that - * can save space compared to the portable format (e.g., for very - * sparse bitmaps). - * - * This function is unsafe in the sense that if you provide bad data, many - * bytes could be read, possibly causing a buffer overflow. See also - * readSafe. - */ - static Roaring64Map read(const char *buf, bool portable = true) { - Roaring64Map result; - // get map size - uint64_t map_size; - std::memcpy(&map_size, buf, sizeof(uint64_t)); - buf += sizeof(uint64_t); - for (uint64_t lcv = 0; lcv < map_size; lcv++) { - // get map key - uint32_t key; - std::memcpy(&key, buf, sizeof(uint32_t)); - // ^-- Note: `uint32_t key = *((uint32_t*)buf);` is undefined - - buf += sizeof(uint32_t); - // read map value Roaring - Roaring read_var = Roaring::read(buf, portable); - // forward buffer past the last Roaring Bitmap - buf += read_var.getSizeInBytes(portable); - result.emplaceOrInsert(key, std::move(read_var)); - } - return result; - } - - /** - * Read a bitmap from a serialized version, reading no more than maxbytes - * bytes. This is meant to be compatible with the Java and Go versions. - * - * Setting the portable flag to false enable a custom format that can save - * space compared to the portable format (e.g., for very sparse bitmaps). - */ - static Roaring64Map readSafe(const char *buf, size_t maxbytes) { - if (maxbytes < sizeof(uint64_t)) { - ROARING_TERMINATE("ran out of bytes"); - } - Roaring64Map result; - uint64_t map_size; - std::memcpy(&map_size, buf, sizeof(uint64_t)); - buf += sizeof(uint64_t); - maxbytes -= sizeof(uint64_t); - for (uint64_t lcv = 0; lcv < map_size; lcv++) { - if(maxbytes < sizeof(uint32_t)) { - ROARING_TERMINATE("ran out of bytes"); - } - uint32_t key; - std::memcpy(&key, buf, sizeof(uint32_t)); - // ^-- Note: `uint32_t key = *((uint32_t*)buf);` is undefined - - buf += sizeof(uint32_t); - maxbytes -= sizeof(uint32_t); - // read map value Roaring - Roaring read_var = Roaring::readSafe(buf, maxbytes); - // forward buffer past the last Roaring Bitmap - size_t tz = read_var.getSizeInBytes(true); - buf += tz; - maxbytes -= tz; - result.emplaceOrInsert(key, std::move(read_var)); - } - return result; - } - - /** - * Return the number of bytes required to serialize this bitmap (meant to - * be compatible with Java and Go versions) - * - * Setting the portable flag to false enable a custom format that can save - * space compared to the portable format (e.g., for very sparse bitmaps). - */ - size_t getSizeInBytes(bool portable = true) const { - // start with, respectively, map size and size of keys for each map - // entry - return std::accumulate( - roarings.cbegin(), roarings.cend(), - sizeof(uint64_t) + roarings.size() * sizeof(uint32_t), - [=](size_t previous, - const std::pair &map_entry) { - // add in bytes used by each Roaring - return previous + map_entry.second.getSizeInBytes(portable); - }); - } - - static const Roaring64Map frozenView(const char *buf) { - // size of bitmap buffer and key - const size_t metadata_size = sizeof(size_t) + sizeof(uint32_t); - - Roaring64Map result; - - // get map size - uint64_t map_size; - memcpy(&map_size, buf, sizeof(uint64_t)); - buf += sizeof(uint64_t); - - for (uint64_t lcv = 0; lcv < map_size; lcv++) { - // pad to 32 bytes minus the metadata size - while (((uintptr_t)buf + metadata_size) % 32 != 0) buf++; - - // get bitmap size - size_t len; - memcpy(&len, buf, sizeof(size_t)); - buf += sizeof(size_t); - - // get map key - uint32_t key; - memcpy(&key, buf, sizeof(uint32_t)); - buf += sizeof(uint32_t); - - // read map value Roaring - const Roaring read = Roaring::frozenView(buf, len); - result.emplaceOrInsert(key, read); - - // forward buffer past the last Roaring Bitmap - buf += len; - } - return result; - } - - // As with serialized 64-bit bitmaps, 64-bit frozen bitmaps are serialized - // by concatenating one or more Roaring::write output buffers with the - // preceeding map key. Unlike standard bitmap serialization, frozen bitmaps - // must be 32-byte aligned and requires a buffer length to parse. As a - // result, each concatenated output of Roaring::writeFrozen is preceeded by - // padding, the buffer size (size_t), and the map key (uint32_t). The - // padding is used to ensure 32-byte alignment, but since it is followed by - // the buffer size and map key, it actually pads to `(x - sizeof(size_t) + - // sizeof(uint32_t)) mod 32` to leave room for the metadata. - void writeFrozen(char *buf) const { - // size of bitmap buffer and key - const size_t metadata_size = sizeof(size_t) + sizeof(uint32_t); - - // push map size - uint64_t map_size = roarings.size(); - memcpy(buf, &map_size, sizeof(uint64_t)); - buf += sizeof(uint64_t); - - for (auto &map_entry : roarings) { - size_t frozenSizeInBytes = map_entry.second.getFrozenSizeInBytes(); - - // pad to 32 bytes minus the metadata size - while (((uintptr_t)buf + metadata_size) % 32 != 0) buf++; - - // push bitmap size - memcpy(buf, &frozenSizeInBytes, sizeof(size_t)); - buf += sizeof(size_t); - - // push map key - memcpy(buf, &map_entry.first, sizeof(uint32_t)); - buf += sizeof(uint32_t); - - // push map value Roaring - map_entry.second.writeFrozen(buf); - buf += map_entry.second.getFrozenSizeInBytes(); - } - } - - size_t getFrozenSizeInBytes() const { - // size of bitmap size and map key - const size_t metadata_size = sizeof(size_t) + sizeof(uint32_t); - size_t ret = 0; - - // map size - ret += sizeof(uint64_t); - - for (auto &map_entry : roarings) { - // pad to 32 bytes minus the metadata size - while ((ret + metadata_size) % 32 != 0) ret++; - ret += metadata_size; - - // frozen bitmaps must be 32-byte aligned - ret += map_entry.second.getFrozenSizeInBytes(); - } - return ret; - } - - /** - * Computes the intersection between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - * - * Performance hint: if you are computing the intersection between several - * bitmaps, two-by-two, it is best to start with the smallest bitmap. - * Consider also using the operator &= to avoid needlessly creating - * many temporary bitmaps. - */ - Roaring64Map operator&(const Roaring64Map &o) const { - return Roaring64Map(*this) &= o; - } - - /** - * Computes the difference between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - */ - Roaring64Map operator-(const Roaring64Map &o) const { - return Roaring64Map(*this) -= o; - } - - /** - * Computes the union between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - */ - Roaring64Map operator|(const Roaring64Map &o) const { - return Roaring64Map(*this) |= o; - } - - /** - * Computes the symmetric union between two bitmaps and returns new bitmap. - * The current bitmap and the provided bitmap are unchanged. - */ - Roaring64Map operator^(const Roaring64Map &o) const { - return Roaring64Map(*this) ^= o; - } - - /** - * Whether or not we apply copy and write. - */ - void setCopyOnWrite(bool val) { - if (copyOnWrite == val) return; - copyOnWrite = val; - std::for_each(roarings.begin(), roarings.end(), - [=](std::pair &map_entry) { - map_entry.second.setCopyOnWrite(val); - }); - } - - /** - * Print the contents of the bitmap to stdout. - * Note: this method adds a final newline, but toString() does not. - */ - void printf() const { - auto sink = [](const std::string &s) { - fputs(s.c_str(), stdout); - }; - printToSink(sink); - sink("\n"); - } - - /** - * Print the contents of the bitmap into a string. - */ - std::string toString() const { - std::string result; - auto sink = [&result](const std::string &s) { - result += s; - }; - printToSink(sink); - return result; - } - - /** - * Whether or not copy and write is active. - */ - bool getCopyOnWrite() const { return copyOnWrite; } - - /** - * Computes the logical or (union) between "n" bitmaps (referenced by a - * pointer). - */ - static Roaring64Map fastunion(size_t n, const Roaring64Map **inputs) { - // The strategy here is to basically do a "group by" operation. - // We group the input roarings by key, do a 32-bit - // roaring_bitmap_or_many on each group, and collect the results. - // We accomplish the "group by" operation using a priority queue, which - // tracks the next key for each of our input maps. At each step, our - // algorithm takes the next subset of maps that share the same next key, - // runs roaring_bitmap_or_many on those bitmaps, and then advances the - // current_iter on all the affected entries and then repeats. - - // There is an entry in our priority queue for each of the 'n' inputs. - // For a given Roaring64Map, we look at its underlying 'roarings' - // std::map, and take its begin() and end(). This forms our half-open - // interval [current_iter, end_iter), which we keep in the priority - // queue as a pq_entry. These entries are updated (removed and then - // reinserted with the pq_entry.iterator field advanced by one step) as - // our algorithm progresses. But when a given interval becomes empty - // (i.e. pq_entry.iterator == pq_entry.end) it is not returned to the - // priority queue. - struct pq_entry { - roarings_t::const_iterator iterator; - roarings_t::const_iterator end; - }; - - // Custom comparator for the priority queue. - auto pq_comp = [](const pq_entry &lhs, const pq_entry &rhs) { - auto left_key = lhs.iterator->first; - auto right_key = rhs.iterator->first; - - // We compare in the opposite direction than normal because priority - // queues normally order from largest to smallest, but we want - // smallest to largest. - return left_key > right_key; - }; - - // Create and populate the priority queue. - std::priority_queue, decltype(pq_comp)> pq(pq_comp); - for (size_t i = 0; i < n; ++i) { - const auto &roarings = inputs[i]->roarings; - if (roarings.begin() != roarings.end()) { - pq.push({roarings.begin(), roarings.end()}); - } - } - - // A reusable vector that holds the pointers to the inner bitmaps that - // we pass to the underlying 32-bit fastunion operation. - std::vector group_bitmaps; - - // Summary of the algorithm: - // 1. While the priority queue is not empty: - // A. Get its lowest key. Call this group_key - // B. While the lowest entry in the priority queue has a key equal to - // group_key: - // 1. Remove this entry (the pair {current_iter, end_iter}) from - // the priority queue. - // 2. Add the bitmap pointed to by current_iter to a list of - // 32-bit bitmaps to process. - // 3. Advance current_iter. Now it will point to a bitmap entry - // with some key greater than group_key (or it will point to - // end()). - // 4. If current_iter != end_iter, reinsert the pair into the - // priority queue. - // C. Invoke the 32-bit roaring_bitmap_or_many() and add to result - Roaring64Map result; - while (!pq.empty()) { - // Find the next key (the lowest key) in the priority queue. - auto group_key = pq.top().iterator->first; - - // The purpose of the inner loop is to gather all the inner bitmaps - // that share "group_key" into "group_bitmaps" so that they can be - // fed to roaring_bitmap_or_many(). While we are doing this, we - // advance those iterators to their next value and reinsert them - // into the priority queue (unless they reach their end). - group_bitmaps.clear(); - while (!pq.empty()) { - auto candidate_current_iter = pq.top().iterator; - auto candidate_end_iter = pq.top().end; - - auto candidate_key = candidate_current_iter->first; - const auto &candidate_bitmap = candidate_current_iter->second; - - // This element will either be in the group (having - // key == group_key) or it will not be in the group (having - // key > group_key). (Note it cannot have key < group_key - // because of the ordered nature of the priority queue itself - // and the ordered nature of all the underlying roaring maps). - if (candidate_key != group_key) { - // This entry, and (thanks to the nature of the priority - // queue) all other entries as well, are all greater than - // group_key, so we're done collecting elements for the - // current group. Because of the way this loop was written, - // the group will will always contain at least one element. - break; - } - - group_bitmaps.push_back(&candidate_bitmap.roaring); - // Remove this entry from the priority queue. Note this - // invalidates pq.top() so make sure you don't have any dangling - // references to it. - pq.pop(); - - // Advance 'candidate_current_iter' and insert a new entry - // {candidate_current_iter, candidate_end_iter} into the - // priority queue (unless it has reached its end). - ++candidate_current_iter; - if (candidate_current_iter != candidate_end_iter) { - pq.push({candidate_current_iter, candidate_end_iter}); - } - } - - // Use the fast inner union to combine these. - auto *inner_result = roaring_bitmap_or_many(group_bitmaps.size(), - group_bitmaps.data()); - // Insert the 32-bit result at end of the 'roarings' map of the - // result we are building. - result.roarings.insert(result.roarings.end(), - std::make_pair(group_key, Roaring(inner_result))); - } - return result; - } - - friend class Roaring64MapSetBitForwardIterator; - friend class Roaring64MapSetBitBiDirectionalIterator; - typedef Roaring64MapSetBitForwardIterator const_iterator; - typedef Roaring64MapSetBitBiDirectionalIterator const_bidirectional_iterator; - - /** - * Returns an iterator that can be used to access the position of the set - * bits. The running time complexity of a full scan is proportional to the - * number of set bits: be aware that if you have long strings of 1s, this - * can be very inefficient. - * - * It can be much faster to use the toArray method if you want to - * retrieve the set bits. - */ - const_iterator begin() const; - - /** - * A bogus iterator that can be used together with begin() - * for constructions such as: for (auto i = b.begin(); * i!=b.end(); ++i) {} - */ - const_iterator end() const; - -private: - typedef std::map roarings_t; - roarings_t roarings{}; // The empty constructor silences warnings from pedantic static analyzers. - bool copyOnWrite{false}; - static constexpr uint32_t highBytes(const uint64_t in) { return uint32_t(in >> 32); } - static constexpr uint32_t lowBytes(const uint64_t in) { return uint32_t(in); } - static constexpr uint64_t uniteBytes(const uint32_t highBytes, - const uint32_t lowBytes) { - return (uint64_t(highBytes) << 32) | uint64_t(lowBytes); - } - // this is needed to tolerate gcc's C++11 libstdc++ lacking emplace - // prior to version 4.8 - void emplaceOrInsert(const uint32_t key, const Roaring &value) { -#if defined(__GLIBCXX__) && __GLIBCXX__ < 20130322 - roarings.insert(std::make_pair(key, value)); -#else - roarings.emplace(std::make_pair(key, value)); -#endif - } - - void emplaceOrInsert(const uint32_t key, Roaring &&value) { -#if defined(__GLIBCXX__) && __GLIBCXX__ < 20130322 - roarings.insert(std::make_pair(key, std::move(value))); -#else - roarings.emplace(key, std::move(value)); -#endif - } - - /* - * Look up 'key' in the 'roarings' map. If it does not exist, create it. - * Also, set its copyOnWrite flag to 'copyOnWrite'. Then return a reference - * to the (already existing or newly created) inner bitmap. - */ - Roaring &lookupOrCreateInner(uint32_t key) { - auto &bitmap = roarings[key]; - bitmap.setCopyOnWrite(copyOnWrite); - return bitmap; - } - - /** - * Prints the contents of the bitmap to a caller-provided sink function. - */ - void printToSink(const std::function &sink) const { - sink("{"); - - // Storage for snprintf. Big enough to store the decimal representation - // of the largest uint64_t value and trailing \0. - char buffer[32]; - const char *separator = ""; - // Reusable, and therefore avoids many repeated heap allocations. - std::string callback_string; - for (const auto &entry : roarings) { - auto high_bits = entry.first; - const auto &bitmap = entry.second; - for (const auto low_bits : bitmap) { - auto value = uniteBytes(high_bits, low_bits); - snprintf(buffer, sizeof(buffer), "%" PRIu64, value); - callback_string = separator; - callback_string.append(buffer); - sink(callback_string); - separator = ","; - } - } - sink("}"); - } - - /** - * Ensures that every key in the closed interval [start_high, end_high] - * refers to a Roaring bitmap rather being an empty slot. Inserts empty - * Roaring bitmaps if necessary. The interval must be valid and non-empty. - * Returns an iterator to the bitmap at start_high. - */ - roarings_t::iterator ensureRangePopulated(uint32_t start_high, - uint32_t end_high) { - if (start_high > end_high) { - ROARING_TERMINATE("Logic error: start_high > end_high"); - } - // next_populated_iter points to the first entry in the outer map with - // key >= start_high, or end(). - auto next_populated_iter = roarings.lower_bound(start_high); - - // Use uint64_t to avoid an infinite loop when end_high == uint32_max. - roarings_t::iterator start_iter{}; // Definitely assigned in loop. - for (uint64_t slot = start_high; slot <= end_high; ++slot) { - roarings_t::iterator slot_iter; - if (next_populated_iter != roarings.end() && - next_populated_iter->first == slot) { - // 'slot' index has caught up to next_populated_iter. - // Note it here and advance next_populated_iter. - slot_iter = next_populated_iter++; - } else { - // 'slot' index has not yet caught up to next_populated_iter. - // Make a fresh entry {key = 'slot', value = Roaring()}, insert - // it just prior to next_populated_iter, and set its copy - // on write flag. We take pains to use emplace_hint and - // piecewise_construct to minimize effort. - slot_iter = roarings.emplace_hint( - next_populated_iter, std::piecewise_construct, - std::forward_as_tuple(uint32_t(slot)), - std::forward_as_tuple()); - auto &bitmap = slot_iter->second; - bitmap.setCopyOnWrite(copyOnWrite); - } - - // Make a note of the iterator of the starting slot. It will be - // needed for the return value. - if (slot == start_high) { - start_iter = slot_iter; - } - } - return start_iter; - } - - /** - * Erases the entry pointed to by 'iter' from the 'roarings' map. Warning: - * this invalidates 'iter'. - */ - void eraseIfEmpty(roarings_t::iterator iter) { - const auto &bitmap = iter->second; - if (bitmap.isEmpty()) { - roarings.erase(iter); - } - } -}; - -/** - * Used to go through the set bits. Not optimally fast, but convenient. - */ -class Roaring64MapSetBitForwardIterator { -public: - typedef std::forward_iterator_tag iterator_category; - typedef uint64_t *pointer; - typedef uint64_t &reference; - typedef uint64_t value_type; - typedef int64_t difference_type; - typedef Roaring64MapSetBitForwardIterator type_of_iterator; - - /** - * Provides the location of the set bit. - */ - value_type operator*() const { - return Roaring64Map::uniteBytes(map_iter->first, i.current_value); - } - - bool operator<(const type_of_iterator &o) const { - if (map_iter == map_end) return false; - if (o.map_iter == o.map_end) return true; - return **this < *o; - } - - bool operator<=(const type_of_iterator &o) const { - if (o.map_iter == o.map_end) return true; - if (map_iter == map_end) return false; - return **this <= *o; - } - - bool operator>(const type_of_iterator &o) const { - if (o.map_iter == o.map_end) return false; - if (map_iter == map_end) return true; - return **this > *o; - } - - bool operator>=(const type_of_iterator &o) const { - if (map_iter == map_end) return true; - if (o.map_iter == o.map_end) return false; - return **this >= *o; - } - - type_of_iterator &operator++() { // ++i, must returned inc. value - if (i.has_value == true) roaring_advance_uint32_iterator(&i); - while (!i.has_value) { - map_iter++; - if (map_iter == map_end) return *this; - roaring_init_iterator(&map_iter->second.roaring, &i); - } - return *this; - } - - type_of_iterator operator++(int) { // i++, must return orig. value - Roaring64MapSetBitForwardIterator orig(*this); - roaring_advance_uint32_iterator(&i); - while (!i.has_value) { - map_iter++; - if (map_iter == map_end) return orig; - roaring_init_iterator(&map_iter->second.roaring, &i); - } - return orig; - } - - bool move(const value_type& x) { - map_iter = p.lower_bound(Roaring64Map::highBytes(x)); - if (map_iter != p.cend()) { - roaring_init_iterator(&map_iter->second.roaring, &i); - if (map_iter->first == Roaring64Map::highBytes(x)) { - if (roaring_move_uint32_iterator_equalorlarger(&i, Roaring64Map::lowBytes(x))) - return true; - map_iter++; - if (map_iter == map_end) return false; - roaring_init_iterator(&map_iter->second.roaring, &i); - } - return true; - } - return false; - } - - bool operator==(const Roaring64MapSetBitForwardIterator &o) const { - if (map_iter == map_end && o.map_iter == o.map_end) return true; - if (o.map_iter == o.map_end) return false; - return **this == *o; - } - - bool operator!=(const Roaring64MapSetBitForwardIterator &o) const { - if (map_iter == map_end && o.map_iter == o.map_end) return false; - if (o.map_iter == o.map_end) return true; - return **this != *o; - } - - Roaring64MapSetBitForwardIterator &operator=(const Roaring64MapSetBitForwardIterator& r) { - map_iter = r.map_iter; - map_end = r.map_end; - i = r.i; - return *this; - } - - Roaring64MapSetBitForwardIterator(const Roaring64MapSetBitForwardIterator& r) - : p(r.p), - map_iter(r.map_iter), - map_end(r.map_end), - i(r.i) - {} - - Roaring64MapSetBitForwardIterator(const Roaring64Map &parent, - bool exhausted = false) - : p(parent.roarings), map_end(parent.roarings.cend()) { - if (exhausted || parent.roarings.empty()) { - map_iter = parent.roarings.cend(); - } else { - map_iter = parent.roarings.cbegin(); - roaring_init_iterator(&map_iter->second.roaring, &i); - while (!i.has_value) { - map_iter++; - if (map_iter == map_end) return; - roaring_init_iterator(&map_iter->second.roaring, &i); - } - } - } - -protected: - const std::map& p; - std::map::const_iterator map_iter{}; // The empty constructor silences warnings from pedantic static analyzers. - std::map::const_iterator map_end{}; // The empty constructor silences warnings from pedantic static analyzers. - api::roaring_uint32_iterator_t i{}; // The empty constructor silences warnings from pedantic static analyzers. -}; - -class Roaring64MapSetBitBiDirectionalIterator final :public Roaring64MapSetBitForwardIterator { -public: - explicit Roaring64MapSetBitBiDirectionalIterator(const Roaring64Map &parent, - bool exhausted = false) - : Roaring64MapSetBitForwardIterator(parent, exhausted), map_begin(parent.roarings.cbegin()) - {} - - Roaring64MapSetBitBiDirectionalIterator &operator=(const Roaring64MapSetBitForwardIterator& r) { - *(Roaring64MapSetBitForwardIterator*)this = r; - return *this; - } - - Roaring64MapSetBitBiDirectionalIterator& operator--() { // --i, must return dec.value - if (map_iter == map_end) { - --map_iter; - roaring_init_iterator_last(&map_iter->second.roaring, &i); - if (i.has_value) return *this; - } - - roaring_previous_uint32_iterator(&i); - while (!i.has_value) { - if (map_iter == map_begin) return *this; - map_iter--; - roaring_init_iterator_last(&map_iter->second.roaring, &i); - } - return *this; - } - - Roaring64MapSetBitBiDirectionalIterator operator--(int) { // i--, must return orig. value - Roaring64MapSetBitBiDirectionalIterator orig(*this); - if (map_iter == map_end) { - --map_iter; - roaring_init_iterator_last(&map_iter->second.roaring, &i); - return orig; - } - - roaring_previous_uint32_iterator(&i); - while (!i.has_value) { - if (map_iter == map_begin) return orig; - map_iter--; - roaring_init_iterator_last(&map_iter->second.roaring, &i); - } - return orig; - } - -protected: - std::map::const_iterator map_begin; -}; - -inline Roaring64MapSetBitForwardIterator Roaring64Map::begin() const { - return Roaring64MapSetBitForwardIterator(*this); -} - -inline Roaring64MapSetBitForwardIterator Roaring64Map::end() const { - return Roaring64MapSetBitForwardIterator(*this, true); -} - -} // namespace roaring - -#endif /* INCLUDE_ROARING_64_MAP_HH_ */ -/* end file cpp/roaring64map.hh */ diff --git a/croaring-sys/Cargo.toml b/croaring-sys/Cargo.toml deleted file mode 100644 index 8f4b5a5..0000000 --- a/croaring-sys/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "croaring-sys" -version = "1.1.0" -edition = "2021" -authors = ["croaring-rs developers"] -license = "Apache-2.0" -repository = "https://github.com/RoaringBitmap/croaring-rs.git" -readme = "../README.md" -documentation = "https://docs.rs/croaring-sys" -build = "build.rs" -description = "Raw bindings to CRoaring" - -[features] -default = [] -# This feature is now a no-op, but we keep it for backwards compatibility -# pre-built bindgen is _always_ used -buildtime_bindgen = [] - -[lib] -doctest = false - -[dependencies] - -[build-dependencies] -cc = "1" diff --git a/croaring-sys/build.rs b/croaring-sys/build.rs deleted file mode 100644 index 1a2d918..0000000 --- a/croaring-sys/build.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::env; -use std::path::PathBuf; - -fn main() { - println!("cargo:rerun-if-changed=CRoaring"); - println!("cargo:rerun-if-env-changed=ROARING_ARCH"); - - let mut build = cc::Build::new(); - let compiler = build.get_compiler(); - build.file("CRoaring/roaring.c"); - - // TODO: - if (env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows") { - println!("cargo::warning=Disabling AVX"); - build.define("ROARING_DISABLE_AVX", "1"); - } - - if let Ok(target_arch) = env::var("ROARING_ARCH") { - build.flag_if_supported(&format!("-march={target_arch}")); - } - - build.flag_if_supported("-Wno-unused-function"); - println!("cargo:warning=compiler {compiler:#?}"); - println!("cargo:warning=build: {build:#?}"); - build.compile("roaring"); -} diff --git a/croaring-sys/src/lib.rs b/croaring-sys/src/lib.rs deleted file mode 100644 index de17745..0000000 --- a/croaring-sys/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(rustdoc::bare_urls)] - -include!("../CRoaring/bindgen_bundled_version.rs"); diff --git a/croaring/Cargo.toml b/croaring/Cargo.toml deleted file mode 100644 index 3eea104..0000000 --- a/croaring/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "croaring" -version = "1.0.1" -edition = "2021" -authors = ["croaring-rs developers"] -license = "Apache-2.0" -description = "Rust wrapper for CRoaring" -repository = "https://github.com/RoaringBitmap/croaring-rs.git" -readme = "../README.md" -keywords = ["RoaringBitmap", "croaring", "bitmap"] -documentation = "https://docs.rs/croaring" - -[features] -default = [] -# This feature is now a no-op, but we keep it for backwards compatibility -# pre-built bindgen is _always_ used -buildtime_bindgen = [] - -[dev-dependencies] -proptest = "1" -roaring = "0.10" -criterion = { version = "0.5", features = ["html_reports"] } - -[dependencies] -ffi = { package = "croaring-sys", path = "../croaring-sys", version = "1.1.0" } -byteorder = "1.4.3" - -[[bench]] -name = "benches" -harness = false - -[[bench]] -name = "performance_comparison" -harness = false diff --git a/croaring/benches/benches.rs b/croaring/benches/benches.rs deleted file mode 100644 index 6bfba71..0000000 --- a/croaring/benches/benches.rs +++ /dev/null @@ -1,274 +0,0 @@ -use criterion::{ - black_box, criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput, -}; - -use croaring::{Bitmap, Portable}; - -fn new(c: &mut Criterion) { - c.bench_function("new", |b| b.iter(Bitmap::new)); - - c.bench_function("with_capacity", |b| { - b.iter(|| Bitmap::with_container_capacity(10_000)) - }); -} - -fn add(c: &mut Criterion) { - c.bench_function("add", |b| { - let mut bitmap = Bitmap::new(); - - b.iter(|| bitmap.add(10000)); - }); -} - -fn add_many(c: &mut Criterion) { - c.bench_function("add_many", |b| { - let mut bitmap = Bitmap::new(); - let int_slice = &[10, 100, 10_000, 1_000_000, 10_000_000]; - - b.iter(|| bitmap.add_many(black_box(int_slice))); - }); -} - -fn remove(c: &mut Criterion) { - c.bench_function("remove", |b| { - let mut bitmap = Bitmap::new(); - - b.iter(|| bitmap.remove(10000)); - }); -} - -fn contains(c: &mut Criterion) { - let mut group = c.benchmark_group("contains"); - group.bench_function("true", |b| { - let mut bitmap = Bitmap::new(); - - bitmap.add(5); - - b.iter(|| bitmap.contains(5)); - }); - - group.bench_function("false", |b| { - let bitmap = Bitmap::new(); - - b.iter(|| bitmap.contains(5)); - }); -} - -fn cardinality(c: &mut Criterion) { - let mut group = c.benchmark_group("cardinality"); - - for &size in &[100_000, 1_000_000] { - group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, &size| { - let bitmap: Bitmap = (0..size).collect(); - - b.iter(|| bitmap.cardinality()); - }); - } -} - -fn binops(c: &mut Criterion) { - let bitmap1 = Bitmap::from([500, 1000]); - let bitmap2 = Bitmap::from([1000, 2000]); - - macro_rules! bench_op { - ($new:ident, $inplace:ident) => {{ - let mut group = c.benchmark_group(stringify!($new)); - - group.bench_function("new", |b| { - b.iter(|| bitmap1.$new(&bitmap2)); - }); - group.bench_function("inplace", |b| { - b.iter_batched( - || bitmap1.clone(), - |mut dst_bitmap| dst_bitmap.$inplace(&bitmap2), - BatchSize::SmallInput, - ); - }); - - group - }}; - ($new:ident, $inplace:ident, $fast:ident) => {{ - let mut group = bench_op!($new, $inplace); - - group.bench_function("fast", |b| { - b.iter(|| Bitmap::$fast(&[&bitmap1, &bitmap2])); - }); - - group - }}; - ($new:ident, $inplace:ident, $fast:ident, $fast_heap:ident) => {{ - let mut group = bench_op!($new, $inplace, $fast); - - group.bench_function("fast_heap", |b| { - b.iter(|| Bitmap::$fast_heap(&[&bitmap1, &bitmap2])); - }); - - group - }}; - } - - bench_op!(and, and_inplace); - bench_op!(or, or_inplace, fast_or, fast_or_heap); - bench_op!(xor, xor_inplace, fast_xor); - bench_op!(andnot, andnot_inplace); -} - -fn flip(c: &mut Criterion) { - let bitmap = Bitmap::of(&[1]); - - let mut group = c.benchmark_group("flip"); - group.bench_function("new", |b| { - b.iter(|| bitmap.flip(1..3)); - }); - group.bench_function("inplace", |b| { - b.iter_batched( - || bitmap.clone(), - |mut bitmap| bitmap.flip_inplace(1..3), - BatchSize::SmallInput, - ); - }); -} - -fn to_vec(c: &mut Criterion) { - c.bench_function("to_vec", |b| { - let bitmap = Bitmap::of(&[1, 2, 3]); - b.iter(|| bitmap.to_vec()); - }); -} - -fn get_serialized_size_in_bytes(c: &mut Criterion) { - c.bench_function("get_serialized_size_in_bytes", |b| { - let bitmap = Bitmap::of(&[1, 2, 3]); - b.iter(|| bitmap.get_serialized_size_in_bytes::()); - }); -} - -fn is_empty(c: &mut Criterion) { - let mut group = c.benchmark_group("is_empty"); - group.bench_function("true", |b| { - let bitmap = Bitmap::new(); - b.iter(|| bitmap.is_empty()); - }); - group.bench_function("false", |b| { - let bitmap = Bitmap::of(&[1000]); - b.iter(|| bitmap.is_empty()); - }); -} - -fn of(c: &mut Criterion) { - c.bench_function("of", |b| { - b.iter(|| Bitmap::of(black_box(&[10, 20, 30, 40]))); - }); -} - -fn serialize(c: &mut Criterion) { - let mut group = c.benchmark_group("serialize"); - for &size in &[100_000, 1_000_000] { - let bitmap: Bitmap = (1..size).collect(); - group.throughput(Throughput::Elements(size.into())); - group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| { - b.iter(|| bitmap.serialize::()); - }); - } -} - -fn deserialize(c: &mut Criterion) { - let mut group = c.benchmark_group("deserialize"); - for &size in &[100_000, 1_000_000] { - let bitmap: Bitmap = (1..size).collect(); - let serialized_buffer = bitmap.serialize::(); - group.throughput(Throughput::Elements(size.into())); - group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| { - b.iter(|| Bitmap::deserialize::(&serialized_buffer)); - }); - } -} - -fn bulk_new(c: &mut Criterion) { - const N: u32 = 1_000_000; - - let mut group = c.benchmark_group("bulk_new"); - group.throughput(Throughput::Elements(N.into())); - let range = black_box(0..N); - group.bench_function("range_new", |b| { - b.iter(|| Bitmap::from_range(range.clone())); - }); - group.bench_function("collect", |b| { - b.iter(|| Bitmap::from_iter(range.clone())); - }); - group.bench_function("slice_init", |b| { - let bulk_data = black_box(range.clone().collect::>()); - b.iter(|| Bitmap::of(&bulk_data)); - }); - group.bench_function("sequential_adds", |b| { - b.iter(|| { - let mut bitmap = Bitmap::new(); - for i in range.clone() { - bitmap.add(i); - } - bitmap - }); - }); - - group.finish(); -} - -fn random_iter(c: &mut Criterion) { - const N: u32 = 5_000; - // Clamp values so we get some re-use of containers - const MAX: u32 = 8 * (u16::MAX as u32 + 1); - - let mut group = c.benchmark_group("random_iter"); - group.throughput(Throughput::Elements(N.into())); - - let rand_iter = { - const MULTIPLIER: u32 = 742938285; - const MODULUS: u32 = (1 << 31) - 1; - // Super simple LCG iterator - let mut z = 20170705; // seed - std::iter::from_fn(move || { - z = (MULTIPLIER * z) % MODULUS; - Some(z % MAX) - }) - }; - - group.bench_function("random_adds", |b| { - b.iter(|| { - let mut bitmap = Bitmap::new(); - rand_iter.clone().take(N as usize).for_each(|item| { - bitmap.add(item); - }); - bitmap - }); - }); - group.bench_function("random_from_iter", |b| { - b.iter(|| Bitmap::from_iter(rand_iter.clone().take(N as usize))); - }); - group.bench_function("collect_to_vec_first", |b| { - b.iter(|| { - let vec = rand_iter.clone().take(N as usize).collect::>(); - Bitmap::of(&vec) - }); - }); -} - -criterion_group!( - benches, - new, - add, - add_many, - remove, - contains, - cardinality, - binops, - flip, - to_vec, - get_serialized_size_in_bytes, - is_empty, - of, - serialize, - deserialize, - bulk_new, - random_iter, -); -criterion_main!(benches); diff --git a/croaring/benches/performance_comparison.rs b/croaring/benches/performance_comparison.rs deleted file mode 100644 index 68dab72..0000000 --- a/croaring/benches/performance_comparison.rs +++ /dev/null @@ -1,213 +0,0 @@ -use croaring::Bitmap; -use roaring::RoaringBitmap; - -use criterion::measurement::Measurement; -use criterion::{ - black_box, criterion_group, criterion_main, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, -}; - -fn compare( - group: &mut BenchmarkGroup<'_, M>, - mut prep1: Prep1, - mut prep2: Prep2, - mut bench1: Bench1, - mut bench2: Bench2, -) where - Prep1: FnMut() -> In1, - Prep2: FnMut() -> In2, - Bench1: FnMut(In1) -> Out1, - Bench2: FnMut(In2) -> Out2, - M: Measurement, -{ - group.bench_function("croaring", |b| { - b.iter_batched(|| prep1(), |x| bench1(x), BatchSize::SmallInput); - }); - group.bench_function("roaring-rs", |b| { - b.iter_batched(|| prep2(), |x| bench2(x), BatchSize::SmallInput); - }); -} - -fn roaring_bitmap_of(items: &[u32]) -> RoaringBitmap { - items.iter().copied().collect() -} - -fn new(c: &mut Criterion) { - compare( - &mut c.benchmark_group("new"), - || (), - || (), - |()| Bitmap::new(), - |()| RoaringBitmap::new(), - ); -} - -fn create_and_add_one(c: &mut Criterion) { - compare( - &mut c.benchmark_group("add_one"), - || (), - || (), - |()| { - let mut bitmap = Bitmap::new(); - bitmap.add(black_box(1)); - bitmap - }, - |()| { - let mut bitmap = RoaringBitmap::new(); - bitmap.insert(black_box(1)); - bitmap - }, - ); -} - -const SIMPLE_ITEMS: &[u32] = &[1, 10, 100, 1_000, 10_000, 100_000, 1_000_000]; - -fn add(c: &mut Criterion) { - let mut group = c.benchmark_group("add_several"); - compare( - &mut group, - Bitmap::new, - RoaringBitmap::new, - |mut bitmap: Bitmap| { - for &item in SIMPLE_ITEMS { - bitmap.add(black_box(item)); - } - bitmap - }, - |mut bitmap: RoaringBitmap| { - for &item in SIMPLE_ITEMS { - bitmap.insert(black_box(item)); - } - bitmap - }, - ); - group.bench_function("croaring many", |b| { - b.iter_batched( - Bitmap::new, - |mut bitmap| { - bitmap.add_many(black_box(SIMPLE_ITEMS)); - bitmap - }, - BatchSize::SmallInput, - ); - }); -} - -fn remove(c: &mut Criterion) { - compare( - &mut c.benchmark_group("remove"), - || Bitmap::of(SIMPLE_ITEMS), - || roaring_bitmap_of(SIMPLE_ITEMS), - |mut bitmap: Bitmap| bitmap.remove(black_box(1_000_000)), - |mut bitmap: RoaringBitmap| bitmap.remove(black_box(1_000_000)), - ); -} - -fn contains(c: &mut Criterion) { - compare( - &mut c.benchmark_group("contains"), - || Bitmap::of(&[1]), - || roaring_bitmap_of(&[1]), - |bitmap: Bitmap| bitmap.contains(black_box(1)), - |bitmap: RoaringBitmap| bitmap.contains(black_box(1)), - ) -} - -fn cardinality(c: &mut Criterion) { - let mut group = c.benchmark_group("cardinality"); - - for &size in &[100_000, 1_000_000] { - group.bench_with_input(BenchmarkId::new("croaring", size), &size, |b, &size| { - b.iter_batched( - || Bitmap::from_iter(1..size), - |bitmap: Bitmap| bitmap.cardinality(), - BatchSize::SmallInput, - ); - }); - group.bench_with_input(BenchmarkId::new("roaring-rs", size), &size, |b, &size| { - b.iter_batched( - || RoaringBitmap::from_iter(1..size), - |bitmap: RoaringBitmap| bitmap.len(), - BatchSize::SmallInput, - ); - }); - } -} - -fn binops(c: &mut Criterion) { - let range1 = 1..100; - let range2 = 100..200; - - let gen_ours = || { - ( - Bitmap::from_iter(range1.clone()), - Bitmap::from_iter(range2.clone()), - ) - }; - let gen_theirs = || { - ( - RoaringBitmap::from_iter(range1.clone()), - RoaringBitmap::from_iter(range2.clone()), - ) - }; - - macro_rules! comp_op { - ($new1:ident, $inplace1:ident, $new2:expr, $inplace2:expr $(,)?) => {{ - compare( - &mut c.benchmark_group(concat!(stringify!($new1), "_new")), - gen_ours, - gen_theirs, - |(bm1, bm2)| bm1.$new1(&bm2), - |(bm1, bm2)| $new2(&bm1, &bm2), - ); - compare( - &mut c.benchmark_group(concat!(stringify!($new1), "_inplace")), - gen_ours, - gen_theirs, - |(mut bm1, bm2)| bm1.$inplace1(&bm2), - |(mut bm1, bm2)| $inplace2(&mut bm1, &bm2), - ); - }}; - } - - comp_op!( - and, - and_inplace, - std::ops::BitAnd::bitand, - std::ops::BitAndAssign::bitand_assign, - ); - comp_op!( - or, - or_inplace, - std::ops::BitOr::bitor, - std::ops::BitOrAssign::bitor_assign, - ); - comp_op!( - xor, - xor_inplace, - std::ops::BitXor::bitxor, - std::ops::BitXorAssign::bitxor_assign, - ); -} - -fn iter(c: &mut Criterion) { - compare( - &mut c.benchmark_group("iter"), - || Bitmap::from_iter(1..10_000), - || RoaringBitmap::from_iter(1..10_000), - |bitmap: Bitmap| assert_eq!(bitmap.iter().fold(0, |a, b| a + b), 49995000), - |bitmap: RoaringBitmap| assert_eq!(bitmap.iter().fold(0, |a, b| a + b), 49995000), - ); -} - -criterion_group!( - benches, - new, - create_and_add_one, - add, - remove, - contains, - cardinality, - binops, - iter -); -criterion_main!(benches); diff --git a/croaring/src/bitmap/imp.rs b/croaring/src/bitmap/imp.rs deleted file mode 100644 index 3ad2bdb..0000000 --- a/croaring/src/bitmap/imp.rs +++ /dev/null @@ -1,1556 +0,0 @@ -use crate::Bitset; -use ffi::roaring_bitmap_t; -use std::convert::TryInto; -use std::ffi::{c_void, CStr}; -use std::ops::{Bound, RangeBounds}; -use std::{mem, ptr}; - -use super::serialization::{Deserializer, Serializer}; -use super::{Bitmap, Statistics}; - -impl Bitmap { - #[inline] - #[allow(clippy::assertions_on_constants)] - pub(crate) unsafe fn take_heap(p: *mut roaring_bitmap_t) -> Self { - // Based heavily on the `roaring.hh` cpp header from croaring - - assert!(!p.is_null()); - let result = Self { bitmap: *p }; - // This depends somewhat heavily on the implementation of croaring, - // In particular, that `roaring_bitmap_t` doesn't store any pointers into itself - // (it can be moved safely), and can be freed with `free`, without freeing the underlying - // containers and auxiliary data. Ensure this is still valid every time we update - // the version of croaring. - const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 2 && ffi::ROARING_VERSION_MINOR == 0); - ffi::roaring_free(p.cast::()); - result - } - - /// Creates a new bitmap (initially empty) - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::new(); - /// - /// assert!(bitmap.is_empty()); - /// ``` - #[inline] - #[must_use] - pub fn new() -> Self { - Self::with_container_capacity(0) - } - - /// Creates a new bitmap (initially empty) with a provided - /// container-storage capacity (it is a performance hint). - /// - /// Note that this is in units of containers, not values: each container holds up to - /// 2^16 values. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::with_container_capacity(1_000); - /// - /// assert!(bitmap.is_empty()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_init_with_capacity")] - #[must_use] - pub fn with_container_capacity(capacity: u32) -> Self { - let mut bitmap = mem::MaybeUninit::uninit(); - let success = - unsafe { ffi::roaring_bitmap_init_with_capacity(bitmap.as_mut_ptr(), capacity) }; - assert!(success); - - Bitmap { - bitmap: unsafe { bitmap.assume_init() }, - } - } - - /// Add the integer element to the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add_many(&[1, 2, 3]); - /// - /// assert!(!bitmap.is_empty()); - /// assert!(bitmap.contains(1)); - /// assert!(bitmap.contains(2)); - /// assert!(bitmap.contains(3)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_add_many")] - pub fn add_many(&mut self, elements: &[u32]) { - unsafe { ffi::roaring_bitmap_add_many(&mut self.bitmap, elements.len(), elements.as_ptr()) } - } - - /// Add the integer element to the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// assert!(bitmap.is_empty()); - /// bitmap.add(1); - /// assert!(!bitmap.is_empty()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_add")] - pub fn add(&mut self, element: u32) { - unsafe { ffi::roaring_bitmap_add(&mut self.bitmap, element) } - } - - /// Add the integer element to the bitmap. Returns true if the value was - /// added, false if the value was already in the bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// assert!(bitmap.add_checked(1)); - /// assert!(!bitmap.add_checked(1)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_add_checked")] - pub fn add_checked(&mut self, element: u32) -> bool { - unsafe { ffi::roaring_bitmap_add_checked(&mut self.bitmap, element) } - } - - /// Add all values in range - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::new(); - /// bitmap1.add_range((1..3)); - /// - /// assert!(!bitmap1.is_empty()); - /// assert!(bitmap1.contains(1)); - /// assert!(bitmap1.contains(2)); - /// assert!(!bitmap1.contains(3)); - /// - /// let mut bitmap2 = Bitmap::new(); - /// bitmap2.add_range((3..1)); - /// assert!(bitmap2.is_empty()); - /// - /// let mut bitmap3 = Bitmap::new(); - /// bitmap3.add_range((3..3)); - /// assert!(bitmap3.is_empty()); - /// - /// let mut bitmap4 = Bitmap::new(); - /// bitmap4.add_range(..=2); - /// bitmap4.add_range(u32::MAX..=u32::MAX); - /// assert!(bitmap4.contains(0)); - /// assert!(bitmap4.contains(1)); - /// assert!(bitmap4.contains(2)); - /// assert!(bitmap4.contains(u32::MAX)); - /// assert_eq!(bitmap4.cardinality(), 4); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_add_range_closed")] - pub fn add_range>(&mut self, range: R) { - let (start, end) = range_to_inclusive(range); - unsafe { - ffi::roaring_bitmap_add_range_closed(&mut self.bitmap, start, end); - } - } - - /// Remove all values in range - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add_range((1..4)); - /// assert!(!bitmap.is_empty()); - /// - /// bitmap.remove_range((1..3)); - /// - /// assert!(!bitmap.contains(1)); - /// assert!(!bitmap.contains(2)); - /// assert!(bitmap.contains(3)); - /// - /// bitmap.add_range(u32::MAX..=u32::MAX); - /// assert!(bitmap.contains(u32::MAX)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_remove_range_closed")] - pub fn remove_range>(&mut self, range: R) { - let (start, end) = range_to_inclusive(range); - unsafe { - ffi::roaring_bitmap_remove_range_closed(&mut self.bitmap, start, end); - } - } - - /// Check whether a range of values of range are present - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1, 2]); - /// assert!(bitmap.contains_range((1..3))); - /// - /// let mut bitmap = bitmap.clone(); - /// bitmap.add(u32::MAX - 1); - /// bitmap.add(u32::MAX); - /// assert!(bitmap.contains_range((u32::MAX - 1)..=u32::MAX)) - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_contains_range")] - pub fn contains_range>(&self, range: R) -> bool { - let (start, end) = range_to_exclusive(range); - unsafe { ffi::roaring_bitmap_contains_range(&self.bitmap, start, end) } - } - - /// Empties the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add(1); - /// bitmap.add(2); - /// bitmap.clear(); - /// - /// assert!(bitmap.is_empty()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_clear")] - pub fn clear(&mut self) { - unsafe { ffi::roaring_bitmap_clear(&mut self.bitmap) } - } - - /// Clear the integer element from the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add(1); - /// bitmap.remove(1); - /// - /// assert!(bitmap.is_empty()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_remove")] - pub fn remove(&mut self, element: u32) { - unsafe { ffi::roaring_bitmap_remove(&mut self.bitmap, element) } - } - - /// Remove the integer element from the bitmap. Returns true if a the value - /// was removed, false if the value was present in the bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add(1); - /// assert!(bitmap.remove_checked(1)); - /// assert!(!bitmap.remove_checked(1)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_remove_checked")] - pub fn remove_checked(&mut self, element: u32) -> bool { - unsafe { ffi::roaring_bitmap_remove_checked(&mut self.bitmap, element) } - } - - /// Contains returns true if the integer element is contained in the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1]); - /// - /// assert!(bitmap.contains(1)); - /// assert!(!bitmap.contains(2)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_contains")] - #[must_use] - pub fn contains(&self, element: u32) -> bool { - unsafe { ffi::roaring_bitmap_contains(&self.bitmap, element) } - } - - /// Compute a new bitmap, which contains all values from this bitmap, but shifted by `offset` - /// - /// Any values which would be `< 0`, or `> u32::MAX` are dropped. - /// - /// # Examples - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[0, 1, 1000, u32::MAX]); - /// let shifted_down = bitmap1.add_offset(-1); - /// assert_eq!(shifted_down.to_vec(), [0, 999, u32::MAX - 1]); - /// let shifted_up = bitmap1.add_offset(1); - /// assert_eq!(shifted_up.to_vec(), [1, 2, 1001]); - /// let big_shifted = bitmap1.add_offset(i64::from(u32::MAX) + 1); - /// assert_eq!(big_shifted.to_vec(), []); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_add_offset")] - #[must_use] - pub fn add_offset(&self, offset: i64) -> Self { - unsafe { Bitmap::take_heap(ffi::roaring_bitmap_add_offset(&self.bitmap, offset)) } - } - - /// Returns number of elements in range - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1, 3, 4]); - /// - /// assert_eq!(bitmap.range_cardinality((..1)), 0); - /// assert_eq!(bitmap.range_cardinality((..2)), 1); - /// assert_eq!(bitmap.range_cardinality((2..5)), 2); - /// assert_eq!(bitmap.range_cardinality((..5)), 3); - /// assert_eq!(bitmap.range_cardinality((1..=4)), 3); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_range_cardinality")] - pub fn range_cardinality>(&self, range: R) -> u64 { - let (start, end) = range_to_exclusive(range); - unsafe { ffi::roaring_bitmap_range_cardinality(&self.bitmap, start, end) } - } - - /// Returns the number of integers contained in the bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1]); - /// - /// assert_eq!(bitmap.cardinality(), 1); - /// - /// let mut bitmap = bitmap.clone(); - /// - /// bitmap.add(2); - /// - /// assert_eq!(bitmap.cardinality(), 2); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_get_cardinality")] - #[must_use] - pub fn cardinality(&self) -> u64 { - unsafe { ffi::roaring_bitmap_get_cardinality(&self.bitmap) } - } - - /// And computes the intersection between two bitmaps and returns the result - /// as a new bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[1]); - /// let bitmap2 = Bitmap::of(&[1, 2]); - /// - /// let bitmap3 = bitmap1.and(&bitmap2); - /// - /// assert!(bitmap3.contains(1)); - /// assert!(!bitmap3.contains(2)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_and")] - #[must_use] - pub fn and(&self, other: &Self) -> Self { - unsafe { Self::take_heap(ffi::roaring_bitmap_and(&self.bitmap, &other.bitmap)) } - } - - /// Computes the intersection between two bitmaps and stores the result - /// in the current bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// let mut bitmap3 = Bitmap::of(&[15]); - /// let bitmap4 = Bitmap::of(&[15, 25]); - /// - /// bitmap1.and_inplace(&bitmap2); - /// - /// assert_eq!(bitmap1.cardinality(), 0); - /// assert!(!bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// - /// bitmap3.and_inplace(&bitmap4); - /// - /// assert_eq!(bitmap3.cardinality(), 1); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_and_inplace")] - pub fn and_inplace(&mut self, other: &Self) { - unsafe { ffi::roaring_bitmap_and_inplace(&mut self.bitmap, &other.bitmap) } - } - - /// Or computes the union between two bitmaps and returns the result - /// as a new bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// - /// let bitmap3 = bitmap1.or(&bitmap2); - /// - /// assert_eq!(bitmap3.cardinality(), 2); - /// assert!(bitmap3.contains(15)); - /// assert!(bitmap3.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or")] - #[must_use] - pub fn or(&self, other: &Self) -> Self { - unsafe { Self::take_heap(ffi::roaring_bitmap_or(&self.bitmap, &other.bitmap)) } - } - - /// Computes the union between two bitmaps and stores the result in - /// the current bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// - /// bitmap1.or_inplace(&bitmap2); - /// - /// assert_eq!(bitmap1.cardinality(), 2); - /// assert!(bitmap1.contains(15)); - /// assert!(bitmap1.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or_inplace")] - pub fn or_inplace(&mut self, other: &Self) { - unsafe { ffi::roaring_bitmap_or_inplace(&mut self.bitmap, &other.bitmap) } - } - - /// Computes the union between many bitmaps quickly, as opposed to having - /// to call or() repeatedly. Returns the result as a new bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// let bitmap3 = Bitmap::of(&[35]); - /// - /// let bitmap4 = Bitmap::fast_or(&[&bitmap1, &bitmap2, &bitmap3]); - /// - /// assert_eq!(bitmap4.cardinality(), 3); - /// assert!(bitmap4.contains(15)); - /// assert!(bitmap4.contains(25)); - /// assert!(bitmap4.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or_many")] - #[must_use] - pub fn fast_or(bitmaps: &[&Bitmap]) -> Self { - #[cfg(windows)] - { - extern "C" { - pub fn croaring_hardware_support() -> std::ffi::c_int; - } - eprintln!("hardware support: {:x}", unsafe { - croaring_hardware_support() - }); - } - let mut bms: Vec<*const ffi::roaring_bitmap_s> = bitmaps - .iter() - .map(|item| ptr::addr_of!(item.bitmap)) - .collect(); - - eprintln!("{bms:#?}"); - - unsafe { - Self::take_heap(dbg!(ffi::roaring_bitmap_or_many( - bms.len(), - bms.as_mut_ptr() - ))) - } - } - - /// Compute the union of 'number' bitmaps using a heap. This can - /// sometimes be faster than Bitmap::fast_or. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// let bitmap3 = Bitmap::of(&[35]); - /// - /// let bitmap4 = Bitmap::fast_or_heap(&[&bitmap1, &bitmap2, &bitmap3]); - /// - /// assert_eq!(bitmap4.cardinality(), 3); - /// assert!(bitmap4.contains(15)); - /// assert!(bitmap4.contains(25)); - /// assert!(bitmap4.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or_many_heap")] - #[must_use] - pub fn fast_or_heap(bitmaps: &[&Bitmap]) -> Self { - let mut bms: Vec<*const ffi::roaring_bitmap_s> = bitmaps - .iter() - .map(|item| ptr::addr_of!(item.bitmap)) - .collect(); - - let count = u32::try_from(bms.len()).expect("can only or up to 2^32 bitmaps"); - - unsafe { Self::take_heap(ffi::roaring_bitmap_or_many_heap(count, bms.as_mut_ptr())) } - } - - /// Computes the symmetric difference (xor) between two bitmaps - /// and returns new bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// let bitmap3 = bitmap1.xor(&bitmap2); - /// - /// assert_eq!(bitmap3.cardinality(), 2); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// assert!(bitmap3.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor")] - #[must_use] - pub fn xor(&self, other: &Self) -> Self { - unsafe { Self::take_heap(ffi::roaring_bitmap_xor(&self.bitmap, &other.bitmap)) } - } - - /// Inplace version of roaring_bitmap_xor, stores result in current bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// bitmap1.xor_inplace(&bitmap2); - /// - /// assert_eq!(bitmap1.cardinality(), 2); - /// assert!(bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// assert!(bitmap1.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor_inplace")] - pub fn xor_inplace(&mut self, other: &Self) { - unsafe { ffi::roaring_bitmap_xor_inplace(&mut self.bitmap, &other.bitmap) } - } - - /// Computes the symmetric difference (xor) between multiple bitmaps - /// and returns new bitmap as a result. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// let bitmap3 = Bitmap::fast_xor(&[&bitmap1, &bitmap2]); - /// - /// assert_eq!(bitmap3.cardinality(), 2); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// assert!(bitmap3.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor_many")] - #[must_use] - pub fn fast_xor(bitmaps: &[&Bitmap]) -> Self { - let mut bms: Vec<*const ffi::roaring_bitmap_s> = bitmaps - .iter() - .map(|item| ptr::addr_of!(item.bitmap)) - .collect(); - - unsafe { Self::take_heap(ffi::roaring_bitmap_xor_many(bms.len(), bms.as_mut_ptr())) } - } - - /// Computes the difference between two bitmaps and returns the result. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// let bitmap3 = bitmap1.andnot(&bitmap2); - /// - /// assert_eq!(bitmap3.cardinality(), 1); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// assert!(!bitmap3.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_andnot")] - #[must_use] - pub fn andnot(&self, other: &Self) -> Self { - unsafe { Self::take_heap(ffi::roaring_bitmap_andnot(&self.bitmap, &other.bitmap)) } - } - - /// Computes the difference between two bitmaps and stores the result - /// in the current bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// bitmap1.andnot_inplace(&bitmap2); - /// - /// assert_eq!(bitmap1.cardinality(), 1); - /// assert!(bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// assert!(!bitmap1.contains(35)); - /// - /// let mut bitmap3 = Bitmap::of(&[15]); - /// let bitmap4 = Bitmap::new(); - /// bitmap3.andnot_inplace(&bitmap4); - /// assert_eq!(bitmap3.cardinality(), 1); - /// assert!(bitmap3.contains(15)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_andnot_inplace")] - pub fn andnot_inplace(&mut self, other: &Self) { - unsafe { ffi::roaring_bitmap_andnot_inplace(&mut self.bitmap, &other.bitmap) } - } - - /// Negates the bits in the given range - /// any integer present in this range and in the bitmap is removed. - /// Returns result as a new bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[4]); - /// - /// let bitmap2 = bitmap1.flip(1..3); - /// - /// assert_eq!(bitmap2.cardinality(), 3); - /// assert!(bitmap2.contains(1)); - /// assert!(bitmap2.contains(2)); - /// assert!(!bitmap2.contains(3)); - /// assert!(bitmap2.contains(4)); - /// - /// let bitmap3 = bitmap1.flip(1..=5); - /// assert_eq!(bitmap3.to_vec(), [1, 2, 3, 5]) - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_flip")] - #[must_use] - pub fn flip>(&self, range: R) -> Self { - let (start, end) = range_to_exclusive(range); - unsafe { Self::take_heap(ffi::roaring_bitmap_flip(&self.bitmap, start, end)) } - } - - /// Negates the bits in the given range - /// any integer present in this range and in the bitmap is removed. - /// Stores the result in the current bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[4]); - /// bitmap1.flip_inplace(1..3); - /// - /// assert_eq!(bitmap1.cardinality(), 3); - /// assert!(bitmap1.contains(1)); - /// assert!(bitmap1.contains(2)); - /// assert!(!bitmap1.contains(3)); - /// assert!(bitmap1.contains(4)); - /// bitmap1.flip_inplace(4..=4); - /// assert_eq!(bitmap1.to_vec(), [1, 2]); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_flip_inplace")] - pub fn flip_inplace>(&mut self, range: R) { - let (start, end) = range_to_exclusive(range); - unsafe { ffi::roaring_bitmap_flip_inplace(&mut self.bitmap, start, end) } - } - - /// Returns a vector containing all of the integers stored in the Bitmap - /// in sorted order. - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[15, 25]); - /// - /// assert_eq!(bitmap.to_vec(), [15, 25]); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_to_uint32_array")] - #[must_use] - pub fn to_vec(&self) -> Vec { - let bitmap_size: usize = self.cardinality().try_into().unwrap(); - - let mut buffer: Vec = Vec::with_capacity(bitmap_size); - unsafe { - ffi::roaring_bitmap_to_uint32_array(&self.bitmap, buffer.as_mut_ptr()); - buffer.set_len(bitmap_size); - } - buffer - } - - /// Computes the serialized size in bytes of the Bitmap in format `S`. - #[inline] - #[must_use] - pub fn get_serialized_size_in_bytes(&self) -> usize { - S::get_serialized_size_in_bytes(self) - } - - /// Serializes a bitmap to a slice of bytes in format `S`. - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, Portable}; - /// - /// let original_bitmap: Bitmap = (1..5).collect(); - /// - /// let serialized_buffer = original_bitmap.serialize::(); - /// - /// let deserialized_bitmap = Bitmap::deserialize::(&serialized_buffer); - /// - /// assert_eq!(original_bitmap, deserialized_bitmap); - /// ``` - #[inline] - #[must_use] - pub fn serialize(&self) -> Vec { - let mut dst = Vec::new(); - self.serialize_into::(&mut dst); - dst - } - - /// Serializes a bitmap to a slice of bytes in format `S`, re-using existing capacity - /// - /// `dst` is not cleared, data is added after any existing data. Returns the added slice of `dst`. - /// If `dst` is empty, it is guaranteed to hold only the serialized data after this call - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, Portable}; - /// - /// let original_bitmap_1: Bitmap = (1..5).collect(); - /// let original_bitmap_2: Bitmap = (1..10).collect(); - /// - /// let mut data = Vec::new(); - /// for bitmap in [original_bitmap_1, original_bitmap_2] { - /// data.clear(); - /// bitmap.serialize_into::(&mut data); - /// // do something with data - /// } - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_portable_serialize")] - pub fn serialize_into<'a, S: Serializer>(&self, dst: &'a mut Vec) -> &'a [u8] { - S::serialize_into(self, dst) - } - - /// Given a serialized bitmap as slice of bytes in format `S`, returns a `Bitmap` instance. - /// See example of [`Self::serialize`] function. - /// - /// On invalid input returns None. - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, Portable}; - /// - /// let original_bitmap: Bitmap = (1..5).collect(); - /// let serialized_buffer = original_bitmap.serialize::(); - /// - /// let deserialized_bitmap = Bitmap::try_deserialize::(&serialized_buffer); - /// assert_eq!(original_bitmap, deserialized_bitmap.unwrap()); - /// - /// let invalid_buffer: Vec = vec![3]; - /// let deserialized_bitmap = Bitmap::try_deserialize::(&invalid_buffer); - /// assert!(deserialized_bitmap.is_none()); - /// ``` - #[inline] - #[must_use] - pub fn try_deserialize(buffer: &[u8]) -> Option { - D::try_deserialize(buffer) - } - - /// Given a serialized bitmap as slice of bytes in format `S `, returns a bitmap instance. - /// See example of [`Self::serialize`] function. - /// - /// On invalid input returns empty bitmap. - #[inline] - pub fn deserialize(buffer: &[u8]) -> Self { - Self::try_deserialize::(buffer).unwrap_or_else(Bitmap::new) - } - - /// Creates a new bitmap from a slice of u32 integers - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let elements = vec![1, 2]; - /// - /// let bitmap = Bitmap::of(&elements); - /// - /// let mut bitmap2 = Bitmap::new(); - /// - /// for element in &elements { - /// bitmap2.add(*element); - /// } - /// - /// assert!(bitmap.contains(1)); - /// assert!(bitmap.contains(2)); - /// assert!(!bitmap.contains(3)); - /// assert_eq!(bitmap, bitmap2); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_of_ptr")] - #[must_use] - pub fn of(elements: &[u32]) -> Self { - // This does the same as `roaring_bitmap_of_ptr`, but that also allocates the bitmap itself - let mut bitmap = Self::new(); - bitmap.add_many(elements); - bitmap - } - - /// Create a new bitmap with all values in `range` - /// - /// # Examples - /// - /// ``` - /// use std::ops::Bound; - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::from_range(5..10); - /// assert_eq!(bitmap1.to_vec(), [5, 6, 7, 8, 9]); - /// - /// let bitmap2 = Bitmap::from_range(5..=7); - /// assert_eq!(bitmap2.to_vec(), [5, 6, 7]); - /// - /// let bitmap3 = Bitmap::from_range((Bound::Excluded(2), Bound::Excluded(6))); - /// assert_eq!(bitmap3.to_vec(), [3, 4, 5]); - #[inline] - #[doc(alias = "roaring_bitmap_from_range")] - pub fn from_range>(range: R) -> Self { - let mut result = Self::new(); - result.add_range(range); - result - } - - /// Create a new bitmap with all values in `range` which are a multiple of `step` away from the lower bound - /// - /// If `step` is zero or there are no values which are a multiple of `step` away from the lower bound - /// within `range`, an empty bitmap is returned. - /// - /// # Examples - /// - /// ``` - /// use std::ops::Bound; - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::from_range_with_step(0..10, 3); - /// assert_eq!(bitmap.to_vec(), [0, 3, 6, 9]); - /// - /// // empty ranges - /// assert_eq!(Bitmap::from_range_with_step(0..0, 1), Bitmap::new()); - /// assert_eq!(Bitmap::from_range_with_step(100..=0, 1), Bitmap::new()); - /// - /// // Step of zero - /// assert_eq!(Bitmap::from_range_with_step(0..100, 0), Bitmap::new()); - /// - /// // No values of step in range - /// let bitmap = Bitmap::from_range_with_step((Bound::Excluded(0), Bound::Included(10)), 100); - /// assert_eq!(bitmap, Bitmap::new()); - /// let bitmap = Bitmap::from_range_with_step((Bound::Excluded(u32::MAX), Bound::Included(u32::MAX)), 1); - /// assert_eq!(bitmap, Bitmap::new()); - /// - /// // Exclusive ranges still step from the start, but do not include it - /// let bitmap = Bitmap::from_range_with_step((Bound::Excluded(10), Bound::Included(30)), 10); - /// assert_eq!(bitmap.to_vec(), [20, 30]); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_from_range")] - pub fn from_range_with_step>(range: R, step: u32) -> Self { - // This can't use `range_to_exclusive` because when the start is excluded, we want - // to start at the next step, not one more - let start = match range.start_bound() { - Bound::Included(&i) => u64::from(i), - Bound::Excluded(&i) => u64::from(i) + u64::from(step), - Bound::Unbounded => 0, - }; - let end = match range.end_bound() { - Bound::Included(&i) => u64::from(i) + 1, - Bound::Excluded(&i) => u64::from(i), - Bound::Unbounded => u64::MAX, - }; - unsafe { - let result = ffi::roaring_bitmap_from_range(start, end, step); - if result.is_null() { - Self::new() - } else { - Self::take_heap(result) - } - } - } - - /// Shrink the memory allocation of the bitmap if needed - /// - /// Returns the number of bytes saved - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::with_container_capacity(10); - /// let saved_bytes = bitmap.shrink_to_fit(); - /// assert!(saved_bytes > 0); - /// let more_saved_bytes = bitmap.shrink_to_fit(); - /// assert_eq!(more_saved_bytes, 0); - #[inline] - #[doc(alias = "roaring_bitmap_shrink_to_fit")] - pub fn shrink_to_fit(&mut self) -> usize { - unsafe { ffi::roaring_bitmap_shrink_to_fit(&mut self.bitmap) } - } - - /// Compresses of the bitmap. Returns true if the bitmap was modified. - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, Portable}; - /// - /// let mut bitmap: Bitmap = (100..1000).collect(); - /// - /// assert_eq!(bitmap.cardinality(), 900); - /// let old_size = bitmap.get_serialized_size_in_bytes::(); - /// assert!(bitmap.run_optimize()); - /// let new_size = bitmap.get_serialized_size_in_bytes::(); - /// assert!(new_size < old_size); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_run_optimize")] - pub fn run_optimize(&mut self) -> bool { - unsafe { ffi::roaring_bitmap_run_optimize(&mut self.bitmap) } - } - - /// Removes run-length encoding even when it is more space efficient. Returns - /// true if a change was applied. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = (100..1000).collect(); - /// - /// assert_eq!(bitmap.cardinality(), 900); - /// - /// bitmap.run_optimize(); - /// - /// assert!(bitmap.remove_run_compression()); - /// assert!(!bitmap.remove_run_compression()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_remove_run_compression")] - pub fn remove_run_compression(&mut self) -> bool { - unsafe { ffi::roaring_bitmap_remove_run_compression(&mut self.bitmap) } - } - - /// Returns true if the Bitmap is empty. - /// Faster than doing: bitmap.cardinality() == 0) - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// - /// assert!(bitmap.is_empty()); - /// - /// bitmap.add(1); - /// - /// assert!(!bitmap.is_empty()); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_is_empty")] - #[must_use] - pub fn is_empty(&self) -> bool { - unsafe { ffi::roaring_bitmap_is_empty(&self.bitmap) } - } - - /// Return true if all the elements of Self are in &other. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1: Bitmap = (5..10).collect(); - /// let bitmap2: Bitmap = (5..8).collect(); - /// let bitmap3: Bitmap = (5..10).collect(); - /// let bitmap4: Bitmap = (9..11).collect(); - /// - /// assert!(bitmap2.is_subset(&bitmap1)); - /// assert!(bitmap3.is_subset(&bitmap1)); - /// assert!(!bitmap4.is_subset(&bitmap1)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_is_subset")] - #[must_use] - pub fn is_subset(&self, other: &Self) -> bool { - unsafe { ffi::roaring_bitmap_is_subset(&self.bitmap, &other.bitmap) } - } - - /// Return true if all the elements of Self are in &other and &other is strictly greater - /// than Self. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1: Bitmap = (5..9).collect(); - /// let bitmap2: Bitmap = (5..8).collect(); - /// let bitmap3: Bitmap = (5..10).collect(); - /// let bitmap4: Bitmap = (9..11).collect(); - /// - /// assert!(bitmap2.is_subset(&bitmap1)); - /// assert!(!bitmap3.is_subset(&bitmap1)); - /// assert!(!bitmap4.is_subset(&bitmap1)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_is_strict_subset")] - #[must_use] - pub fn is_strict_subset(&self, other: &Self) -> bool { - unsafe { ffi::roaring_bitmap_is_strict_subset(&self.bitmap, &other.bitmap) } - } - - /// Return true if Self and &other intersect - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1: Bitmap = (1..5).collect(); - /// let bitmap2: Bitmap = (5..9).collect(); - /// let bitmap3: Bitmap = (3..7).collect(); - /// - /// assert_eq!(bitmap1.intersect(&bitmap2), false); - /// assert_eq!(bitmap1.intersect(&bitmap3), true); - /// assert_eq!(bitmap2.intersect(&bitmap3), true); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_intersect")] - #[must_use] - pub fn intersect(&self, other: &Self) -> bool { - unsafe { ffi::roaring_bitmap_intersect(&self.bitmap, &other.bitmap) } - } - - /// Check if a bitmap has any values set in `range` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1, 100, 101, u32::MAX]); - /// - /// assert!(bitmap.intersect_with_range(0..10)); - /// assert!(!bitmap.intersect_with_range(2..100)); - /// assert!(bitmap.intersect_with_range(999..=u32::MAX)); - /// - /// // Empty ranges - /// assert!(!bitmap.intersect_with_range(100..100)); - /// assert!(!bitmap.intersect_with_range(100..0)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_intersect_with_range")] - pub fn intersect_with_range>(&self, range: R) -> bool { - let (start, end) = range_to_exclusive(range); - unsafe { ffi::roaring_bitmap_intersect_with_range(&self.bitmap, start, end) } - } - - /// Return the Jaccard index between Self and &other - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1: Bitmap = (1..5).collect(); - /// let bitmap2: Bitmap = (5..9).collect(); - /// let bitmap3: Bitmap = (3..9).collect(); - /// - /// assert_eq!(bitmap1.jaccard_index(&bitmap2), 0.0); - /// assert_eq!(bitmap1.jaccard_index(&bitmap3), 0.25); - /// assert_eq!(bitmap2.jaccard_index(&bitmap3), 0.6666666666666666); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_jaccard_index")] - #[must_use] - pub fn jaccard_index(&self, other: &Self) -> f64 { - unsafe { ffi::roaring_bitmap_jaccard_index(&self.bitmap, &other.bitmap) } - } - - /// Return the size of the intersection between Self and &other - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[1]); - /// let bitmap2 = Bitmap::of(&[1, 2]); - /// - /// assert_eq!(bitmap1.and_cardinality(&bitmap2), 1); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_and_cardinality")] - #[must_use] - pub fn and_cardinality(&self, other: &Self) -> u64 { - unsafe { ffi::roaring_bitmap_and_cardinality(&self.bitmap, &other.bitmap) } - } - - /// Return the size of the union between Self and &other - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// - /// assert_eq!(bitmap1.or_cardinality(&bitmap2), 2); - #[inline] - #[doc(alias = "roaring_bitmap_or_cardinality")] - #[must_use] - pub fn or_cardinality(&self, other: &Self) -> u64 { - unsafe { ffi::roaring_bitmap_or_cardinality(&self.bitmap, &other.bitmap) } - } - - /// Return the size of the difference between Self and &other - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// assert_eq!(bitmap1.andnot_cardinality(&bitmap2), 1); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_andnot_cardinality")] - #[must_use] - pub fn andnot_cardinality(&self, other: &Self) -> u64 { - unsafe { ffi::roaring_bitmap_andnot_cardinality(&self.bitmap, &other.bitmap) } - } - - /// Return the size of the symmetric difference between Self and &other - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// assert_eq!(bitmap1.xor_cardinality(&bitmap2), 2); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor_cardinality")] - #[must_use] - pub fn xor_cardinality(&self, other: &Self) -> u64 { - unsafe { ffi::roaring_bitmap_xor_cardinality(&self.bitmap, &other.bitmap) } - } - - /// Returns the smallest value in the set. - /// - /// Returns `None` if the set is empty. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = (5..10).collect(); - /// let empty_bitmap: Bitmap = Bitmap::new(); - /// - /// assert_eq!(bitmap.minimum(), Some(5)); - /// assert_eq!(empty_bitmap.minimum(), None); - /// - /// bitmap.add(3); - /// - /// assert_eq!(bitmap.minimum(), Some(3)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_minimum")] - #[must_use] - pub fn minimum(&self) -> Option { - if self.is_empty() { - None - } else { - Some(unsafe { ffi::roaring_bitmap_minimum(&self.bitmap) }) - } - } - - /// Returns the greatest value in the set. - /// - /// Returns `None` if the set is empty. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = (5..10).collect(); - /// let empty_bitmap: Bitmap = Bitmap::new(); - /// - /// assert_eq!(bitmap.maximum(), Some(9)); - /// assert_eq!(empty_bitmap.maximum(), None); - /// - /// bitmap.add(15); - /// - /// assert_eq!(bitmap.maximum(), Some(15)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_maximum")] - #[must_use] - pub fn maximum(&self) -> Option { - if self.is_empty() { - None - } else { - Some(unsafe { ffi::roaring_bitmap_maximum(&self.bitmap) }) - } - } - - /// Rank returns the number of values smaller or equal to x. - /// - /// For a similar function which also checks if x is in the set, see [position][Self::position]. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = (5..10).collect(); - /// - /// assert_eq!(bitmap.rank(8), 4); - /// - /// bitmap.add(15); - /// - /// assert_eq!(bitmap.rank(11), 5); - /// assert_eq!(bitmap.rank(15), 6); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_rank")] - #[must_use] - pub fn rank(&self, x: u32) -> u64 { - unsafe { ffi::roaring_bitmap_rank(&self.bitmap, x) } - } - - /// Returns the index of x in the given roaring bitmap. - /// - /// If the roaring bitmap doesn't contain x, this function will return None. - /// The difference with the [rank][Self::rank] function is that this function - /// will return None when x is not the element of roaring bitmap, but the rank - /// function will return the the number of items less than x, and would require - /// a call to [contains][Self::contains] to check if x is in the roaring bitmap. - /// - /// # Examples - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = Bitmap::from_range(5..10); - /// assert_eq!(bitmap.position(4), None); - /// assert_eq!(bitmap.position(5), Some(0)); - /// assert_eq!(bitmap.position(9), Some(4)); - /// assert_eq!(bitmap.position(10), None); - /// assert_eq!(bitmap.position(9999), None); - /// - /// // rank returns the number of values smaller or equal to x, so it always returns a value, and - /// // returns `position + 1` when x is contained in the bitmap. - /// assert_eq!(bitmap.rank(4), 0); - /// assert_eq!(bitmap.rank(5), 1); - /// assert_eq!(bitmap.rank(9), 5); - /// assert_eq!(bitmap.rank(10), 5); - /// assert_eq!(bitmap.rank(9999), 5); - /// - /// let pos = bitmap.position(7).unwrap(); - /// assert_eq!(bitmap.select(pos), Some(7)); - /// ``` - #[inline] - #[doc(alias = "index")] - #[doc(alias = "roaring_bitmap_get_index")] - #[must_use] - pub fn position(&self, x: u32) -> Option { - let index = unsafe { ffi::roaring_bitmap_get_index(&self.bitmap, x) }; - if index == -1 { - None - } else { - Some(u32::try_from(index).unwrap()) - } - } - - /// Select returns the element having the designated position, if it exists - /// - /// If the size of the roaring bitmap is strictly greater than pos, - /// then this function returns element of given rank wrapped in Some. - /// Otherwise, it returns None. - /// - /// To do the inverse operation (given an element, find its position), use the - /// [position][Self::position] function, or the [rank][Self::rank] function. - /// - /// Note that the [rank][Self::rank] function is inclusive: it returns the number of values - /// smaller or equal to x, when `x` is contained in the bitmap, it returns - /// `position + 1`. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap: Bitmap = (5..10).collect(); - /// - /// assert_eq!(bitmap.select(0), Some(5)); - /// assert_eq!(bitmap.select(1), Some(6)); - /// assert_eq!(bitmap.select(2), Some(7)); - /// assert_eq!(bitmap.select(3), Some(8)); - /// assert_eq!(bitmap.select(4), Some(9)); - /// assert_eq!(bitmap.select(5), None); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_select")] - #[must_use] - pub fn select(&self, position: u32) -> Option { - let mut element: u32 = 0; - let result = unsafe { ffi::roaring_bitmap_select(&self.bitmap, position, &mut element) }; - - if result { - Some(element) - } else { - None - } - } - - /// Returns statistics about the composition of a roaring bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = (1..100).collect(); - /// let statistics = bitmap.statistics(); - /// - /// assert_eq!(statistics.n_containers, 1); - /// assert_eq!(statistics.n_array_containers, 1); - /// assert_eq!(statistics.n_run_containers, 0); - /// assert_eq!(statistics.n_bitset_containers, 0); - /// assert_eq!(statistics.n_values_array_containers, 99); - /// assert_eq!(statistics.n_values_run_containers, 0); - /// assert_eq!(statistics.n_values_bitset_containers, 0); - /// assert_eq!(statistics.n_bytes_array_containers, 198); - /// assert_eq!(statistics.n_bytes_run_containers, 0); - /// assert_eq!(statistics.n_bytes_bitset_containers, 0); - /// assert_eq!(statistics.max_value, 99); - /// assert_eq!(statistics.min_value, 1); - /// assert_eq!(statistics.sum_value, 4950); - /// assert_eq!(statistics.cardinality, 99); - /// - /// bitmap.run_optimize(); - /// let statistics = bitmap.statistics(); - /// - /// assert_eq!(statistics.n_containers, 1); - /// assert_eq!(statistics.n_array_containers, 0); - /// assert_eq!(statistics.n_run_containers, 1); - /// assert_eq!(statistics.n_bitset_containers, 0); - /// assert_eq!(statistics.n_values_array_containers, 0); - /// assert_eq!(statistics.n_values_run_containers, 99); - /// assert_eq!(statistics.n_values_bitset_containers, 0); - /// assert_eq!(statistics.n_bytes_array_containers, 0); - /// assert_eq!(statistics.n_bytes_run_containers, 6); - /// assert_eq!(statistics.n_bytes_bitset_containers, 0); - /// assert_eq!(statistics.max_value, 99); - /// assert_eq!(statistics.min_value, 1); - /// assert_eq!(statistics.sum_value, 4950); - /// assert_eq!(statistics.cardinality, 99); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_statistics")] - #[must_use] - pub fn statistics(&self) -> Statistics { - let mut statistics: ffi::roaring_statistics_s = unsafe { ::std::mem::zeroed() }; - - unsafe { ffi::roaring_bitmap_statistics(&self.bitmap, &mut statistics) }; - - statistics - } - - /// Store the bitmap to a bitset - /// - /// This can be useful for those who need the performance and simplicity of a standard bitset. - /// - /// # Errors - /// - /// This function will return None on allocation failure - /// - /// # Examples - /// ``` - /// use croaring::Bitmap; - /// let bitmap = Bitmap::from_range(0..100); - /// let bitset = bitmap.to_bitset().unwrap(); - /// assert_eq!(bitset.count(), 100); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_to_bitset")] - #[must_use] - pub fn to_bitset(&self) -> Option { - let mut bitset = Bitset::new(); - let success = unsafe { ffi::roaring_bitmap_to_bitset(&self.bitmap, bitset.as_raw_mut()) }; - success.then_some(bitset) - } - - /// Ensure the bitmap is internally valid - /// - /// This is useful for development, but is not needed for normal use: - /// bitmaps should _always_ be internally valid. - /// - /// # Errors - /// - /// Returns an error if the bitmap is not valid, with a description of the problem. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::from_range(0..100); - /// bitmap.internal_validate().unwrap(); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_internal_validate")] - #[doc(hidden)] - pub fn internal_validate(&self) -> Result<(), String> { - let mut error_str = ptr::null(); - let valid = unsafe { ffi::roaring_bitmap_internal_validate(&self.bitmap, &mut error_str) }; - if valid { - Ok(()) - } else { - if error_str.is_null() { - return Err(String::from("Unknown error")); - } - let reason = unsafe { CStr::from_ptr(error_str) }; - Err(reason.to_string_lossy().into_owned()) - } - } -} - -fn range_to_inclusive>(range: R) -> (u32, u32) { - let start = match range.start_bound() { - Bound::Included(&i) => i, - Bound::Excluded(&i) => match i.checked_add(1) { - Some(i) => i, - None => return (1, 0), - }, - Bound::Unbounded => 0, - }; - let end = match range.end_bound() { - Bound::Included(&i) => i, - Bound::Excluded(&i) => match i.checked_sub(1) { - Some(i) => i, - None => return (1, 0), - }, - Bound::Unbounded => u32::MAX, - }; - (start, end) -} - -fn range_to_exclusive>(range: R) -> (u64, u64) { - let start = match range.start_bound() { - Bound::Included(&i) => u64::from(i), - Bound::Excluded(&i) => u64::from(i) + 1, - Bound::Unbounded => 0, - }; - let end = match range.end_bound() { - Bound::Included(&i) => u64::from(i) + 1, - Bound::Excluded(&i) => u64::from(i), - Bound::Unbounded => u64::MAX, - }; - (start, end) -} diff --git a/croaring/src/bitmap/iter.rs b/croaring/src/bitmap/iter.rs deleted file mode 100644 index 0530e81..0000000 --- a/croaring/src/bitmap/iter.rs +++ /dev/null @@ -1,211 +0,0 @@ -use std::iter::{FromIterator, IntoIterator}; -use std::marker::PhantomData; -use std::mem::MaybeUninit; - -use super::Bitmap; - -/// Iterator over the values of a bitmap -#[derive(Clone)] -pub struct BitmapIterator<'a> { - iterator: ffi::roaring_uint32_iterator_s, - phantom: PhantomData<&'a Bitmap>, -} - -unsafe impl Send for BitmapIterator<'_> {} -unsafe impl Sync for BitmapIterator<'_> {} - -impl<'a> BitmapIterator<'a> { - fn new(bitmap: &'a Bitmap) -> Self { - let mut iterator = MaybeUninit::::uninit(); - unsafe { - ffi::roaring_init_iterator(&bitmap.bitmap, iterator.as_mut_ptr()); - } - BitmapIterator { - iterator: unsafe { iterator.assume_init() }, - phantom: PhantomData, - } - } - - #[inline] - fn current_value(&self) -> Option { - if self.has_value() { - Some(self.iterator.current_value) - } else { - None - } - } - - #[inline] - fn has_value(&self) -> bool { - self.iterator.has_value - } - - #[inline] - fn advance(&mut self) -> bool { - unsafe { ffi::roaring_advance_uint32_iterator(&mut self.iterator) } - } - - /// Attempt to read many values from the iterator into `dst` - /// - /// Returns the number of items read from the iterator, may be `< dst.len()` iff - /// the iterator is exhausted or `dst.len() > u32::MAX`. - /// - /// This can be much more efficient than repeated iteration. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap: Bitmap = Bitmap::new(); - /// bitmap.add_range(0..100); - /// bitmap.add(222); - /// bitmap.add(555); - /// - /// let mut buf = [0; 100]; - /// let mut iter = bitmap.iter(); - /// assert_eq!(iter.next_many(&mut buf), 100); - /// // Get the first 100 items, from the original range added - /// for (i, item) in buf.iter().enumerate() { - /// assert_eq!(*item, i as u32); - /// } - /// // Calls to next_many() can be interleaved with calls to next() - /// assert_eq!(iter.next(), Some(222)); - /// assert_eq!(iter.next_many(&mut buf), 1); - /// assert_eq!(buf[0], 555); - /// - /// assert_eq!(iter.next(), None); - /// assert_eq!(iter.next_many(&mut buf), 0); - /// ``` - /// - /// ``` - /// use croaring::Bitmap; - /// - /// fn print_by_chunks(bitmap: &Bitmap) { - /// let mut buf = [0; 1024]; - /// let mut iter = bitmap.iter(); - /// loop { - /// let n = iter.next_many(&mut buf); - /// if n == 0 { - /// break; - /// } - /// println!("{:?}", &buf[..n]); - /// } - /// } - /// - /// # print_by_chunks(&Bitmap::of(&[1, 2, 8, 20, 1000])); - /// ``` - #[inline] - #[doc(alias = "roaring_read_uint32_iterator")] - pub fn next_many(&mut self, dst: &mut [u32]) -> usize { - let count: u32 = u32::try_from(dst.len()).unwrap_or(u32::MAX); - let result = unsafe { - ffi::roaring_read_uint32_iterator(&mut self.iterator, dst.as_mut_ptr(), count) - }; - debug_assert!(result <= count); - result as usize - } - - /// Reset the iterator to the first value `>= val` - /// - /// This can move the iterator forwards or backwards. - /// - /// # Examples - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::of(&[0, 1, 100, 1000, u32::MAX]); - /// let mut iter = bitmap.iter(); - /// iter.reset_at_or_after(0); - /// assert_eq!(iter.next(), Some(0)); - /// iter.reset_at_or_after(0); - /// assert_eq!(iter.next(), Some(0)); - /// - /// iter.reset_at_or_after(101); - /// assert_eq!(iter.next(), Some(1000)); - /// assert_eq!(iter.next(), Some(u32::MAX)); - /// assert_eq!(iter.next(), None); - /// iter.reset_at_or_after(u32::MAX); - /// assert_eq!(iter.next(), Some(u32::MAX)); - /// assert_eq!(iter.next(), None); - /// ``` - #[inline] - #[doc(alias = "roaring_move_uint32_iterator_equalorlarger")] - pub fn reset_at_or_after(&mut self, val: u32) { - unsafe { ffi::roaring_move_uint32_iterator_equalorlarger(&mut self.iterator, val) }; - } -} - -impl<'a> Iterator for BitmapIterator<'a> { - type Item = u32; - - fn next(&mut self) -> Option { - match self.current_value() { - Some(value) => { - self.advance(); - - Some(value) - } - None => None, - } - } -} - -impl Bitmap { - /// Returns an iterator over each value stored in the bitmap. - /// Returned values are ordered in ascending order. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// bitmap.add(4); - /// bitmap.add(3); - /// bitmap.add(2); - /// let mut iterator = bitmap.iter(); - /// - /// assert_eq!(iterator.next(), Some(2)); - /// assert_eq!(iterator.next(), Some(3)); - /// assert_eq!(iterator.next(), Some(4)); - /// assert_eq!(iterator.next(), None); - /// ``` - #[inline] - #[doc(alias = "roaring_init_iterator")] - #[must_use] - pub fn iter(&self) -> BitmapIterator { - BitmapIterator::new(self) - } -} - -impl FromIterator for Bitmap { - /// Convenience method for creating bitmap from iterator. - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap: Bitmap = (1..3).collect(); - /// - /// assert!(!bitmap.is_empty()); - /// assert!(bitmap.contains(1)); - /// assert!(bitmap.contains(2)); - /// assert_eq!(bitmap.cardinality(), 2); - /// ``` - fn from_iter>(iter: I) -> Self { - let mut bitmap = Bitmap::new(); - bitmap.extend(iter); - bitmap - } -} - -impl Extend for Bitmap { - fn extend>(&mut self, iter: T) { - let mut ctx = MaybeUninit::::zeroed(); - iter.into_iter().for_each(|item| unsafe { - ffi::roaring_bitmap_add_bulk(&mut self.bitmap, ctx.as_mut_ptr(), item); - }); - } -} diff --git a/croaring/src/bitmap/lazy.rs b/croaring/src/bitmap/lazy.rs deleted file mode 100644 index 8ccf4fe..0000000 --- a/croaring/src/bitmap/lazy.rs +++ /dev/null @@ -1,121 +0,0 @@ -use crate::Bitmap; - -/// A handle to lazily perform multiple bitwise operations on a bitmap -pub struct LazyBitmap<'a> { - bitmap: &'a mut Bitmap, -} - -impl<'a> LazyBitmap<'a> { - /// Modifies the bitmap this lazy bitmap is associated with to be the union of the two bitmaps. - /// - /// # Arguments - /// * `other` - The other bitmap to union with. - /// * `force_bitsets` - Whether to force conversions to bitsets when modifying containers - #[inline] - #[doc(alias = "roaring_bitmap_lazy_or_inplace")] - pub fn or_inplace(&mut self, other: &Bitmap, force_bitsets: bool) -> &mut Self { - unsafe { - // Because we have a mutable borrow of the bitmap, `other` cannot be == our bitmap, - // so this is always safe - ffi::roaring_bitmap_lazy_or_inplace( - &mut self.bitmap.bitmap, - &other.bitmap, - force_bitsets, - ); - } - self - } - - /// Modifies the bitmap this lazy bitmap is associated with to be the xor of the two bitmaps. - #[inline] - #[doc(alias = "roaring_bitmap_lazy_xor_inplace")] - pub fn xor_inplace(&mut self, other: &Bitmap) -> &mut Self { - unsafe { - // Because we have a mutable borrow of the bitmap, `other` cannot be == our bitmap, - // so this is always safe - ffi::roaring_bitmap_lazy_xor_inplace(&mut self.bitmap.bitmap, &other.bitmap); - } - self - } -} - -impl<'a> std::ops::BitOrAssign<&Bitmap> for LazyBitmap<'a> { - #[inline] - fn bitor_assign(&mut self, other: &Bitmap) { - self.or_inplace(other, false); - } -} - -impl<'a> std::ops::BitXorAssign<&Bitmap> for LazyBitmap<'a> { - #[inline] - fn bitxor_assign(&mut self, other: &Bitmap) { - self.xor_inplace(other); - } -} - -impl Bitmap { - /// Perform multiple bitwise operations on a bitmap. - /// - /// The passed closure will be passed a handle which can be used to perform bitwise operations on the bitmap lazily. - /// - /// The result will be equivalent to doing the same operations on this bitmap directly, but because of reduced - /// bookkeeping in between operations, it should be faster - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// // Perform a series of bitwise operations on a bitmap: - /// let mut bitmap = Bitmap::of(&[99]); - /// let bitmaps_to_or = [Bitmap::of(&[1, 2, 5, 10]), Bitmap::of(&[1, 30, 100])]; - /// let bitmaps_to_xor = [Bitmap::of(&[5]), Bitmap::of(&[1, 1000, 1001])]; - /// - /// bitmap.lazy_batch(|lazy| { - /// for b in &bitmaps_to_or { - /// *lazy |= b; - /// } - /// for b in &bitmaps_to_xor { - /// *lazy ^= b; - /// } - /// }); - /// let mut bitmap2 = Bitmap::of(&[99]); - /// for b in &bitmaps_to_or { - /// bitmap2 |= b; - /// } - /// for b in &bitmaps_to_xor { - /// bitmap2 ^= b; - /// } - /// assert_eq!(bitmap, bitmap2); - /// assert_eq!(bitmap.to_vec(), [2, 10, 30, 99, 100, 1000, 1001]); - /// ``` - /// - /// The result the passed closure is returned from `lazy_batch` - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap = Bitmap::new(); - /// let bitmaps_to_or = [Bitmap::of(&[1, 2, 5, 10]), Bitmap::of(&[1, 30, 100])]; - /// let total_added = bitmap.lazy_batch(|lazy| { - /// let mut total = 0; - /// for b in &bitmaps_to_or { - /// lazy.or_inplace(b, true); - /// total += b.cardinality(); - /// } - /// total - /// }); - /// assert_eq!(total_added, 7); - #[doc(alias = "roaring_bitmap_repair_after_lazy")] - pub fn lazy_batch(&mut self, f: F) -> O - where - F: FnOnce(&mut LazyBitmap<'_>) -> O, - { - let mut lazy_bitmap = LazyBitmap { bitmap: self }; - let result = f(&mut lazy_bitmap); - unsafe { - ffi::roaring_bitmap_repair_after_lazy(&mut self.bitmap); - } - result - } -} diff --git a/croaring/src/bitmap/mod.rs b/croaring/src/bitmap/mod.rs deleted file mode 100644 index 658fcea..0000000 --- a/croaring/src/bitmap/mod.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! Rust wrapper for `CRoaring` (a C/C++ implementation at ) -//! -//! The original Java version can be found at -//! # Example -//! -//! ```rust -//! use croaring::Bitmap; -//! -//! let mut rb1 = Bitmap::new(); -//! rb1.add(1); -//! rb1.add(2); -//! rb1.add(3); -//! rb1.add(4); -//! rb1.add(5); -//! rb1.add(100); -//! rb1.add(1000); -//! rb1.run_optimize(); -//! -//! let mut rb2 = Bitmap::new(); -//! rb2.add(3); -//! rb2.add(4); -//! rb2.add(1000); -//! rb2.run_optimize(); -//! -//! let mut rb3 = Bitmap::new(); -//! -//! assert_eq!(rb1.cardinality(), 7); -//! assert!(rb1.contains(3)); -//! -//! rb1.and_inplace(&rb2); -//! rb3.add(5); -//! rb3.or_inplace(&rb1); -//! -//! let mut rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); -//! -//! rb1.and_inplace(&rb2); -//! println!("{:?}", rb1); -//! -//! rb3.add(5); -//! rb3.or_inplace(&rb1); -//! -//! println!("{:?}", rb1); -//! -//! rb3.add(5); -//! rb3.or_inplace(&rb1); -//! -//! println!("{:?}", rb3.to_vec()); -//! println!("{:?}", rb3); -//! println!("{:?}", rb4); -//! -//! rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); -//! -//! println!("{:?}", rb4); -//! ``` - -use std::marker::PhantomData; - -/// A compressed bitmap -// Must be repr(transparent) and match BitmapView, to allow safe transmute between -// &BitmapView and &Bitmap -#[repr(transparent)] -pub struct Bitmap { - bitmap: ffi::roaring_bitmap_t, -} - -unsafe impl Sync for Bitmap {} -unsafe impl Send for Bitmap {} - -/// A frozen view of a bitmap, backed by a byte slice -/// -/// All read-only methods for [`Bitmap`] are also usable on a [`BitmapView`] -#[repr(transparent)] -pub struct BitmapView<'a> { - bitmap: ffi::roaring_bitmap_t, - // Rust lifetime rules will ensure we don't outlive our data, or modify it behind the scenes - phantom: PhantomData<&'a [u8]>, -} - -unsafe impl<'a> Sync for BitmapView<'a> {} -unsafe impl<'a> Send for BitmapView<'a> {} - -/// Detailed statistics on the composition of a bitmap -pub type Statistics = ffi::roaring_statistics_s; - -mod imp; -mod iter; -mod lazy; -mod ops; -mod serialization; -mod view; - -pub use self::iter::BitmapIterator; -pub use self::lazy::LazyBitmap; -pub use self::serialization::{Deserializer, Serializer, ViewDeserializer}; diff --git a/croaring/src/bitmap/ops.rs b/croaring/src/bitmap/ops.rs deleted file mode 100644 index b499dfe..0000000 --- a/croaring/src/bitmap/ops.rs +++ /dev/null @@ -1,520 +0,0 @@ -use crate::BitmapView; -use std::fmt; -use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign}; - -use super::Bitmap; - -impl fmt::Debug for Bitmap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.cardinality() < 32 { - write!(f, "Bitmap<{:?}>", self.to_vec()) - } else { - write!( - f, - "Bitmap<{:?} values between {:?} and {:?}>", - self.cardinality(), - self.minimum().unwrap(), - self.maximum().unwrap() - ) - } - } -} - -impl Default for Bitmap { - fn default() -> Self { - Self::new() - } -} - -/// Create a new bitmap from a slice of u32 values -/// -/// # Examples -/// -/// ``` -/// use croaring::Bitmap; -/// -/// let data: &[u32] = &[1, 2, 3]; -/// -/// let bitmap1 = Bitmap::from(data); -/// let bitmap2 = Bitmap::from_range(1..=3); -/// assert_eq!(bitmap1, bitmap2); -/// ``` -impl From<&'_ [u32]> for Bitmap { - #[inline] - #[doc(alias = "roaring_bitmap_of_ptr")] - fn from(values: &'_ [u32]) -> Self { - Self::of(values) - } -} - -/// Create a new bitmap from an array of u32 values -/// -/// # Examples -/// -/// ``` -/// use croaring::Bitmap; -/// -/// let bitmap1 = Bitmap::from([1, 2, 3]); -/// let bitmap2 = Bitmap::from_range(1..=3); -/// assert_eq!(bitmap1, bitmap2); -/// ``` -impl From<[u32; N]> for Bitmap { - #[inline] - #[doc(alias = "roaring_bitmap_of_ptr")] - fn from(values: [u32; N]) -> Self { - Self::of(&values) - } -} - -impl PartialEq for Bitmap { - #[inline] - #[doc(alias = "roaring_bitmap_equals")] - fn eq(&self, other: &Bitmap) -> bool { - unsafe { ffi::roaring_bitmap_equals(&self.bitmap, &other.bitmap) } - } -} - -impl PartialEq> for Bitmap { - #[inline] - fn eq(&self, other: &BitmapView) -> bool { - unsafe { ffi::roaring_bitmap_equals(&self.bitmap, &other.bitmap) } - } -} - -impl PartialEq for BitmapView<'_> { - #[inline] - fn eq(&self, other: &Bitmap) -> bool { - unsafe { ffi::roaring_bitmap_equals(&self.bitmap, &other.bitmap) } - } -} - -impl Eq for Bitmap {} - -impl Clone for Bitmap { - /// Create a copy of a Bitmap - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::new(); - /// bitmap1.add(11); - /// - /// let bitmap2 = bitmap1.clone(); - /// - /// assert_eq!(bitmap1, bitmap2); - /// ``` - #[inline] - fn clone(&self) -> Self { - let mut result = Self::new(); - result.clone_from(self); - result - } - - #[doc(alias = "roaring_bitmap_overwrite")] - fn clone_from(&mut self, source: &Self) { - unsafe { - let success = ffi::roaring_bitmap_overwrite(&mut self.bitmap, &source.bitmap); - assert!(success, "Memory allocation failure cloning roaring bitmap"); - } - } -} - -impl Drop for Bitmap { - #[allow(clippy::assertions_on_constants)] - #[doc(alias = "roaring_bitmap_clear")] - fn drop(&mut self) { - // This depends somewhat heavily on the implementation of croaring, - // Ensure this is still valid every time we update the version of croaring. - const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 2 && ffi::ROARING_VERSION_MINOR == 0); - - // Per https://github.com/RoaringBitmap/CRoaring/blob/4f8dbdb0cc884626b20ef0cc9e891f701fe157cf/cpp/roaring.hh#L182 - // > By contract, calling roaring_bitmap_clear() is enough to - // > release all auxiliary memory used by the structure. - // - // We do not currently expose a way to get a frozen bitmap, but if we ever do, - // look at the roaring.hh destructor for implementation - unsafe { ffi::roaring_bitmap_clear(&mut self.bitmap) } - } -} - -macro_rules! impl_binop { - ( - impl $trait_name:ident { - $(type $type_name:ident = $type_value:ty;)* - - $(#[$($attr:tt)*])* - fn $fn_name:ident -> $ret_ty:ty as $alias:ident - } - ) => { - impl_binop!{ - impl $trait_name { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name(self, other) -> $ret_ty { - self.$alias(&other) - } - } - } - }; - ( - impl $trait_name:ident { - $(type $type_name:ident = $type_value:ty;)* - - $(#[$($attr:tt)*])* - fn $fn_name:ident($self_ident:ident, $other_ident:ident) -> $ret_ty:ty - $body:block - } - ) => { - impl $trait_name for Bitmap { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: Bitmap) -> $ret_ty - $body - } - - impl $trait_name<&Bitmap> for Bitmap { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &Bitmap) -> $ret_ty - $body - } - - impl $trait_name for &Bitmap { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: Bitmap) -> $ret_ty - $body - } - - impl $trait_name<&Bitmap> for &Bitmap { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &Bitmap) -> $ret_ty - $body - } - - impl $trait_name for BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: BitmapView<'_>) -> $ret_ty - $body - } - - impl $trait_name<&BitmapView<'_>> for BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &BitmapView<'_>) -> $ret_ty - $body - } - - impl $trait_name> for &BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: BitmapView<'_>) -> $ret_ty - $body - } - - impl $trait_name<&BitmapView<'_>> for &BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &BitmapView<'_>) -> $ret_ty - $body - } - - impl $trait_name for BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: Bitmap) -> $ret_ty - $body - } - - impl $trait_name<&Bitmap> for BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &Bitmap) -> $ret_ty - $body - } - - impl $trait_name<&Bitmap> for &BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: &Bitmap) -> $ret_ty - $body - } - - impl $trait_name for &BitmapView<'_> { - $(type $type_name = $type_value;)* - - $(#[$($attr)*])* - fn $fn_name($self_ident, $other_ident: Bitmap) -> $ret_ty - $body - } - }; -} - -macro_rules! impl_binop_assign { - ( - impl $trait_name:ident { - $(#[$($attr:tt)*])* - fn $fn_name:ident as $alias:ident - } - ) => { - impl $trait_name for Bitmap { - $(#[$($attr)*])* - fn $fn_name(&mut self, other: Bitmap) { - self.$alias(&other) - } - } - - impl $trait_name<&'_ Bitmap> for Bitmap { - $(#[$($attr)*])* - fn $fn_name(&mut self, other: &Bitmap) { - self.$alias(other) - } - } - - impl $trait_name> for Bitmap { - $(#[$($attr)*])* - fn $fn_name(&mut self, other: BitmapView<'_>) { - self.$alias(&other) - } - } - - impl $trait_name<&BitmapView<'_>> for Bitmap { - $(#[$($attr)*])* - fn $fn_name(&mut self, other: &BitmapView<'_>) { - self.$alias(other) - } - } - }; -} - -impl_binop! { - impl BitAnd { - type Output = Bitmap; - - /// Syntactic sugar for `.and` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::new(); - /// bitmap1.add(1); - /// - /// let mut bitmap2 = Bitmap::new(); - /// bitmap2.add(1); - /// bitmap2.add(2); - /// - /// let bitmap3 = bitmap1 & bitmap2; - /// - /// assert!(bitmap3.contains(1)); - /// assert!(!bitmap3.contains(2)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_and")] - fn bitand -> Bitmap as and - } -} - -impl_binop! { - impl BitOr { - type Output = Bitmap; - - /// Syntatic sugar for `.or` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// - /// let bitmap3 = bitmap1 | bitmap2; - /// - /// assert!(bitmap3.cardinality() == 2); - /// assert!(bitmap3.contains(15)); - /// assert!(bitmap3.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or")] - fn bitor -> Bitmap as or - } -} - -impl_binop! { - impl BitXor { - type Output = Bitmap; - - /// Syntatic sugar for `.xor` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// let bitmap3 = bitmap1 ^ bitmap2; - /// - /// assert!(bitmap3.cardinality() == 2); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// assert!(bitmap3.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor")] - fn bitxor -> Bitmap as xor - } -} - -impl_binop! { - impl Sub { - type Output = Bitmap; - - /// Syntatic sugar for `.andnot` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// let bitmap3 = bitmap1 - bitmap2; - /// - /// assert_eq!(bitmap3.cardinality(), 1); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// assert!(!bitmap3.contains(35)); - /// ``` - #[inline] - #[doc(alias = "andnot")] - #[doc(alias = "roaring_bitmap_andnot")] - fn sub -> Bitmap as andnot - } -} - -impl_binop_assign! { - impl BitAndAssign { - /// Syntactic sugar for `.and_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// let mut bitmap3 = Bitmap::of(&[15]); - /// let bitmap4 = Bitmap::of(&[15, 25]); - /// - /// bitmap1 &= bitmap2; - /// - /// assert!(bitmap1.cardinality() == 0); - /// assert!(!bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// - /// bitmap3 &= bitmap4; - /// - /// assert!(bitmap3.cardinality() == 1); - /// assert!(bitmap3.contains(15)); - /// assert!(!bitmap3.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_and_inplace")] - fn bitand_assign as and_inplace - } -} - -impl_binop_assign! { - impl BitOrAssign { - /// Syntatic sugar for `.or_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15]); - /// let bitmap2 = Bitmap::of(&[25]); - /// - /// bitmap1 |= bitmap2; - /// - /// assert!(bitmap1.cardinality() == 2); - /// assert!(bitmap1.contains(15)); - /// assert!(bitmap1.contains(25)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_or_inplace")] - fn bitor_assign as or_inplace - } -} - -impl_binop_assign! { - impl BitXorAssign { - /// Syntatic sugar for `.xor_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// bitmap1 ^= bitmap2; - /// - /// assert!(bitmap1.cardinality() == 2); - /// assert!(bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// assert!(bitmap1.contains(35)); - /// ``` - #[inline] - #[doc(alias = "roaring_bitmap_xor_inplace")] - fn bitxor_assign as xor_inplace - } -} - -impl_binop_assign! { - impl SubAssign { - /// Syntatic sugar for `.andnot_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Bitmap; - /// - /// let mut bitmap1 = Bitmap::of(&[15, 25]); - /// let bitmap2 = Bitmap::of(&[25, 35]); - /// - /// bitmap1 -= bitmap2; - /// - /// assert_eq!(bitmap1.cardinality(), 1); - /// assert!(bitmap1.contains(15)); - /// assert!(!bitmap1.contains(25)); - /// assert!(!bitmap1.contains(35)); - /// ``` - #[inline] - #[doc(alias = "andnot_inplace")] - #[doc(alias = "roaring_bitmap_andnot_inplace")] - fn sub_assign as andnot_inplace - } -} diff --git a/croaring/src/bitmap/serialization.rs b/croaring/src/bitmap/serialization.rs deleted file mode 100644 index 7e19d6f..0000000 --- a/croaring/src/bitmap/serialization.rs +++ /dev/null @@ -1,266 +0,0 @@ -use super::{Bitmap, BitmapView}; -use crate::serialization::{Frozen, Native, Portable}; - -use std::ffi::{c_char, c_void}; - -/// Trait for different formats of bitmap serialization -pub trait Serializer { - /// Serialize a bitmap into bytes, using the provided vec buffer to store the serialized data - /// - /// Note that some serializers ([Frozen]) may require that the bitmap is aligned specially, - /// this method will ensure that the returned slice of bytes is aligned correctly, by adding - /// additional padding before the serialized data if required. - /// - /// The contents of the provided vec buffer will not be overwritten: only new data will be - /// appended to the end of the buffer. If the buffer has enough capacity, and the current - /// end of the buffer is correctly aligned, then no additional allocations will be performed. - fn serialize_into<'a>(bitmap: &Bitmap, dst: &'a mut Vec) -> &'a [u8]; - /// Get the number of bytes required to serialize this bitmap - /// - /// This does not include any additional padding which may be required to align the bitmap - fn get_serialized_size_in_bytes(bitmap: &Bitmap) -> usize; -} - -/// Trait for different formats of bitmap deserialization -pub trait Deserializer { - /// Try to deserialize a bitmap from the beginning of the provided buffer - /// - /// The [`Bitmap::try_deserialize`] method should usually be used instead of this method - /// directly. - /// - /// If the buffer starts with the serialized representation of a bitmap, then - /// this method will return a new bitmap containing the deserialized data. - /// - /// If the buffer does not start with a serialized bitmap (or contains an invalidly - /// truncated bitmap), then this method will return `None`. - /// - /// To determine how many bytes were consumed from the buffer, use the - /// [`Serializer::get_serialized_size_in_bytes`] method on the returned bitmap. - fn try_deserialize(buffer: &[u8]) -> Option; - - /// Deserialize a bitmap from the beginning of the provided buffer - /// - /// # Safety - /// - /// Unlike its safe counterpart, [`try_deserialize`], this function assumes the data is valid, - /// passing data which does not contain/start with a bitmap serialized with this format will - /// result in undefined behavior. - unsafe fn try_deserialize_unchecked(buffer: &[u8]) -> Bitmap; -} - -/// Trait for different formats of bitmap deserialization into a view without copying -pub trait ViewDeserializer { - /// Create a bitmap view using the passed data - /// - /// # Safety - /// * `data` must be the result of serializing a roaring bitmap in this format. - /// * Its beginning must be aligned properly for this format. - /// * data.len() must be equal exactly to the size of the serialized bitmap. - /// - /// See [`BitmapView::deserialize`] for examples. - unsafe fn deserialize_view(data: &[u8]) -> BitmapView<'_>; -} - -impl Serializer for Portable { - /// Serializes a bitmap to a slice of bytes in portable format. - /// See [`Bitmap::serialize_into`] for examples. - #[doc(alias = "roaring_bitmap_portable_serialize")] - fn serialize_into<'a>(bitmap: &Bitmap, dst: &'a mut Vec) -> &'a [u8] { - let len = Self::get_serialized_size_in_bytes(bitmap); - - dst.reserve(len); - let offset = dst.len(); - let total_len = offset.checked_add(len).unwrap(); - - unsafe { - ffi::roaring_bitmap_portable_serialize( - &bitmap.bitmap, - dst.spare_capacity_mut().as_mut_ptr().cast::(), - ); - dst.set_len(total_len); - } - - &dst[offset..] - } - - /// Computes the serialized size in bytes of the Bitmap in portable format. - /// See [`Bitmap::get_serialized_size_in_bytes`] for examples. - #[doc(alias = "roaring_bitmap_portable_size_in_bytes")] - fn get_serialized_size_in_bytes(bitmap: &Bitmap) -> usize { - unsafe { ffi::roaring_bitmap_portable_size_in_bytes(&bitmap.bitmap) } - } -} - -impl Deserializer for Portable { - /// Given a serialized bitmap as slice of bytes in portable format, returns a `Bitmap` instance. - /// See [`Bitmap::try_deserialize`] for examples. - #[doc(alias = "roaring_bitmap_portable_deserialize_safe")] - fn try_deserialize(buffer: &[u8]) -> Option { - unsafe { - let bitmap = ffi::roaring_bitmap_portable_deserialize_safe( - buffer.as_ptr().cast::(), - buffer.len(), - ); - - if bitmap.is_null() { - return None; - } - - let bitmap = Bitmap::take_heap(bitmap); - if bitmap.internal_validate().is_ok() { - Some(bitmap) - } else { - None - } - } - } - - #[doc(alias = "roaring_bitmap_portable_deserialize")] - unsafe fn try_deserialize_unchecked(buffer: &[u8]) -> Bitmap { - let bitmap = ffi::roaring_bitmap_portable_deserialize(buffer.as_ptr().cast::()); - Bitmap::take_heap(bitmap) - } -} - -impl ViewDeserializer for Portable { - /// Read bitmap from a serialized buffer - /// - /// This is meant to be compatible with the Java and Go versions - /// - /// # Safety - /// * `data` must be the result of serializing a roaring bitmap in portable mode - /// (following `https://github.com/RoaringBitmap/RoaringFormatSpec`), for example, with - /// [`Bitmap::serialize`] - /// * Using this function (or the returned bitmap in any way) may execute unaligned memory accesses - /// - #[doc(alias = "roaring_bitmap_portable_deserialize_frozen")] - unsafe fn deserialize_view(data: &[u8]) -> BitmapView<'_> { - // portable_deserialize_size does some amount of checks, and returns zero if data cannot be valid - debug_assert_ne!( - ffi::roaring_bitmap_portable_deserialize_size(data.as_ptr().cast(), data.len()), - 0, - ); - let roaring = ffi::roaring_bitmap_portable_deserialize_frozen(data.as_ptr().cast()); - BitmapView::take_heap(roaring) - } -} - -impl Serializer for Native { - /// Serializes a bitmap to a slice of bytes in native format. - /// See [`Bitmap::serialize_into`] for examples. - #[doc(alias = "roaring_bitmap_serialize")] - fn serialize_into<'a>(bitmap: &Bitmap, dst: &'a mut Vec) -> &'a [u8] { - let len = Self::get_serialized_size_in_bytes(bitmap); - - dst.reserve(len); - let offset = dst.len(); - let total_len = offset.checked_add(len).unwrap(); - - unsafe { - ffi::roaring_bitmap_serialize( - &bitmap.bitmap, - dst.spare_capacity_mut().as_mut_ptr().cast::(), - ); - dst.set_len(total_len); - } - - &dst[offset..] - } - - /// Computes the serialized size in bytes of the Bitmap in native format. - /// See [`Bitmap::get_serialized_size_in_bytes`] for examples. - #[doc(alias = "roaring_bitmap_size_in_bytes")] - fn get_serialized_size_in_bytes(bitmap: &Bitmap) -> usize { - unsafe { ffi::roaring_bitmap_size_in_bytes(&bitmap.bitmap) } - } -} - -impl Deserializer for Native { - /// Given a serialized bitmap as slice of bytes in native format, returns a `Bitmap` instance. - /// See [`Bitmap::try_deserialize`] for examples. - #[doc(alias = "roaring_bitmap_deserialize_safe")] - fn try_deserialize(buffer: &[u8]) -> Option { - unsafe { - let bitmap = ffi::roaring_bitmap_deserialize_safe( - buffer.as_ptr().cast::(), - buffer.len(), - ); - - if bitmap.is_null() { - return None; - } - let bitmap = Bitmap::take_heap(bitmap); - if bitmap.internal_validate().is_ok() { - Some(bitmap) - } else { - None - } - } - } - - #[doc(alias = "roaring_bitmap_deserialize")] - unsafe fn try_deserialize_unchecked(buffer: &[u8]) -> Bitmap { - let bitmap = ffi::roaring_bitmap_deserialize(buffer.as_ptr().cast::()); - Bitmap::take_heap(bitmap) - } -} - -impl Serializer for Frozen { - /// Serializes a bitmap to a slice of bytes in "frozen" format. - /// - /// This has an odd API because it always returns a slice which is aligned to 32 bytes: - /// This means the returned slice may not start exactly at the beginning of the passed `Vec` - /// See [`Bitmap::serialize_into`] for examples. - #[doc(alias = "roaring_bitmap_frozen_serialize")] - fn serialize_into<'a>(bitmap: &Bitmap, dst: &'a mut Vec) -> &'a [u8] { - let len = Self::get_serialized_size_in_bytes(bitmap); - - let mut offset = dst.len(); - if dst.capacity() < dst.len() + len - || Self::required_padding(dst.as_ptr_range().end as usize) != 0 - { - dst.reserve(len.checked_add(Self::MAX_PADDING).unwrap()); - let extra_offset = Self::required_padding(dst.as_ptr_range().end as usize); - offset = offset.checked_add(extra_offset).unwrap(); - // we must initialize up to offset - dst.resize(offset, 0); - } - let total_len = offset.checked_add(len).unwrap(); - debug_assert!(dst.capacity() >= total_len); - - unsafe { - ffi::roaring_bitmap_frozen_serialize( - &bitmap.bitmap, - dst.as_mut_ptr().add(offset).cast::(), - ); - dst.set_len(total_len); - } - - &dst[offset..total_len] - } - - /// Computes the serialized size in bytes of the Bitmap in frozen format. - /// See [`Bitmap::get_serialized_size_in_bytes`] for examples. - #[doc(alias = "roaring_bitmap_frozen_size_in_bytes")] - fn get_serialized_size_in_bytes(bitmap: &Bitmap) -> usize { - unsafe { ffi::roaring_bitmap_frozen_size_in_bytes(&bitmap.bitmap) } - } -} - -impl ViewDeserializer for Frozen { - /// Create a frozen bitmap view using the passed data - /// - /// # Safety - /// * `data` must be the result of serializing a roaring bitmap in frozen mode - /// (in c with `roaring_bitmap_frozen_serialize`, or via [`Bitmap::serialize_into::`]). - /// * Its beginning must be aligned by 32 bytes. - /// * data.len() must be equal exactly to the size of the frozen bitmap. - /// - /// See [`BitmapView::deserialize`] for examples. - unsafe fn deserialize_view(data: &[u8]) -> BitmapView<'_> { - assert_eq!(data.as_ptr() as usize % Self::REQUIRED_ALIGNMENT, 0); - - let roaring = ffi::roaring_bitmap_frozen_view(data.as_ptr().cast(), data.len()); - BitmapView::take_heap(roaring) - } -} diff --git a/croaring/src/bitmap/view.rs b/croaring/src/bitmap/view.rs deleted file mode 100644 index 543e45d..0000000 --- a/croaring/src/bitmap/view.rs +++ /dev/null @@ -1,129 +0,0 @@ -use super::serialization::ViewDeserializer; -use super::{Bitmap, BitmapView}; -use ffi::roaring_bitmap_t; -use std::marker::PhantomData; -use std::ops::Deref; -use std::{fmt, mem}; - -#[inline] -const fn original_bitmap_ptr(bitmap: &roaring_bitmap_t) -> *const roaring_bitmap_t { - // The implementation must put the containers array immediately after the bitmap pointer - bitmap - .high_low_container - .containers - .cast::() - // wrapping_sub to ensure we can still check this ptr against the original even if - // this isn't actually the correct pointer because of a change in CRoaring implementation - .wrapping_sub(1) -} - -impl<'a> BitmapView<'a> { - #[inline] - #[allow(clippy::assertions_on_constants)] - pub(crate) unsafe fn take_heap(p: *const roaring_bitmap_t) -> Self { - // This depends somewhat heavily on the implementation of croaring, - // In particular, that `roaring_bitmap_t` doesn't store any pointers into itself - // (it can be moved safely), and a "frozen" bitmap is stored in an arena, and the - // `containers` array is stored immediately after the roaring_bitmap_t data. - // Ensure this is still valid every time we update - // the version of croaring. - const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 2 && ffi::ROARING_VERSION_MINOR == 0); - - assert!(!p.is_null()); - - // We will use this in the Drop implementation to re-create this pointer to pass to roaring_bitmap_free - // If this fails, we would pass junk to roaring_bitmap_free in Drop. - assert_eq!(p, original_bitmap_ptr(&*p)); - - Self { - bitmap: *p, - phantom: PhantomData, - } - } - - /// Create a bitmap view of a slice of data without copying - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, BitmapView, Portable}; - /// let orig_bitmap = Bitmap::of(&[1, 2, 3, 4]); - /// let data: Vec = orig_bitmap.serialize::(); - /// let view = unsafe { BitmapView::deserialize::(&data) }; - /// assert!(view.contains_range(1..=4)); - /// assert_eq!(orig_bitmap, view); - /// ``` - /// - /// # Safety - /// - /// The data must be the result of serializing a bitmap with the same serialization format - #[must_use] - pub unsafe fn deserialize(data: &'a [u8]) -> Self { - S::deserialize_view(data) - } - - /// Create an owned, mutable bitmap from this view - /// - /// # Examples - /// - /// ``` - /// use croaring::{Bitmap, BitmapView, Portable}; - /// - /// let orig_bitmap = Bitmap::of(&[1, 2, 3, 4]); - /// let data = orig_bitmap.serialize::(); - /// let view: BitmapView = unsafe { BitmapView::deserialize::(&data) }; - /// # assert_eq!(view, orig_bitmap); - /// let mut mutable_bitmap: Bitmap = view.to_bitmap(); - /// assert_eq!(view, mutable_bitmap); - /// mutable_bitmap.add(10); - /// assert!(!view.contains(10)); - /// assert!(mutable_bitmap.contains(10)); - /// ``` - #[must_use] - pub fn to_bitmap(&self) -> Bitmap { - (**self).clone() - } -} - -impl<'a> Deref for BitmapView<'a> { - type Target = Bitmap; - - fn deref(&self) -> &Self::Target { - const _: () = assert!(mem::size_of::() == mem::size_of::()); - const _: () = assert!(mem::align_of::() == mem::align_of::()); - // SAFETY: - // Bitmap and BitmapView are repr(transparent), and both only wrap a roaring_bitmap_t - // Bitmap provides no features with a shared reference which modifies the underlying bitmap - unsafe { mem::transmute::<&BitmapView, &Bitmap>(self) } - } -} - -impl PartialEq for BitmapView<'_> { - fn eq(&self, other: &Self) -> bool { - Bitmap::eq(self, other) - } -} - -impl Eq for BitmapView<'_> {} - -impl<'a> Drop for BitmapView<'a> { - fn drop(&mut self) { - // Based heavily on the c++ wrapper included in CRoaring - // - // The roaring member variable copies the `roaring_bitmap_t` and - // nested `roaring_array_t` structures by value and is freed in the - // constructor, however the underlying memory arena used for the - // container data is not freed with it. Here we derive the arena - // pointer from the second arena allocation in - // `roaring_bitmap_frozen_view` and free it as well. - unsafe { - ffi::roaring_bitmap_free(original_bitmap_ptr(&self.bitmap)); - } - } -} - -impl<'a> fmt::Debug for BitmapView<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (**self).fmt(f) - } -} diff --git a/croaring/src/bitset/imp.rs b/croaring/src/bitset/imp.rs deleted file mode 100644 index e42d3ad..0000000 --- a/croaring/src/bitset/imp.rs +++ /dev/null @@ -1,500 +0,0 @@ -use super::Bitset; -use std::{mem, ptr}; - -impl Bitset { - #[inline] - #[allow(clippy::assertions_on_constants)] - pub(super) unsafe fn take_heap(p: *mut ffi::bitset_t) -> Self { - assert!(!p.is_null()); - let result = Self { bitset: p.read() }; - // It seems unlikely that the bitset type will meaningfully change, but check if we ever go - // to a version 3. - const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 2); - ffi::roaring_free(p.cast()); - result - } - - /// Access the raw underlying slice - #[inline] - #[must_use] - pub const fn as_slice(&self) -> &[u64] { - if self.bitset.arraysize == 0 { - &[] - } else { - unsafe { std::slice::from_raw_parts(self.bitset.array, self.bitset.arraysize) } - } - } - - /// Access the raw underlying slice - #[inline] - pub fn as_mut_slice(&mut self) -> &mut [u64] { - if self.bitset.arraysize == 0 { - &mut [] - } else { - unsafe { std::slice::from_raw_parts_mut(self.bitset.array, self.bitset.arraysize) } - } - } - - /// Create a new bitset - /// - /// Does not allocate - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let bitset = Bitset::new(); - /// assert_eq!(bitset.capacity(), 0); - /// assert_eq!(bitset.size_in_bits(), 0); - /// ``` - #[inline] - #[doc(alias = "bitset_create")] - #[must_use] - pub const fn new() -> Self { - Self { - bitset: ffi::bitset_t { - array: ptr::null_mut(), - arraysize: 0, - capacity: 0, - }, - } - } - - /// Create a new bitset of the specified size - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let bitset = Bitset::with_size(100); - /// // Actual size/capacity may be rounded up - /// assert!(bitset.capacity() >= 100); - /// assert!(bitset.size_in_bits() >= 100); - /// ``` - #[inline] - #[doc(alias = "bitset_create_with_capacity")] - #[must_use] - pub fn with_size(size: usize) -> Self { - unsafe { Self::take_heap(ffi::bitset_create_with_capacity(size)) } - } - - /// Capacity in bits - #[inline] - #[must_use] - pub const fn capacity(&self) -> usize { - self.bitset.capacity * 64 - } - - /// Set all bits to zero - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::with_size(64); - /// bitset.fill(true); - /// assert!(bitset.get(1)); - /// assert!(bitset.get(63)); - /// // Bitset size stays the same - /// assert!(!bitset.get(64)); - /// bitset.fill(false); - /// assert!(!bitset.get(1)); - /// assert!(!bitset.get(63)); - /// assert!(!bitset.get(64)); - /// ``` - #[inline] - #[doc(alias = "bitset_clear")] - #[doc(alias = "bitset_fill")] - pub fn fill(&mut self, value: bool) { - if value { - unsafe { ffi::bitset_fill(&mut self.bitset) }; - } else { - unsafe { ffi::bitset_clear(&mut self.bitset) }; - } - } - - /// How many bytes of memory the backend buffer uses - #[inline] - #[doc(alias = "bitset_size_in_bytes")] - #[must_use] - pub const fn size_in_bytes(&self) -> usize { - self.size_in_words() * mem::size_of::() - } - - /// How many bits can be accessed - #[inline] - #[doc(alias = "bitset_size_in_bits")] - #[must_use] - pub const fn size_in_bits(&self) -> usize { - self.size_in_bytes() * 8 - } - - /// How many 64-bit words of memory the backend buffer uses - #[inline] - #[doc(alias = "bitset_size_in_words")] - #[must_use] - pub const fn size_in_words(&self) -> usize { - self.bitset.arraysize - } - - /// Resize the bitset to contain `new_array_size` 64-bit words - /// - /// New bits are set to `value` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// bitset.resize_words(1, false); - /// bitset.resize_words(2, true); - /// assert_eq!(bitset.iter().collect::>(), (64..128).collect::>()); - /// ``` - pub fn resize_words(&mut self, new_array_size: usize, value: bool) { - let old_array_size = self.bitset.arraysize; - let res = unsafe { ffi::bitset_resize(&mut self.bitset, new_array_size, value) }; - assert!(res); - if new_array_size > old_array_size { - let new_data_slice = &mut self.as_mut_slice()[old_array_size..]; - new_data_slice.fill(u64::from(value) * !0); - } - } - - /// For advanced users: Grow the bitset so that it can support newarraysize * 64 bits with padding. - /// Return true in case of success, false for failure - #[inline] - #[doc(alias = "bitset_grow")] - fn grow(&mut self, new_array_size: usize) { - assert!(unsafe { ffi::bitset_grow(&mut self.bitset, new_array_size) }); - } - - /// Attempts to recover unused memory by shrinking capacity to fit the highest set bit - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// bitset.set(63); - /// bitset.set(1000); - /// assert!(bitset.size_in_bits() > 1000); - /// bitset.set_to_value(1000, false); - /// bitset.shrink_to_fit(); - /// // The next highest bit is at index 63 - /// assert_eq!(bitset.size_in_bits(), 64); - #[inline] - #[doc(alias = "bitset_trim")] - pub fn shrink_to_fit(&mut self) { - unsafe { ffi::bitset_trim(&mut self.bitset) }; - } - - /// Set the ith bit - /// - /// Will resize the bitset if needed, any other newly added bits will be initialized to zero - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// bitset.set(1); - /// bitset.set(2); - /// bitset.set(100); - /// assert_eq!(bitset.iter().collect::>(), vec![1, 2, 100]); - /// ``` - #[inline] - #[doc(alias = "bitset_set")] - pub fn set(&mut self, i: usize) { - let array_idx = i / 64; - if array_idx >= self.bitset.arraysize { - self.grow(array_idx + 1); - } - self.as_mut_slice()[array_idx] |= 1 << (i % 64); - } - - /// Set the ith bit to `value` - /// - /// Will resize the bitset if needed, any other newly added bits will be initialized to zero - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// bitset.set_to_value(1, true); - /// bitset.set_to_value(2, true); - /// bitset.set_to_value(100, true); - /// bitset.set_to_value(1, false); - /// assert_eq!(bitset.iter().collect::>(), vec![2, 100]); - /// ``` - #[inline] - #[doc(alias = "bitset_set_to_value")] - pub fn set_to_value(&mut self, i: usize, value: bool) { - let array_idx = i / 64; - if array_idx >= self.bitset.arraysize { - self.grow(array_idx + 1); - } - let dst = &mut self.as_mut_slice()[array_idx]; - let mask = 1 << (i % 64); - let value_bit = u64::from(value) << (i % 64); - let mut word = *dst; - word &= !mask; - word |= value_bit; - *dst = word; - } - - /// Get the value of the ith bit - /// - /// If the bit is out of bounds, returns false - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// bitset.set(1); - /// bitset.set(2); - /// assert!(bitset.get(1)); - /// assert!(bitset.get(2)); - /// assert!(!bitset.get(3)); - /// ``` - #[inline] - #[doc(alias = "bitset_get")] - #[must_use] - pub const fn get(&self, i: usize) -> bool { - let array_idx = i / 64; - if array_idx >= self.bitset.arraysize { - return false; - } - let word = self.as_slice()[array_idx]; - let mask = 1 << (i % 64); - (word & mask) != 0 - } - - /// Count of number of set bits - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// assert_eq!(bitset.count(), 4); - /// ``` - #[inline] - #[doc(alias = "bitset_count")] - #[must_use] - pub fn count(&self) -> usize { - unsafe { ffi::bitset_count(&self.bitset) } - } - - /// Index of the first set bit, or zero if the bitset has no set bits - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// // minimum returns 0 if the bitset is empty - /// assert_eq!(bitset.minimum(), 0); - /// bitset.set(100); - /// assert_eq!(bitset.minimum(), 100); - /// ``` - #[inline] - #[doc(alias = "bitset_minimum")] - #[must_use] - pub fn minimum(&self) -> usize { - unsafe { ffi::bitset_minimum(&self.bitset) } - } - - /// Index of the last set bit, or zero if the bitset has no set bits - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset = Bitset::new(); - /// // maximum returns 0 if the bitset is empty - /// assert_eq!(bitset.maximum(), 0); - /// bitset.set(100); - /// assert_eq!(bitset.maximum(), 100); - /// bitset.set(1000); - /// assert_eq!(bitset.maximum(), 1000); - /// ``` - #[inline] - #[doc(alias = "bitset_maximum")] - #[must_use] - pub fn maximum(&self) -> usize { - unsafe { ffi::bitset_maximum(&self.bitset) } - } - - /// The size of the hypothetical union of `self` and `other` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert_eq!(bitset1.union_count(&bitset2), 6); - /// bitset1 |= &bitset2; - /// assert_eq!(bitset1.count(), 6); - /// ``` - #[inline] - #[doc(alias = "bitset_union_count")] - #[must_use] - pub fn union_count(&self, other: &Self) -> usize { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return self.count(); - } - unsafe { ffi::bitset_union_count(&self.bitset, &other.bitset) } - } - - /// The size of the hypothetical intersection of `self` and `other` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert_eq!(bitset1.intersection_count(&bitset2), 2); - /// bitset1 &= &bitset2; - /// assert_eq!(bitset1.count(), 2); - /// ``` - #[inline] - #[doc(alias = "bitset_intersection_count")] - #[must_use] - pub fn intersection_count(&self, other: &Self) -> usize { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return self.count(); - } - unsafe { ffi::bitset_intersection_count(&self.bitset, &other.bitset) } - } - - /// Return true if `self` and `other` contain no common elements - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert!(!bitset1.is_disjoint(&bitset2)); - /// let bitset3: Bitset = [4, 5, 6, 7].into_iter().collect(); - /// assert!(bitset1.is_disjoint(&bitset3)); - /// ``` - /// - /// Empty bitsets are always disjoint - /// - /// ``` - /// use croaring::Bitset; - /// let bitset1 = Bitset::new(); - /// let bitset2 = Bitset::new(); - /// assert!(bitset1.is_disjoint(&bitset2)); - /// ``` - #[inline] - #[doc(alias = "bitset_disjoint")] - #[must_use] - pub fn is_disjoint(&self, other: &Self) -> bool { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return false; - } - unsafe { ffi::bitsets_disjoint(&self.bitset, &other.bitset) } - } - - /// Return true if `self` and `other` contain at least one common element - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert!(bitset1.has_intersect(&bitset2)); - /// let bitset3: Bitset = [4, 5, 6, 7].into_iter().collect(); - /// assert!(!bitset1.has_intersect(&bitset3)); - /// ``` - #[inline] - #[doc(alias = "bitset_intersect")] - #[must_use] - pub fn has_intersect(&self, other: &Self) -> bool { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return true; - } - unsafe { ffi::bitsets_intersect(&self.bitset, &other.bitset) } - } - - /// Return true if `self` is a superset of `other` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3].into_iter().collect(); - /// assert!(bitset1.is_superset(&bitset2)); - /// let bitset3: Bitset = [4, 5, 6, 7].into_iter().collect(); - /// assert!(!bitset1.is_superset(&bitset3)); - /// ``` - #[inline] - #[doc(alias = "bitset_contains_all")] - #[must_use] - pub fn is_superset(&self, other: &Self) -> bool { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return true; - } - unsafe { ffi::bitset_contains_all(&self.bitset, &other.bitset) } - } - - /// The size of the hypothetical difference of `self` and `other` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert_eq!(bitset1.difference_count(&bitset2), 2); - /// bitset1 -= &bitset2; - /// assert_eq!(bitset1.count(), 2); - /// ``` - #[inline] - #[doc(alias = "bitset_difference_count")] - #[must_use] - pub fn difference_count(&self, other: &Self) -> usize { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return 0; - } - unsafe { ffi::bitset_difference_count(&self.bitset, &other.bitset) } - } - - /// The size of the hypothetical symmetric difference (xor) of `self` and `other` - /// - /// # Examples - /// ``` - /// use croaring::Bitset; - /// let mut bitset1: Bitset = [1, 2, 3, 100].into_iter().collect(); - /// let bitset2: Bitset = [2, 3, 4, 5].into_iter().collect(); - /// assert_eq!(bitset1.symmetric_difference_count(&bitset2), 4); - /// bitset1 ^= &bitset2; - /// assert_eq!(bitset1.count(), 4); - /// ``` - #[inline] - #[doc(alias = "bitset_symmetric_difference_count")] - #[doc(alias = "xor_count")] - #[must_use] - pub fn symmetric_difference_count(&self, other: &Self) -> usize { - // CRoaring uses restrict pointers, so we can't use the same pointer for both - if ptr::eq(self, other) { - return 0; - } - unsafe { ffi::bitset_symmetric_difference_count(&self.bitset, &other.bitset) } - } - - /// Expose the raw `CRoaring` bitset - /// - /// This allows calling raw `CRoaring` functions on the bitset. - #[inline] - #[must_use] - pub fn as_raw(&self) -> &ffi::bitset_t { - &self.bitset - } - - /// Expose the raw `CRoaring` bitset mutably - /// - /// This allows calling raw `CRoaring` functions on the bitset. - #[inline] - #[must_use] - pub fn as_raw_mut(&mut self) -> &mut ffi::bitset_t { - &mut self.bitset - } -} diff --git a/croaring/src/bitset/iter.rs b/croaring/src/bitset/iter.rs deleted file mode 100644 index 8c99222..0000000 --- a/croaring/src/bitset/iter.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::Bitset; - -/// Iterator over set bits in a bitset -pub struct BitsetIterator<'a> { - bitset: &'a Bitset, - current: usize, -} - -impl<'a> BitsetIterator<'a> { - fn next_set_bits(&mut self, buffer: &mut [usize]) -> usize { - let mut current = self.current; - let len = unsafe { - ffi::bitset_next_set_bits( - &self.bitset.bitset, - buffer.as_mut_ptr(), - buffer.len(), - &mut current, - ) - }; - self.current = current + 1; - len - } -} - -impl<'a> Iterator for BitsetIterator<'a> { - type Item = usize; - - #[doc(alias = "bitset_next_set_bit")] - fn next(&mut self) -> Option { - let has_value = unsafe { ffi::bitset_next_set_bit(&self.bitset.bitset, &mut self.current) }; - let value = self.current; - self.current += 1; - has_value.then_some(value) - } - - fn size_hint(&self) -> (usize, Option) { - (0, Some(self.bitset.size_in_bits() - self.current)) - } - - #[doc(alias = "bitset_next_set_bits")] - fn fold(mut self, init: B, mut f: F) -> B - where - Self: Sized, - F: FnMut(B, Self::Item) -> B, - { - let mut acc = init; - let mut buffer = [0; 512]; - loop { - let count = self.next_set_bits(&mut buffer); - if count == 0 { - return acc; - } - for &value in &buffer[..count] { - acc = f(acc, value); - } - } - } -} - -impl<'a> IntoIterator for &'a Bitset { - type Item = usize; - type IntoIter = BitsetIterator<'a>; - - #[inline] - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl Bitset { - /// Returns an iterator over the set bits in the bitset - #[inline] - #[must_use] - pub const fn iter(&self) -> BitsetIterator<'_> { - BitsetIterator { - bitset: self, - current: 0, - } - } -} diff --git a/croaring/src/bitset/mod.rs b/croaring/src/bitset/mod.rs deleted file mode 100644 index 5eb1c9e..0000000 --- a/croaring/src/bitset/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! Dense bitset implementation - -mod imp; -mod iter; -mod ops; - -/// A dense bitset -#[repr(transparent)] -pub struct Bitset { - bitset: ffi::bitset_t, -} - -pub use self::iter::BitsetIterator; - -unsafe impl Sync for Bitset {} -unsafe impl Send for Bitset {} diff --git a/croaring/src/bitset/ops.rs b/croaring/src/bitset/ops.rs deleted file mode 100644 index e56b0a1..0000000 --- a/croaring/src/bitset/ops.rs +++ /dev/null @@ -1,95 +0,0 @@ -use super::Bitset; -use std::ffi::c_void; -use std::{fmt, ops}; - -impl Default for Bitset { - #[inline] - fn default() -> Self { - Self::new() - } -} - -impl Clone for Bitset { - fn clone(&self) -> Self { - unsafe { Bitset::take_heap(ffi::bitset_copy(&self.bitset)) } - } -} - -impl Extend for Bitset { - fn extend>(&mut self, iter: T) { - for value in iter { - self.set(value); - } - } -} - -impl FromIterator for Bitset { - fn from_iter>(iter: T) -> Self { - let mut bitset = Bitset::new(); - bitset.extend(iter); - bitset - } -} - -impl ops::ShlAssign for Bitset { - #[inline] - #[doc(alias = "bitset_shift_left")] - fn shl_assign(&mut self, shift: usize) { - unsafe { ffi::bitset_shift_left(&mut self.bitset, shift) }; - } -} - -impl ops::ShrAssign for Bitset { - #[inline] - #[doc(alias = "bitset_shift_right")] - fn shr_assign(&mut self, shift: usize) { - unsafe { ffi::bitset_shift_right(&mut self.bitset, shift) }; - } -} - -impl ops::BitOrAssign<&Bitset> for Bitset { - #[inline] - #[doc(alias = "bitset_inplace_union")] - fn bitor_assign(&mut self, rhs: &Bitset) { - let result = unsafe { ffi::bitset_inplace_union(&mut self.bitset, &rhs.bitset) }; - assert!(result); - } -} - -impl ops::BitAndAssign<&Bitset> for Bitset { - #[inline] - #[doc(alias = "bitset_inplace_intersection")] - fn bitand_assign(&mut self, rhs: &Bitset) { - unsafe { ffi::bitset_inplace_intersection(&mut self.bitset, &rhs.bitset) }; - } -} - -impl ops::SubAssign<&Bitset> for Bitset { - #[inline] - #[doc(alias = "bitset_inplace_difference")] - fn sub_assign(&mut self, rhs: &Bitset) { - unsafe { ffi::bitset_inplace_difference(&mut self.bitset, &rhs.bitset) }; - } -} - -impl ops::BitXorAssign<&Bitset> for Bitset { - #[inline] - #[doc(alias = "bitset_inplace_symmetric_difference")] - fn bitxor_assign(&mut self, rhs: &Bitset) { - unsafe { ffi::bitset_inplace_symmetric_difference(&mut self.bitset, &rhs.bitset) }; - } -} - -impl fmt::Debug for Bitset { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_set().entries(self.iter()).finish() - } -} - -impl Drop for Bitset { - fn drop(&mut self) { - unsafe { - ffi::roaring_free(self.bitset.array.cast::()); - } - } -} diff --git a/croaring/src/lib.rs b/croaring/src/lib.rs deleted file mode 100644 index 680262d..0000000 --- a/croaring/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![deny(missing_docs)] -//! Rust wrapper for `CRoaring` (a C/C++ implementation at ) -//! -//! Provides Compressed Bitmaps, which act like a set of integers in an efficient way. - -pub mod bitmap; -pub mod bitset; -pub mod treemap; - -mod serialization; - -pub use serialization::*; - -pub use bitmap::Bitmap; -pub use bitset::Bitset; -pub use treemap::Treemap; - -pub use bitmap::BitmapView; diff --git a/croaring/src/serialization.rs b/croaring/src/serialization.rs deleted file mode 100644 index bcb56b3..0000000 --- a/croaring/src/serialization.rs +++ /dev/null @@ -1,45 +0,0 @@ -/// The `Portable` format is meant to be compatible with other roaring bitmap libraries, such as Go or Java. -/// -/// Note despite the name, it is not fully portable: it depends on native endianness. -/// -/// It's defined here: -pub enum Portable {} - -/// The `Native` format format can sometimes be more space efficient than [`Portable`], -/// -/// e.g. when the data is sparse. It's not compatible with Java and Go implementations. -/// Use [`Portable`] for that purpose. -pub enum Native {} - -/// The `Frozen` format imitates memory layout of the underlying C library. -/// -/// This reduces amount of allocations and copying required during deserialization, though -/// `Portable` offers comparable performance. -/// -/// Note that because frozen serialization format imitates C memory layout -/// of `roaring_bitmap_t`, it is not fixed. It is different on big/little endian -/// platforms and can be changed in future. -pub enum Frozen {} - -impl Frozen { - /// The frozen format requires bitmaps are aligned to 32 bytes. - pub const REQUIRED_ALIGNMENT: usize = 32; - - // The most padding required to get 32 byte alignment is 31 bytes. - pub(crate) const MAX_PADDING: usize = Self::REQUIRED_ALIGNMENT - 1; - - #[inline] - pub(crate) const fn required_padding(x: usize) -> usize { - match x % Self::REQUIRED_ALIGNMENT { - 0 => 0, - r => Self::REQUIRED_ALIGNMENT - r, - } - } -} - -/// The `JvmLegacy` format is meant to be compatible with the original Java implementation of `Roaring64NavigableMap` -/// -/// It is used only for [Treemap][crate::Treemap]s, not bitmaps. -/// -/// See -pub enum JvmLegacy {} diff --git a/croaring/src/treemap/imp.rs b/croaring/src/treemap/imp.rs deleted file mode 100644 index 05e9201..0000000 --- a/croaring/src/treemap/imp.rs +++ /dev/null @@ -1,1249 +0,0 @@ -use crate::Bitmap; -use crate::Treemap; - -use super::util; -use crate::treemap::{Deserializer, Serializer}; -use std::collections::btree_map::Entry; -use std::collections::BTreeMap; -use std::ops::{Bound, RangeBounds}; -use std::{io, u64}; - -impl Treemap { - /// Creates an empty `Treemap`. - /// - /// # Examples - /// - /// ```rust - /// use croaring::Treemap; - /// let treemap = Treemap::new(); - /// ``` - #[must_use] - pub fn new() -> Self { - Treemap { - map: BTreeMap::new(), - } - } - - /// Creates a `Treemap` with the contents of a `Bitmap`. - /// - /// # Examples - /// - /// ```rust - /// use croaring::Treemap; - /// use croaring::Bitmap; - /// - /// let bitmap = Bitmap::of(&[1, 2, 3]); - /// let treemap = Treemap::from_bitmap(bitmap); - /// assert_eq!(treemap.cardinality(), 3); - /// ``` - #[must_use] - pub fn from_bitmap(bitmap: Bitmap) -> Self { - let mut map = BTreeMap::new(); - map.insert(0, bitmap); - Treemap { map } - } - - /// Add the integer element to the bitmap - /// - /// # Examples - /// - /// ```rust - /// use std::u32; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(3); - /// assert!(treemap.contains(3)); - /// treemap.add(u32::MAX as u64); - /// assert!(treemap.contains(u32::MAX as u64)); - /// treemap.add(u64::from(u32::MAX) + 1); - /// assert!(treemap.contains(u64::from(u32::MAX)+ 1)); - /// ``` - pub fn add(&mut self, value: u64) { - let (hi, lo) = util::split(value); - self.get_or_create(hi).add(lo); - } - - /// Add the integer element to the bitmap. Returns true if the value was - /// added, false if the value was already in the bitmap. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut bitmap = Treemap::new(); - /// assert!(bitmap.add_checked(1)); - /// assert!(!bitmap.add_checked(1)); - /// ``` - pub fn add_checked(&mut self, value: u64) -> bool { - let (hi, lo) = util::split(value); - self.get_or_create(hi).add_checked(lo) - } - - /// Add all values in range - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add_range((1..3)); - /// - /// assert!(!treemap1.is_empty()); - /// assert!(treemap1.contains(1)); - /// assert!(treemap1.contains(2)); - /// assert!(!treemap1.contains(3)); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add_range((3..1)); - /// assert!(treemap2.is_empty()); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add_range((3..3)); - /// assert!(treemap3.is_empty()); - /// - /// let mut treemap4 = Treemap::new(); - /// treemap4.add_range(..=2); - /// treemap4.add_range(u64::MAX..=u64::MAX); - /// assert!(treemap4.contains(0)); - /// assert!(treemap4.contains(1)); - /// assert!(treemap4.contains(2)); - /// assert!(treemap4.contains(u64::MAX)); - /// assert_eq!(treemap4.cardinality(), 4); - /// ``` - pub fn add_range>(&mut self, range: R) { - let (start, end) = range_to_inclusive(range); - self.add_range_inclusive(start, end); - } - - fn add_range_inclusive(&mut self, start: u64, end: u64) { - if start > end { - return; - } - let (start_high, start_low) = util::split(start); - let (end_high, end_low) = util::split(end); - if start_high == end_high { - self.map - .entry(start_high) - .or_default() - .add_range(start_low..=end_low); - return; - } - - // Because start and end don't land on the same inner bitmap, - // we need to do this in multiple steps: - // 1. Partially fill the first bitmap with values from the closed - // interval [start_low, uint32_max] - // 2. Fill intermediate bitmaps completely: [0, uint32_max] - // 3. Partially fill the last bitmap with values from the closed - // interval [0, end_low] - - // Step 1: Partially fill the first bitmap - { - let bitmap = self.get_or_create(start_high); - bitmap.add_range(start_low..=u32::MAX); - } - // Step 2: Fill intermediate bitmaps completely - for i in start_high + 1..end_high { - // This blows away the container, is it worth trying to save any existing alocations? - self.map.insert(i, Bitmap::from_range(0..=u32::MAX)); - } - // Step 3: Partially fill the last bitmap - { - let bitmap = self.get_or_create(end_high); - bitmap.add_range(0..=end_low); - } - } - - /// ```rust - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// ``` - #[must_use] - pub fn contains(&self, value: u64) -> bool { - let (hi, lo) = util::split(value); - match self.map.get(&hi) { - None => false, - Some(r) => r.contains(lo), - } - } - - /// Returns true if the Treemap is empty. - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// - /// assert!(treemap.is_empty()); - /// - /// treemap.add(u64::MAX); - /// - /// assert!(!treemap.is_empty()); - /// ``` - #[must_use] - pub fn is_empty(&self) -> bool { - self.map.values().all(Bitmap::is_empty) - } - - /// Returns true if the Treemap is full. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// assert!(!treemap.is_full()); - /// ``` - #[must_use] - pub fn is_full(&self) -> bool { - // only bother to check if map is fully saturated - if self.map.len() != usize::try_from(u32::MAX).unwrap() + 1 { - return false; - } - self.map - .values() - .all(|bitmap| bitmap.cardinality() == u64::from(u32::MAX) + 1) - } - - /// Return true if all the elements of Self are in &other. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let bitmap1: Treemap = (5..10).collect(); - /// let bitmap2: Treemap = (5..8).collect(); - /// let bitmap3: Treemap = (5..10).collect(); - /// let bitmap4: Treemap = (9..11).collect(); - /// - /// assert!(bitmap2.is_subset(&bitmap1)); - /// assert!(bitmap3.is_subset(&bitmap1)); - /// assert!(!bitmap4.is_subset(&bitmap1)); - /// ``` - #[must_use] - pub fn is_subset(&self, other: &Treemap) -> bool { - self.map.iter().all(|(key, lhs)| { - lhs.is_empty() || other.map.get(key).map_or(false, |rhs| lhs.is_subset(rhs)) - }) - } - - /// Returns true if this bitmap is a strict subset of `other` - #[must_use] - pub fn is_strict_subset(&self, other: &Treemap) -> bool { - self.is_subset(other) && self.cardinality() != other.cardinality() - } - - /// Negate the bits in the given range, any bit set in the range is cleared, and any bit cleared - /// - /// Areas outside the interval are unchanged - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add_range(1..5); - /// treemap.flip(2..10); - /// assert_eq!(treemap.cardinality(), 6); - /// assert_eq!(treemap.iter().collect::>(), vec![1, 5, 6, 7, 8, 9]); - /// ``` - pub fn flip>(&mut self, range: R) { - let (start, end) = range_to_inclusive(range); - self.flip_inclusive(start, end); - } - - fn flip_inclusive(&mut self, start: u64, end: u64) { - if start > end { - return; - } - let (start_high, start_low) = util::split(start); - let (end_high, end_low) = util::split(end); - - if start_high == end_high { - match self.map.entry(start_high) { - Entry::Occupied(mut entry) => { - entry.get_mut().flip_inplace(start_low..=end_low); - if entry.get().is_empty() { - entry.remove(); - } - } - Entry::Vacant(entry) => { - entry.insert(Bitmap::from_range(start_low..=end_low)); - } - } - return; - } - - // Because start and end don't land on the same inner bitmap, - // we need to do this in multiple steps: - // 1. Partially flip the first bitmap with values from the closed - // interval [start_low, uint32_max] - // 2. Flip intermediate bitmaps completely: [0, uint32_max] - // 3. Partially flip the last bitmap with values from the closed - - // Step 1: Partially flip the first bitmap - match self.map.entry(start_high) { - Entry::Vacant(e) => { - e.insert(Bitmap::from_range(start_low..=u32::MAX)); - } - Entry::Occupied(mut e) => { - e.get_mut().flip_inplace(start_low..=u32::MAX); - if e.get().is_empty() { - e.remove(); - } - } - } - - // Step 2: Flip intermediate bitmaps completely - for i in start_high + 1..end_high { - match self.map.entry(i) { - Entry::Vacant(e) => { - e.insert(Bitmap::from_range(..)); - } - Entry::Occupied(mut e) => { - e.get_mut().flip_inplace(..); - if e.get().is_empty() { - e.remove(); - } - } - } - } - - // Step 3: Partially flip the last bitmap - match self.map.entry(end_high) { - Entry::Vacant(e) => { - e.insert(Bitmap::from_range(..=end_low)); - } - Entry::Occupied(mut e) => { - e.get_mut().flip_inplace(..=end_low); - if e.get().is_empty() { - e.remove(); - } - } - } - } - - /// Empties the Treemap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// - /// treemap.add(1); - /// treemap.add(u64::MAX); - /// - /// assert!(!treemap.is_empty()); - /// - /// treemap.clear(); - /// - /// assert!(treemap.is_empty()); - /// ``` - pub fn clear(&mut self) { - self.map.clear(); - } - - /// Remove element from the Treemap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(u64::MAX); - /// treemap.remove(u64::MAX); - /// - /// assert!(treemap.is_empty()); - /// ``` - pub fn remove(&mut self, element: u64) { - let (hi, lo) = util::split(element); - match self.map.entry(hi) { - Entry::Vacant(_) => (), - Entry::Occupied(mut bitmap) => { - bitmap.get_mut().remove(lo); - if bitmap.get().is_empty() { - bitmap.remove(); - } - } - } - } - - /// Remove element from the Treemap, returning if a value was removed - /// - /// Returns true if the element was removed, false if it was not present - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(u64::MAX); - /// assert!(treemap.remove_checked(u64::MAX)); - /// assert!(!treemap.remove_checked(u64::MAX)); - /// ``` - pub fn remove_checked(&mut self, element: u64) -> bool { - let (hi, lo) = util::split(element); - match self.map.entry(hi) { - Entry::Vacant(_) => false, - Entry::Occupied(mut bitmap) => { - let removed = bitmap.get_mut().remove_checked(lo); - if bitmap.get().is_empty() { - bitmap.remove(); - } - removed - } - } - } - - /// Remove all values in range - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add_range(0..=10); - /// treemap.remove_range(5..=15); - /// assert_eq!(treemap.cardinality(), 5); - /// ``` - pub fn remove_range>(&mut self, range: R) { - let (start, end) = range_to_inclusive(range); - self.remove_range_inclusive(start, end); - } - - fn remove_range_inclusive(&mut self, start: u64, end: u64) { - if start > end { - return; - } - let (start_high, start_low) = util::split(start); - let (end_high, end_low) = util::split(end); - - if start_high == end_high { - if let Entry::Occupied(mut e) = self.map.entry(start_high) { - let bitmap = e.get_mut(); - bitmap.remove_range(start_low..=end_low); - if bitmap.is_empty() { - e.remove(); - } - } - return; - } - - let mut iter = self.map.range_mut(start_high..=end_high); - let mut keys_to_remove = Vec::new(); - // Step 1: Remove first partial range if bitmap exists - if let Some((&first_high, first_bitmap)) = iter.next() { - if first_high == start_high { - first_bitmap.remove_range(start_low..=u32::MAX); - if first_bitmap.is_empty() { - keys_to_remove.push(first_high); - } - } else { - keys_to_remove.push(first_high); - } - } - // Step 2: Remove the final partial range if bitmap exists - if let Some((&last_high, last_bitmap)) = iter.next_back() { - if last_high == end_high { - last_bitmap.remove_range(0..=end_low); - if last_bitmap.is_empty() { - keys_to_remove.push(last_high); - } - } else { - keys_to_remove.push(last_high); - } - } - - // Step 3: Remove all full ranges - // Unfortunately, there's no way to remove a range from a BTreeMap, so - // we have to build a list of keys to remove and then remove them individually - keys_to_remove.extend(iter.map(|(&k, _)| k)); - - for key in &keys_to_remove { - self.map.remove(key); - } - } - - /// Reallocate memory to shrink the memory usage - pub fn shrink_to_fit(&mut self) { - for bitmap in self.map.values_mut() { - _ = bitmap.shrink_to_fit(); - } - } - - /// Selects the value at index `rank` in the bitmap - /// - /// The smallest value is at index 0. If 'rank' < cardinality(), - /// returns Some, otherwise, returns None - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add_range(10..=20); - /// assert_eq!(treemap.select(0), Some(10)); - /// assert_eq!(treemap.select(10), Some(20)); - /// assert_eq!(treemap.select(11), None); - /// ``` - #[must_use] - pub fn select(&self, mut rank: u64) -> Option { - for (&key, bitmap) in &self.map { - let sub_cardinality = bitmap.cardinality(); - if rank < sub_cardinality { - // rank < sub_cadinality, and sub_cardinality is <= 2^32 - // so rank < 2^32 - let rank = u32::try_from(rank).unwrap(); - let low_bytes = bitmap - .select(rank) - .expect("select failed despite rank < cardinailty()"); - return Some(util::join(key, low_bytes)); - } - rank -= sub_cardinality; - } - None - } - - /// Returns the number of elements that are smaller or equal to `value` - #[must_use] - pub fn rank(&self, value: u64) -> u64 { - let (hi, lo) = util::split(value); - let mut rank = 0; - let mut range = self.map.range(..=hi); - if let Some((&key, bitmap)) = range.next_back() { - rank += if key == hi { - bitmap.rank(lo) - } else { - bitmap.cardinality() - }; - } - for (_, bitmap) in range { - rank += bitmap.cardinality(); - } - rank - } - - /// Returns the index of `value` in the set (zero based index) - /// - /// If the set doesn't contain `value`, return None - /// - /// The difference with the `rank` method is that this method will return - /// None if the value is not in the set, whereas `rank` will always return a value - #[doc(alias = "get_index")] - #[must_use] - pub fn position(&self, value: u64) -> Option { - let (hi, lo) = util::split(value); - let mut range = self.map.range(..=hi); - let mut index = u64::from( - range - .next_back() - .filter(|(&key, _)| key == hi) - .and_then(|(_, bitmap)| bitmap.position(lo))?, - ); - for (_, bitmap) in range { - index += bitmap.cardinality(); - } - Some(index) - } - - /// Returns the number of elements contained in the Treemap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(1); - /// - /// assert_eq!(treemap.cardinality(), 1); - /// - /// treemap.add(u64::MAX); - /// - /// assert_eq!(treemap.cardinality(), 2); - /// ``` - #[must_use] - pub fn cardinality(&self) -> u64 { - self.map.values().map(Bitmap::cardinality).sum() - } - - /// Returns the smallest value in the set. - /// Returns [`u64::MAX`] if the set is empty. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap: Treemap = Treemap::new(); - /// let empty_treemap: Treemap = Treemap::new(); - /// - /// treemap.add(120); - /// treemap.add(1000); - /// - /// assert_eq!(treemap.minimum(), Some(120)); - /// assert_eq!(empty_treemap.minimum(), None); - /// ``` - #[must_use] - pub fn minimum(&self) -> Option { - self.map - .iter() - .find_map(|(&k, bitmap)| bitmap.minimum().map(|low| util::join(k, low))) - } - - /// Returns the greatest value in the set. - /// Returns 0 if the set is empty. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap: Treemap = Treemap::new(); - /// let empty_treemap: Treemap = Treemap::new(); - /// - /// treemap.add(120); - /// treemap.add(1000); - /// - /// assert_eq!(treemap.maximum(), Some(1000)); - /// assert_eq!(empty_treemap.maximum(), None); - /// ``` - #[must_use] - pub fn maximum(&self) -> Option { - self.map - .iter() - .rev() - .find_map(|(&k, bitmap)| bitmap.maximum().map(|low| util::join(k, low))) - } - - /// And computes the intersection between two treemaps and returns the - /// result as a new treemap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(2); - /// - /// let treemap3 = treemap1.and(&treemap2); - /// - /// assert!(treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(2)); - /// ``` - #[must_use] - pub fn and(&self, other: &Self) -> Self { - let mut treemap = Treemap::new(); - - for (key, bitmap) in &self.map { - other - .map - .get(key) - .map(|other_bitmap| treemap.map.insert(*key, bitmap.and(other_bitmap))); - } - - treemap - } - - /// Computes the intersection between two treemaps and stores the result - /// in the current treemap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add(u64::MAX); - /// - /// let mut treemap4 = Treemap::new(); - /// treemap4.add(u64::MAX); - /// treemap4.add(25); - /// - /// treemap1.and_inplace(&treemap2); - /// - /// assert_eq!(treemap1.cardinality(), 0); - /// assert!(!treemap1.contains(u64::MAX)); - /// assert!(!treemap1.contains(25)); - /// - /// treemap3.and_inplace(&treemap4); - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(25)); - /// - /// let mut treemap5 = Treemap::new(); - /// treemap5.add(u64::MAX); - /// treemap5.and_inplace(&Treemap::new()); - /// assert_eq!(treemap5.cardinality(), 0); - /// ``` - pub fn and_inplace(&mut self, other: &Self) { - let mut keys_to_remove: Vec = Vec::new(); - - for (key, bitmap) in &mut self.map { - match other.map.get(key) { - None => { - keys_to_remove.push(*key); - } - Some(other_bitmap) => { - bitmap.and_inplace(other_bitmap); - if bitmap.is_empty() { - keys_to_remove.push(*key); - } - } - } - } - - for key in keys_to_remove { - self.map.remove(&key); - } - } - - /// Or computes the union between two bitmaps and returns the result - /// as a new bitmap - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let treemap3 = treemap1.or(&treemap2); - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(u64::MAX)); - /// assert!(treemap3.contains(25)); - /// ``` - #[must_use] - pub fn or(&self, other: &Self) -> Self { - let mut treemap = self.clone(); - - for (key, other_bitmap) in &other.map { - match treemap.map.entry(*key) { - Entry::Vacant(current_map) => { - current_map.insert(other_bitmap.clone()); - } - Entry::Occupied(mut bitmap) => { - bitmap.get_mut().or_inplace(other_bitmap); - } - }; - } - - treemap - } - - /// Computes the intersection between two bitmaps and stores the result - /// in the current bitmap - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add(15); - /// - /// let mut bitmap4 = Treemap::new(); - /// bitmap4.add(15); - /// bitmap4.add(25); - /// - /// treemap1.and_inplace(&treemap2); - /// - /// assert_eq!(treemap1.cardinality(), 0); - /// assert!(!treemap1.contains(15)); - /// assert!(!treemap1.contains(25)); - /// - /// treemap3.and_inplace(&bitmap4); - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(25)); - /// ``` - pub fn or_inplace(&mut self, other: &Self) { - for (key, other_bitmap) in &other.map { - match self.map.entry(*key) { - Entry::Vacant(current_map) => { - current_map.insert(other_bitmap.clone()); - } - Entry::Occupied(mut current_map) => { - current_map.get_mut().or_inplace(other_bitmap); - } - }; - } - } - - /// Computes the symmetric difference (xor) between two treemaps - /// and returns a new treemap. - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = treemap1.xor(&treemap2); - /// - /// assert_eq!(treemap3.cardinality(), 2); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(25)); - /// assert!(treemap3.contains(35)); - /// ``` - #[must_use] - pub fn xor(&self, other: &Self) -> Self { - let mut treemap = self.clone(); - - for (key, other_bitmap) in &other.map { - match treemap.map.entry(*key) { - Entry::Vacant(current_map) => { - current_map.insert(other_bitmap.clone()); - } - Entry::Occupied(mut bitmap) => { - bitmap.get_mut().xor_inplace(other_bitmap); - } - }; - } - - treemap - } - - /// Inplace version of xor, stores result in the current treemap. - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(25); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// treemap2.add(35); - /// - /// treemap1.xor_inplace(&treemap2); - /// - /// assert_eq!(treemap1.cardinality(), 2); - /// assert!(treemap1.contains(15)); - /// assert!(treemap1.contains(35)); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add(15); - /// treemap3.xor_inplace(&Treemap::new()); - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// ``` - pub fn xor_inplace(&mut self, other: &Self) { - let mut keys_to_remove: Vec = Vec::new(); - - for (key, other_bitmap) in &other.map { - match self.map.entry(*key) { - Entry::Vacant(bitmap) => { - bitmap.insert(other_bitmap.clone()); - } - Entry::Occupied(mut bitmap) => { - bitmap.get_mut().xor_inplace(other_bitmap); - if bitmap.get().is_empty() { - keys_to_remove.push(*key); - } - } - }; - } - - for key in keys_to_remove { - self.map.remove(&key); - } - } - - /// Computes the difference between two bitmaps and returns the result. - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = treemap1.andnot(&treemap2); - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(35)); - /// ``` - #[must_use] - pub fn andnot(&self, other: &Self) -> Self { - let mut treemap = Treemap::new(); - - for (key, bitmap) in &self.map { - let sub_bitmap = match other.map.get(key) { - Some(other_bitmap) => { - let sub_bitmap = bitmap.andnot(other_bitmap); - if sub_bitmap.is_empty() { - continue; - } - sub_bitmap - } - // x.andnot(empty) == x - None => bitmap.clone(), - }; - treemap.map.insert(*key, sub_bitmap); - } - - treemap - } - - /// Computes the difference between two treemaps and stores the result - /// in the current treemap. - /// - /// # Examples - /// - /// ``` - /// use std::u32; - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(25); - /// treemap1.add(u64::MAX - 10); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(25); - /// treemap2.add(35); - /// - /// treemap1.andnot_inplace(&treemap2); - /// - /// assert_eq!(treemap1.cardinality(), 2); - /// assert!(treemap1.contains(15)); - /// assert!(treemap1.contains(u64::MAX - 10)); - /// assert!(!treemap1.contains(u64::MAX)); - /// assert!(!treemap1.contains(35)); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add(15); - /// let treemap4 = Treemap::new(); - /// treemap3.andnot_inplace(&treemap4); - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// ``` - pub fn andnot_inplace(&mut self, other: &Self) { - for (key, bitmap) in &mut self.map { - if let Some(other_bitmap) = other.map.get(key) { - bitmap.andnot_inplace(other_bitmap); - } - } - } - - /// Returns a vector containing all of the integers stored in the Treemap - /// in a sorted order. - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(25); - /// treemap.add(15); - /// treemap.add(u64::MAX); - /// - /// assert_eq!(treemap.to_vec(), [15, 25, u64::MAX]); - /// ``` - #[must_use] - pub fn to_vec(&self) -> Vec { - let treemap_size: usize = self.cardinality().try_into().unwrap(); - - let mut result: Vec = Vec::with_capacity(treemap_size); - let mut buffer = [0; 1024]; - - for (&key, bitmap) in &self.map { - let mut iter = bitmap.iter(); - loop { - let n = iter.next_many(&mut buffer); - if n == 0 { - break; - } - result.extend(buffer[..n].iter().map(|&bit| util::join(key, bit))); - } - } - - result - } - - /// Computes the serialized size in bytes of the treemap in format `S`. - #[must_use] - pub fn get_serialized_size_in_bytes(&self) -> usize { - S::get_serialized_size_in_bytes(self) - } - - /// Serializes the treemap to a slice of bytes in format `S`. - /// - /// # Examples - /// - /// ``` - /// use croaring::{Treemap, Portable}; - /// - /// let treemap: Treemap = (1..5).collect(); - /// - /// let serialized_buffer = treemap.serialize::(); - /// - /// let deserialized_treemap = Treemap::deserialize::(&serialized_buffer); - /// - /// assert_eq!(treemap, deserialized_treemap); - /// ``` - #[must_use] - pub fn serialize(&self) -> Vec { - let mut dst = Vec::new(); - self.serialize_into::(&mut dst); - dst - } - - /// Serializes a treemap to a slice of bytes in format `S`, re-using existing capacity - /// - /// `dst` is not cleared, data is added after any existing data. Returns the added slice of `dst`. - /// If `dst` is empty, it is guaranteed to hold only the serialized data after this call - /// - /// # Examples - /// - /// ``` - /// use croaring::{Treemap, Portable}; - /// - /// let original_treemap_1: Treemap = (1..5).collect(); - /// let original_treemap_2: Treemap = (1..10).collect(); - /// - /// let mut data = Vec::new(); - /// for treemap in [original_treemap_1, original_treemap_2] { - /// data.clear(); - /// let serialized_output = treemap.serialize_into::(&mut data); - /// // do something with serialized_output - /// } - /// ``` - pub fn serialize_into<'a, S: Serializer>(&self, dst: &'a mut Vec) -> &'a [u8] { - S::serialize_into(self, dst) - } - - /// Serializes a treemap to a writer in format `S`. - /// - /// Returns the number of bytes written to the writer. - /// - /// Note that the [`Frozen`][crate::Frozen] format requires alignment to 32 bytes. This function - /// assumes the writer starts at an aligned position (and cannot check this). - /// - /// # Examples - /// - /// ``` - /// use croaring::{Treemap, Portable}; - /// use std::io::Cursor; - /// - /// let treemap: Treemap = (1..5).collect(); - /// - /// let mut cursor = Cursor::new(Vec::new()); - /// treemap.serialize_into_writer::(&mut cursor).unwrap(); - /// - /// let deserialized_treemap = Treemap::try_deserialize::(cursor.into_inner().as_slice()).unwrap(); - /// - /// assert_eq!(treemap, deserialized_treemap); - /// ``` - pub fn serialize_into_writer( - &self, - writer: W, - ) -> io::Result { - S::serialize_into_writer(self, writer) - } - - /// Given a serialized treemap as slice of bytes in format `S`, returns a `Bitmap` instance. - /// See example of [`Self::serialize`] function. - /// - /// On invalid input returns None. - /// - /// # Examples - /// - /// ``` - /// use croaring::{Treemap, Portable}; - /// - /// let original_treemap: Treemap = (1..5).collect(); - /// let serialized_buffer = original_treemap.serialize::(); - /// - /// let deserialized_treemap = Treemap::try_deserialize::(&serialized_buffer); - /// assert_eq!(original_treemap, deserialized_treemap.unwrap()); - /// - /// let invalid_buffer: Vec = vec![3]; - /// let deserialized_treemap = Treemap::try_deserialize::(&invalid_buffer); - /// assert!(deserialized_treemap.is_none()); - /// ``` - #[must_use] - pub fn try_deserialize(buffer: &[u8]) -> Option { - D::try_deserialize(buffer).map(|(treemap, _bytes_read)| treemap) - } - - /// Given a serialized treemap as slice of bytes in format `S `, returns a treemap instance. - /// See example of [`Self::serialize`] function. - /// - /// On invalid input returns empty treemap. - #[must_use] - pub fn deserialize(buffer: &[u8]) -> Self { - Self::try_deserialize::(buffer).unwrap_or_default() - } - - /// Creates a new treemap from a slice of u64 integers - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let elements = vec![1, 2, u64::MAX]; - /// - /// let treemap = Treemap::of(&elements); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// for element in &elements { - /// treemap2.add(*element); - /// } - /// - /// assert!(treemap.contains(1)); - /// assert!(treemap.contains(2)); - /// assert!(treemap.contains(u64::MAX)); - /// assert!(!treemap.contains(3)); - /// assert_eq!(treemap, treemap2); - /// ``` - #[must_use] - pub fn of(elements: &[u64]) -> Self { - let mut treemap = Treemap::new(); - - for element in elements { - treemap.add(*element); - } - - treemap - } - - /// Compresses treemap's bitmaps. Returns true if any of the bitmaps - /// were modified. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap: Treemap = (100..1000).collect(); - /// - /// assert_eq!(treemap.cardinality(), 900); - /// assert!(treemap.run_optimize()); - /// ``` - pub fn run_optimize(&mut self) -> bool { - self.map - .iter_mut() - .fold(false, |result, (_, bitmap)| bitmap.run_optimize() || result) - } - - /// Removes run-length encoding from treemap's bitmaps. Returns true if - /// change was made to any of the bitmaps. - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap: Treemap = (100..1000).collect(); - /// - /// assert_eq!(treemap.cardinality(), 900); - /// assert!(treemap.run_optimize()); - /// assert!(treemap.remove_run_compression()); - /// ``` - pub fn remove_run_compression(&mut self) -> bool { - self.map.iter_mut().fold(false, |result, (_, bitmap)| { - bitmap.remove_run_compression() || result - }) - } - - pub(super) fn get_or_create(&mut self, bucket: u32) -> &mut Bitmap { - self.map.entry(bucket).or_default() - } -} - -fn range_to_inclusive>(range: R) -> (u64, u64) { - let start = match range.start_bound() { - Bound::Included(&i) => i, - Bound::Excluded(&i) => match i.checked_add(1) { - Some(i) => i, - None => return (1, 0), - }, - Bound::Unbounded => 0, - }; - let end = match range.end_bound() { - Bound::Included(&i) => i, - Bound::Excluded(&i) => match i.checked_sub(1) { - Some(i) => i, - None => return (1, 0), - }, - Bound::Unbounded => u64::MAX, - }; - (start, end) -} diff --git a/croaring/src/treemap/iter.rs b/croaring/src/treemap/iter.rs deleted file mode 100644 index d25504a..0000000 --- a/croaring/src/treemap/iter.rs +++ /dev/null @@ -1,129 +0,0 @@ -use super::util; -use crate::bitmap::BitmapIterator; -use crate::{Bitmap, Treemap}; -use std::collections::btree_map; -use std::iter::{self, FromIterator}; - -struct To64Iter<'a> { - key: u32, - iterator: BitmapIterator<'a>, -} - -impl<'a> Iterator for To64Iter<'a> { - type Item = u64; - - fn next(&mut self) -> Option { - self.iterator.next().map(|n| util::join(self.key, n)) - } -} - -fn to64iter<'a>(t: (&'a u32, &'a Bitmap)) -> To64Iter<'a> { - To64Iter { - key: *t.0, - iterator: t.1.iter(), - } -} - -type InnerIter<'a> = iter::FlatMap< - btree_map::Iter<'a, u32, Bitmap>, - To64Iter<'a>, - fn((&'a u32, &'a Bitmap)) -> To64Iter<'a>, ->; - -/// Iterator over values stored in the treemap -/// -/// Values are ordered in ascending order -pub struct TreemapIterator<'a> { - iter: InnerIter<'a>, -} - -impl<'a> TreemapIterator<'a> { - fn new(treemap: &'a Treemap) -> Self { - let iter = treemap.map.iter().flat_map(to64iter as _); - - TreemapIterator { iter } - } -} - -impl<'a> Iterator for TreemapIterator<'a> { - type Item = u64; - - fn next(&mut self) -> Option { - self.iter.next() - } -} - -impl Treemap { - /// Returns an iterator over each value stored in the bitmap. - /// Returned values are ordered in ascending order. - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap = Treemap::new(); - /// treemap.add(4); - /// treemap.add(3); - /// treemap.add(2); - /// treemap.add(2); - /// treemap.add(u64::MAX); - /// let mut iterator = treemap.iter(); - /// - /// assert_eq!(iterator.next(), Some(2)); - /// assert_eq!(iterator.next(), Some(3)); - /// assert_eq!(iterator.next(), Some(4)); - /// assert_eq!(iterator.next(), Some(u64::MAX)); - /// assert_eq!(iterator.next(), None); - /// ``` - #[must_use] - pub fn iter(&self) -> TreemapIterator { - TreemapIterator::new(self) - } -} - -impl FromIterator for Treemap { - /// Convenience method for creating treemap from an iterator. - /// - /// # Examples - /// - /// ``` - /// use std::{u32, u64}; - /// use croaring::Treemap; - /// - /// let treemap: Treemap = (1..3).chain(u64::from(u32::MAX)+1..u64::from(u32::MAX)+10).collect(); - /// - /// assert!(!treemap.is_empty()); - /// assert!(treemap.contains(1)); - /// assert!(treemap.contains(2)); - /// assert!(treemap.contains(u64::from(u32::MAX)+1)); - /// assert!(treemap.contains(u64::from(u32::MAX)+5)); - /// assert_eq!(treemap.cardinality(), 11); - /// ``` - fn from_iter>(iter: I) -> Self { - let mut result = Self::new(); - result.extend(iter); - result - } -} - -impl Extend for Treemap { - fn extend>(&mut self, iter: T) { - // Potentially reduce outer map lookups by optimistically - // assuming that adjacent values will belong to the same inner bitmap. - let mut last_bitmap: Option<(u32, &mut Bitmap)> = None; - for item in iter { - let (high, low) = util::split(item); - if let Some((last_high, ref mut last_bitmap)) = last_bitmap { - if last_high == high { - last_bitmap.add(low); - continue; - } - } - let bitmap = self.get_or_create(high); - bitmap.add(low); - last_bitmap = Some((high, bitmap)); - } - } -} diff --git a/croaring/src/treemap/mod.rs b/croaring/src/treemap/mod.rs deleted file mode 100644 index ca2aa53..0000000 --- a/croaring/src/treemap/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Treemap is a RoaringBitmap-based structure that supports 64bit unsigned -//! integer values. Implemented as a [`BTreeMap`]. -//! -//! Java version can be found at -//! C++ version - -//! -//! # Example -//! -//! ```rust -//! use std::u32; -//! use croaring::Treemap; -//! -//! let mut treemap = Treemap::new(); -//! treemap.add(3); -//! assert!(treemap.contains(3)); -//! treemap.add(u32::MAX as u64); -//! assert!(treemap.contains(u32::MAX as u64)); -//! treemap.add(u64::from(u32::MAX) + 1); -//! assert!(treemap.contains(u64::from(u32::MAX)+ 1)); -//! assert_eq!(treemap.cardinality(), 3); -//! ``` -use crate::Bitmap; -use std::collections::BTreeMap; - -mod imp; -mod iter; -mod ops; -mod serialization; -mod util; - -pub use iter::TreemapIterator; -pub use serialization::{Deserializer, Serializer}; - -/// A RoaringBitmap-based structure that supports 64bit unsigned integer values -/// -/// Implemented as a [`BTreeMap`] of [`Bitmap`]s. -#[derive(Clone, PartialEq, Eq)] -pub struct Treemap { - /// The underlying map of bitmaps - pub map: BTreeMap, -} diff --git a/croaring/src/treemap/ops.rs b/croaring/src/treemap/ops.rs deleted file mode 100644 index fc40048..0000000 --- a/croaring/src/treemap/ops.rs +++ /dev/null @@ -1,520 +0,0 @@ -use std::fmt; -use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign}; - -use super::Treemap; - -impl fmt::Debug for Treemap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.cardinality() < 32 { - write!(f, "Treemap<{:?}>", self.to_vec()) - } else { - write!( - f, - "Treemap<{}, [{:?}..{:?}]>", - self.cardinality(), - self.minimum().unwrap(), - self.maximum().unwrap() - ) - } - } -} - -impl Default for Treemap { - fn default() -> Self { - Self::new() - } -} - -impl BitAnd for Treemap { - type Output = Treemap; - - /// Syntactic sugar for `.and` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(1); - /// treemap2.add(u64::MAX); - /// - /// let treemap3 = treemap1 & treemap2; - /// - /// assert!(treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(1)); - /// ``` - #[inline] - fn bitand(self, other: Treemap) -> Treemap { - self.and(&other) - } -} - -impl<'a> BitAnd<&'a Treemap> for Treemap { - type Output = Treemap; - - /// Syntactic sugar for `.and` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(1); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(1); - /// treemap2.add(2); - /// - /// let treemap3 = treemap1 & &treemap2; - /// - /// assert!(treemap3.contains(1)); - /// assert!(!treemap3.contains(2)); - /// ``` - #[inline] - fn bitand(self, other: &'a Treemap) -> Treemap { - self.and(other) - } -} - -impl<'a, 'b> BitAnd<&'a Treemap> for &'b Treemap { - type Output = Treemap; - - /// Syntactic sugar for `.and` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1: Treemap = Treemap::new(); - /// treemap1.add(1); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(1); - /// treemap2.add(2); - /// - /// let treemap3 = &treemap1 & &treemap2; - /// - /// assert!(treemap3.contains(1)); - /// assert!(!treemap3.contains(2)); - /// ``` - #[inline] - fn bitand(self, other: &'a Treemap) -> Treemap { - self.and(other) - } -} - -impl BitAndAssign for Treemap { - /// Syntactic sugar for `.and_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let mut treemap3 = Treemap::new(); - /// treemap3.add(15); - /// - /// let mut treemap4 = Treemap::new(); - /// treemap4.add(15); - /// treemap4.add(25); - /// - /// treemap1 &= treemap2; - /// - /// assert!(treemap1.cardinality() == 0); - /// assert!(!treemap1.contains(15)); - /// assert!(!treemap1.contains(25)); - /// - /// treemap3 &= treemap4; - /// - /// assert!(treemap3.cardinality() == 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(25)); - /// ``` - #[inline] - fn bitand_assign(&mut self, other: Treemap) { - self.and_inplace(&other); - } -} - -impl BitOr for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.or` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let treemap3 = treemap1 | treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(treemap3.contains(25)); - /// ``` - #[inline] - fn bitor(self, other: Treemap) -> Treemap { - self.or(&other) - } -} - -impl<'a> BitOr<&'a Treemap> for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.or` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let treemap3 = treemap1 | &treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(treemap3.contains(25)); - /// ``` - #[inline] - fn bitor(self, other: &'a Treemap) -> Treemap { - self.or(other) - } -} - -impl<'a, 'b> BitOr<&'a Treemap> for &'b Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.or` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// let treemap3 = &treemap1 | &treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(treemap3.contains(25)); - /// ``` - #[inline] - fn bitor(self, other: &'a Treemap) -> Treemap { - self.or(other) - } -} - -impl BitOrAssign for Treemap { - /// Syntatic sugar for `.or_inplace` - /// - /// # Examples - /// - /// ``` - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(25); - /// - /// treemap1 |= treemap2; - /// - /// assert!(treemap1.cardinality() == 2); - /// assert!(treemap1.contains(15)); - /// assert!(treemap1.contains(25)); - /// ``` - #[inline] - fn bitor_assign(&mut self, other: Treemap) { - self.or_inplace(&other); - } -} - -impl BitXor for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.xor` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = treemap1 ^ treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(treemap3.contains(35)); - /// ``` - #[inline] - fn bitxor(self, other: Treemap) -> Treemap { - self.xor(&other) - } -} - -impl<'a> BitXor<&'a Treemap> for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.xor` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = treemap1 ^ &treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(treemap3.contains(35)); - /// ``` - #[inline] - fn bitxor(self, other: &'a Treemap) -> Treemap { - self.xor(other) - } -} - -impl<'a, 'b> BitXor<&'a Treemap> for &'b Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.xor` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = &treemap1 ^ &treemap2; - /// - /// assert!(treemap3.cardinality() == 2); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(treemap3.contains(35)); - /// ``` - #[inline] - fn bitxor(self, other: &'a Treemap) -> Treemap { - self.xor(other) - } -} - -impl BitXorAssign for Treemap { - /// Syntatic sugar for `.xor_inplace` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// treemap1 ^= treemap2; - /// - /// assert!(treemap1.cardinality() == 2); - /// assert!(treemap1.contains(15)); - /// assert!(!treemap1.contains(u64::MAX)); - /// assert!(treemap1.contains(35)); - /// ``` - #[inline] - fn bitxor_assign(&mut self, other: Treemap) { - self.xor_inplace(&other); - } -} - -impl Sub for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.andnot` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(u64::MAX); - /// treemap2.add(35); - /// - /// let treemap3 = treemap1 - treemap2; - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(35)); - /// ``` - #[inline] - fn sub(self, other: Treemap) -> Treemap { - self.andnot(&other) - } -} - -impl<'a> Sub<&'a Treemap> for Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.andnot` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(25); - /// treemap2.add(u64::MAX); - /// - /// let treemap3 = treemap1 - &treemap2; - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(35)); - /// ``` - #[inline] - fn sub(self, other: &'a Treemap) -> Treemap { - self.andnot(other) - } -} - -impl<'a, 'b> Sub<&'a Treemap> for &'b Treemap { - type Output = Treemap; - - /// Syntatic sugar for `.andnot` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(25); - /// treemap2.add(u64::MAX); - /// - /// let treemap3 = &treemap1 - &treemap2; - /// - /// assert_eq!(treemap3.cardinality(), 1); - /// assert!(treemap3.contains(15)); - /// assert!(!treemap3.contains(u64::MAX)); - /// assert!(!treemap3.contains(35)); - /// ``` - #[inline] - fn sub(self, other: &'a Treemap) -> Treemap { - self.andnot(other) - } -} - -impl SubAssign for Treemap { - /// Syntatic sugar for `.andnot_inplace` - /// - /// # Examples - /// - /// ``` - /// use std::u64; - /// use croaring::Treemap; - /// - /// let mut treemap1 = Treemap::new(); - /// - /// treemap1.add(15); - /// treemap1.add(u64::MAX); - /// - /// let mut treemap2 = Treemap::new(); - /// - /// treemap2.add(25); - /// treemap2.add(u64::MAX); - /// - /// treemap1.andnot_inplace(&treemap2); - /// - /// assert_eq!(treemap1.cardinality(), 1); - /// assert!(treemap1.contains(15)); - /// assert!(!treemap1.contains(u64::MAX)); - /// assert!(!treemap1.contains(35)); - /// ``` - #[inline] - fn sub_assign(&mut self, other: Treemap) { - self.andnot_inplace(&other); - } -} diff --git a/croaring/src/treemap/serialization.rs b/croaring/src/treemap/serialization.rs deleted file mode 100644 index 71dc0db..0000000 --- a/croaring/src/treemap/serialization.rs +++ /dev/null @@ -1,418 +0,0 @@ -use crate::serialization::{Frozen, Native, Portable}; -use crate::{bitmap, Treemap}; -use crate::{Bitmap, JvmLegacy}; -use std::collections::BTreeMap; -use std::io; -use std::io::Write as _; - -use byteorder::{BigEndian, NativeEndian, ReadBytesExt, WriteBytesExt}; -use std::mem::size_of; - -/// Trait for different formats of treemap deserialization -pub trait Serializer { - /// Serialize a treemap into a writer - /// - /// Returns the number of bytes written, or an error if writing failed - /// - /// Note tha some serializers ([`Frozen`]) may require that the bitmap is aligned specially when - /// reading: this method does not perform any extra alignment. See [`Self::serialize_into`] - /// for a method which will return a slice of bytes which are guaranteed to be aligned correctly - /// in memory - fn serialize_into_writer(treemap: &Treemap, dst: W) -> io::Result - where - W: io::Write; - - /// Serialize a treemap into bytes, using the provided vec buffer to store the serialized data - /// - /// Note that some serializers ([`Frozen`]) may require that bitmaps are aligned specially, this - /// method will ensure that the returned slice of bytes is aligned correctly so that each bitmap - /// is correctly aligned, adding additional padding before the serialized data if required. - /// - /// The contents of the provided vec buffer will not be overwritten: only new data will be - /// appended to the end of the buffer. If the buffer has enough capacity, and the current - /// end of the buffer is correctly aligned, then no additional allocations will be performed. - /// - /// Note that this method requires keeping the serialized data in memory: see also the - /// [`Self::serialize_into_writer`] method which will write the serialized data directly to a - /// writer - fn serialize_into<'a>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8]; - - /// Get the number of bytes required to serialize this bitmap - /// - /// This does not include any additional padding which may be required to align the treemap - fn get_serialized_size_in_bytes(treemap: &Treemap) -> usize; -} - -/// Trait for different formats of treemap deserialization -pub trait Deserializer { - /// Try to deserialize a treemap from the beginning of the provided buffer - /// - /// If the buffer starts with the serialized representation of a treemap, then - /// this method will return a tuple containing a new treemap containing the deserialized data, - /// and the number of bytes consumed from the buffer. - /// - /// If the buffer does not start with a serialized treemap (or contains an invalidly - /// truncated treemap), then this method will return `None`. - fn try_deserialize(buffer: &[u8]) -> Option<(Treemap, usize)>; -} - -fn serialize_impl<'a, S>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8] -where - S: bitmap::Serializer, -{ - let start_idx = dst.len(); - let map_len = u64::try_from(treemap.map.len()).unwrap(); - dst.extend_from_slice(&map_len.to_ne_bytes()); - - treemap.map.iter().for_each(|(&key, bitmap)| { - dst.extend_from_slice(&key.to_ne_bytes()); - let prev_len = dst.len(); - let serialized_slice = bitmap.serialize_into::(dst); - let serialized_len = serialized_slice.len(); - let serialized_range = serialized_slice.as_ptr_range(); - // Serialization should only append the data, no padding can be allowed for this implementation - debug_assert_eq!(prev_len + serialized_len, dst.len()); - debug_assert_eq!(serialized_range.end, dst.as_ptr_range().end); - }); - &dst[start_idx..] -} - -fn serialize_writer_impl(treemap: &Treemap, dst: W) -> io::Result -where - S: bitmap::Serializer, - W: io::Write, -{ - let mut dst = OffsetTrackingWriter::new(dst); - let map_len = u64::try_from(treemap.map.len()).unwrap(); - dst.write_u64::(map_len)?; - - let mut buf = Vec::new(); - - for (&key, bitmap) in &treemap.map { - dst.write_u32::(key)?; - - let bitmap_serialized = bitmap.serialize_into::(&mut buf); - dst.write_all(bitmap_serialized)?; - buf.clear(); - } - Ok(dst.bytes_written) -} - -fn size_in_bytes_impl(treemap: &Treemap) -> usize -where - S: bitmap::Serializer, -{ - let overhead = size_of::() + treemap.map.len() * size_of::(); - let total_sizes = treemap - .map - .values() - .map(Bitmap::get_serialized_size_in_bytes::) - .sum::(); - overhead + total_sizes -} - -fn deserialize_impl(mut buffer: &[u8]) -> Option<(Treemap, usize)> -where - S: bitmap::Serializer + bitmap::Deserializer, -{ - let start_len = buffer.len(); - let map_len = buffer.read_u64::().ok()?; - let mut map = BTreeMap::new(); - for _ in 0..map_len { - let key = buffer.read_u32::().ok()?; - let bitmap = Bitmap::try_deserialize::(buffer)?; - buffer = &buffer[bitmap.get_serialized_size_in_bytes::()..]; - map.insert(key, bitmap); - } - Some((Treemap { map }, start_len - buffer.len())) -} - -impl Serializer for Portable { - /// Serializes a Treemap to a writer in portable format. - /// See [`Treemap::serialize_into_writer`] for examples. - fn serialize_into_writer(treemap: &Treemap, dst: W) -> io::Result - where - W: io::Write, - { - serialize_writer_impl::(treemap, dst) - } - - /// Serializes a Treemap to a slice of bytes in portable format. - /// See [`Treemap::serialize_into`] for examples. - fn serialize_into<'a>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8] { - serialize_impl::(treemap, dst) - } - - /// Computes the serialized size in bytes of the Treemap in portable format. - /// See [`Treemap::get_serialized_size_in_bytes`] for examples. - fn get_serialized_size_in_bytes(treemap: &Treemap) -> usize { - size_in_bytes_impl::(treemap) - } -} - -impl Deserializer for Portable { - fn try_deserialize(buffer: &[u8]) -> Option<(Treemap, usize)> { - deserialize_impl::(buffer) - } -} - -impl Serializer for Native { - /// Serializes a Treemap to a writer in native format. - /// See [`Treemap::serialize_into_writer`] for examples. - fn serialize_into_writer(treemap: &Treemap, dst: W) -> io::Result - where - W: io::Write, - { - serialize_writer_impl::(treemap, dst) - } - - /// Serializes a Treemap to a slice of bytes in native format. - /// See [`Treemap::serialize_into`] for examples. - fn serialize_into<'a>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8] { - serialize_impl::(treemap, dst) - } - - /// Computes the serialized size in bytes of the Treemap in native format. - /// See [`Treemap::get_serialized_size_in_bytes`] for examples. - fn get_serialized_size_in_bytes(treemap: &Treemap) -> usize { - size_in_bytes_impl::(treemap) - } -} - -impl Deserializer for Native { - fn try_deserialize(buffer: &[u8]) -> Option<(Treemap, usize)> { - deserialize_impl::(buffer) - } -} - -const FROZEN_BITMAP_METADATA_SIZE: usize = size_of::() + size_of::(); - -impl Serializer for Frozen { - /// Serializes a Treemap to a writer in frozen format. - /// See [`Treemap::serialize_into_writer`] for examples. - fn serialize_into_writer(treemap: &Treemap, dst: W) -> io::Result - where - W: io::Write, - { - const FULL_PADDING: [u8; Frozen::MAX_PADDING] = [0; Frozen::MAX_PADDING]; - - let mut dst = OffsetTrackingWriter::new(dst); - - let map_size = u64::try_from(treemap.map.len()).unwrap(); - dst.write_all(&u64::to_ne_bytes(map_size))?; - - let mut buf = Vec::new(); - for (&key, bitmap) in &treemap.map { - let bitmap_serialized = bitmap.serialize_into::(&mut buf); - let required_padding = - Self::required_padding(dst.bytes_written + FROZEN_BITMAP_METADATA_SIZE); - - dst.write_all(&FULL_PADDING[..required_padding])?; - dst.write_all(&usize::to_ne_bytes(bitmap_serialized.len()))?; - dst.write_all(&u32::to_ne_bytes(key))?; - - debug_assert_eq!(dst.bytes_written % Self::REQUIRED_ALIGNMENT, 0); - dst.write_all(bitmap_serialized)?; - - buf.clear(); - } - - Ok(dst.bytes_written) - } - - /// Serializes a Treemap to a slice of bytes in frozen format. - /// See [`Treemap::serialize_into`] for examples. - fn serialize_into<'a>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8] { - let len = Self::get_serialized_size_in_bytes(treemap); - let mut offset = dst.len(); - if dst.capacity() < dst.len() + len - || Self::required_padding(dst.as_ptr() as usize + offset) != 0 - { - dst.reserve(len.checked_add(Self::MAX_PADDING).unwrap()); - let extra_offset = Self::required_padding(dst.as_ptr() as usize + offset); - offset = offset.checked_add(extra_offset).unwrap(); - // we must initialize up to offset - dst.resize(offset, 0); - } - let total_len = offset.checked_add(len).unwrap(); - debug_assert!(dst.capacity() >= total_len); - - let map_size = u64::try_from(treemap.map.len()).unwrap(); - dst.extend_from_slice(&map_size.to_ne_bytes()); - - treemap.map.iter().for_each(|(&key, bitmap)| { - let end_with_metadata = dst.as_ptr_range().end as usize + FROZEN_BITMAP_METADATA_SIZE; - let extra_padding = Self::required_padding(end_with_metadata); - dst.resize(dst.len() + extra_padding, 0); - - let frozen_size_in_bytes: usize = bitmap.get_serialized_size_in_bytes::(); - dst.extend_from_slice(&frozen_size_in_bytes.to_ne_bytes()); - dst.extend_from_slice(&key.to_ne_bytes()); - - let before_bitmap_serialize = dst.as_ptr_range().end; - let serialized_slice = bitmap.serialize_into::(dst); - // We pre-calculated padding, so there should be no padding added - debug_assert_eq!(before_bitmap_serialize, serialized_slice.as_ptr()); - debug_assert_eq!(serialized_slice.as_ptr_range().end, dst.as_ptr_range().end); - }); - - &dst[offset..] - } - - /// Computes the serialized size in bytes of the Treemap in frozen format. - /// See [`Treemap::get_serialized_size_in_bytes`] for examples. - fn get_serialized_size_in_bytes(treemap: &Treemap) -> usize { - let mut result = size_of::(); - for bitmap in treemap.map.values() { - result += FROZEN_BITMAP_METADATA_SIZE; - result += Self::required_padding(result); - result += bitmap.get_serialized_size_in_bytes::(); - } - result - } -} - -impl Serializer for JvmLegacy { - fn serialize_into_writer(treemap: &Treemap, dst: W) -> io::Result - where - W: io::Write, - { - let mut dst = OffsetTrackingWriter::new(dst); - // Push a boolean false indicating that the values are not signed - dst.write_u8(0)?; - - let bitmap_count: u32 = treemap.map.len().try_into().unwrap(); - dst.write_u32::(bitmap_count)?; - - let mut buf = Vec::new(); - for (&key, bitmap) in &treemap.map { - dst.write_u32::(key)?; - let bitmap_serialized = bitmap.serialize_into::(&mut buf); - dst.write_all(bitmap_serialized)?; - buf.clear(); - } - - Ok(dst.bytes_written) - } - - fn serialize_into<'a>(treemap: &Treemap, dst: &'a mut Vec) -> &'a [u8] { - let start_idx = dst.len(); - // Push a boolean false indicating that the values are not signed - dst.write_u8(0).unwrap(); - - let bitmap_count: u32 = treemap.map.len().try_into().unwrap(); - dst.write_u32::(bitmap_count).unwrap(); - treemap.map.iter().for_each(|(&key, bitmap)| { - dst.write_u32::(key).unwrap(); - bitmap.serialize_into::(dst); - }); - - &dst[start_idx..] - } - - fn get_serialized_size_in_bytes(treemap: &Treemap) -> usize { - let overhead = size_of::() + size_of::() + size_of::() * treemap.map.len(); - let total_sizes = treemap - .map - .values() - .map(Bitmap::get_serialized_size_in_bytes::) - .sum::(); - overhead + total_sizes - } -} - -impl Deserializer for JvmLegacy { - fn try_deserialize(mut buffer: &[u8]) -> Option<(Treemap, usize)> { - let start_len = buffer.len(); - // Ignored, we assume that the values are not signed - let _is_signed = buffer.read_u8().ok()?; - - let bitmap_count = buffer.read_u32::().ok()?; - let mut map = BTreeMap::new(); - for _ in 0..bitmap_count { - let key = buffer.read_u32::().ok()?; - let bitmap = Bitmap::try_deserialize::(buffer)?; - buffer = &buffer[bitmap.get_serialized_size_in_bytes::()..]; - map.insert(key, bitmap); - } - - Some((Treemap { map }, start_len - buffer.len())) - } -} - -struct OffsetTrackingWriter { - writer: W, - bytes_written: usize, -} - -impl OffsetTrackingWriter { - pub fn new(writer: W) -> Self { - Self { - writer, - bytes_written: 0, - } - } -} - -impl io::Write for OffsetTrackingWriter { - fn write(&mut self, buf: &[u8]) -> io::Result { - let written = self.writer.write(buf)?; - self.bytes_written += written; - Ok(written) - } - - fn flush(&mut self) -> io::Result<()> { - self.writer.flush() - } - - fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.writer.write_all(buf)?; - self.bytes_written += buf.len(); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn example_treemap() -> Treemap { - Treemap::from_iter([1, 2, 3, 4, 5, u64::from(u32::MAX), u64::MAX]) - } - - fn smoke_test_ser(expected_len: usize) { - let treemap = example_treemap(); - assert_eq!(treemap.get_serialized_size_in_bytes::(), expected_len); - - let mut buf = Vec::new(); - let serialized = treemap.serialize_into::(&mut buf); - assert_eq!(serialized.len(), expected_len); - - let mut writer = Vec::new(); - assert_eq!( - treemap.serialize_into_writer::(&mut writer).unwrap(), - expected_len, - ); - assert_eq!(serialized, writer); - } - - #[test] - fn smoke_portable() { - smoke_test_ser::(70); - } - - #[test] - fn smoke_native() { - smoke_test_ser::(54); - } - - #[test] - fn smoke_frozen() { - smoke_test_ser::(107); - } - - #[test] - fn smoke_jvm_legacy() { - smoke_test_ser::(67); - } -} diff --git a/croaring/src/treemap/util.rs b/croaring/src/treemap/util.rs deleted file mode 100644 index 00a32af..0000000 --- a/croaring/src/treemap/util.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[inline] -pub fn split(value: u64) -> (u32, u32) { - ((value >> 32) as u32, value as u32) -} - -#[inline] -pub fn join(high: u32, low: u32) -> u64 { - (u64::from(high) << 32) | u64::from(low) -} diff --git a/croaring/tests/data/.gitignore b/croaring/tests/data/.gitignore deleted file mode 100644 index 33691cb..0000000 --- a/croaring/tests/data/.gitignore +++ /dev/null @@ -1 +0,0 @@ -create_serialization \ No newline at end of file diff --git a/croaring/tests/data/README.md b/croaring/tests/data/README.md deleted file mode 100644 index 1213bb1..0000000 --- a/croaring/tests/data/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Test data - -Based on [croaring-rs-testgen](https://github.com/saulius/croaring-rs-testgen). diff --git a/croaring/tests/data/create_serialization.c b/croaring/tests/data/create_serialization.c deleted file mode 100644 index 5732760..0000000 --- a/croaring/tests/data/create_serialization.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -void write_file(const char *path, const char *contents, size_t len) { - FILE *f = fopen(path, "wb"); - assert(f != NULL); - size_t n = fwrite(contents, 1, len, f); - assert(n == len); - fclose(f); -} - -void write_frozen(const roaring_bitmap_t *b) { - size_t size = roaring_bitmap_frozen_size_in_bytes(b); - char *data = roaring_malloc(size); - roaring_bitmap_frozen_serialize(b, data); - write_file("frozen_bitmap.bin", data, size); - roaring_free(data); -} - -void write_portable(const roaring_bitmap_t *b) { - size_t size = roaring_bitmap_portable_size_in_bytes(b); - char *data = roaring_malloc(size); - roaring_bitmap_portable_serialize(b, data); - write_file("portable_bitmap.bin", data, size); - roaring_free(data); -} - -void write_native(const roaring_bitmap_t *b) { - size_t size = roaring_bitmap_size_in_bytes(b); - char *data = roaring_malloc(size); - roaring_bitmap_serialize(b, data); - write_file("native_bitmap.bin", data, size); - roaring_free(data); -} - -int main(void) { - int i; - - roaring_bitmap_t *b = roaring_bitmap_create(); - // Range container - roaring_bitmap_add_range(b, 0x00000, 0x09000); - roaring_bitmap_add_range(b, 0x0A000, 0x10000); - // Array container - roaring_bitmap_add(b, 0x20000); - roaring_bitmap_add(b, 0x20005); - // Bitmap container - for (i = 0; i < 0x10000; i += 2) { - roaring_bitmap_add(b, 0x80000 + i); - } - - roaring_bitmap_run_optimize(b); - - write_frozen(b); - write_portable(b); - write_native(b); - - roaring_bitmap_free(b); -} \ No newline at end of file diff --git a/croaring/tests/data/frozen_bitmap.bin b/croaring/tests/data/frozen_bitmap.bin deleted file mode 100644 index b32d6d6..0000000 --- a/croaring/tests/data/frozen_bitmap.bin +++ /dev/null @@ -1 +0,0 @@ -UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUÿ ÿ_ÿƵ \ No newline at end of file diff --git a/croaring/tests/data/native_bitmap.bin b/croaring/tests/data/native_bitmap.bin deleted file mode 100644 index 99d96e7..0000000 Binary files a/croaring/tests/data/native_bitmap.bin and /dev/null differ diff --git a/croaring/tests/data/portable_bitmap.bin b/croaring/tests/data/portable_bitmap.bin deleted file mode 100644 index d7c9333..0000000 Binary files a/croaring/tests/data/portable_bitmap.bin and /dev/null differ diff --git a/croaring/tests/data/testcpp.bin b/croaring/tests/data/testcpp.bin deleted file mode 100644 index 8a2bc21..0000000 Binary files a/croaring/tests/data/testcpp.bin and /dev/null differ diff --git a/croaring/tests/data/testjvm.bin b/croaring/tests/data/testjvm.bin deleted file mode 100644 index 093be9c..0000000 Binary files a/croaring/tests/data/testjvm.bin and /dev/null differ diff --git a/croaring/tests/lib.rs b/croaring/tests/lib.rs deleted file mode 100644 index 8294a92..0000000 --- a/croaring/tests/lib.rs +++ /dev/null @@ -1,350 +0,0 @@ -use std::collections::BTreeMap; -use std::{fs, iter, u32}; - -use croaring::{Bitmap, BitmapView, Frozen, JvmLegacy, Native, Portable, Treemap}; -use proptest::prelude::*; - -// borrowed and adapted from https://github.com/Nemo157/roaring-rs/blob/5089f180ca7e17db25f5c58023f4460d973e747f/tests/lib.rs#L7-L37 -#[test] -fn smoke1() { - let mut bitmap = Bitmap::new(); - assert_eq!(bitmap.cardinality(), 0); - assert!(bitmap.is_empty()); - bitmap.remove(0); - assert_eq!(bitmap.cardinality(), 0); - assert!(bitmap.is_empty()); - bitmap.add(1); - assert!(bitmap.contains(1)); - assert_eq!(bitmap.cardinality(), 1); - assert!(!bitmap.is_empty()); - bitmap.add(u32::MAX - 2); - assert!(bitmap.contains(u32::MAX - 2)); - assert_eq!(bitmap.cardinality(), 2); - bitmap.add(u32::MAX); - assert!(bitmap.contains(u32::MAX)); - assert_eq!(bitmap.cardinality(), 3); - bitmap.add(2); - assert!(bitmap.contains(2)); - assert_eq!(bitmap.cardinality(), 4); - bitmap.remove(2); - assert!(!bitmap.contains(2)); - assert_eq!(bitmap.cardinality(), 3); - assert!(!bitmap.contains(0)); - assert!(bitmap.contains(1)); - assert!(!bitmap.contains(100)); - assert!(bitmap.contains(u32::MAX - 2)); - assert!(!bitmap.contains(u32::MAX - 1)); - assert!(bitmap.contains(u32::MAX)); - bitmap.clear(); - assert_eq!(bitmap.cardinality(), 0); - assert!(bitmap.is_empty()); -} - -// borrowed and adapted from https://github.com/Bitmap/gocroaring/blob/4a2fc02f79b1c36b904301e7d052f7f0017b6973/gocroaring_test.go#L24-L64 -#[test] -fn smoke2() { - let mut rb1 = Bitmap::new(); - rb1.add(1); - rb1.add(2); - rb1.add(3); - rb1.add(4); - rb1.add(5); - rb1.add(100); - rb1.add(1000); - rb1.run_optimize(); - - let mut rb2 = Bitmap::new(); - rb2.add(3); - rb2.add(4); - rb2.add(1000); - rb2.run_optimize(); - - let mut rb3 = Bitmap::new(); - - assert_eq!(rb1.cardinality(), 7); - assert!(rb1.contains(3)); - - rb1.and_inplace(&rb2); - rb3.add(5); - rb3.or_inplace(&rb1); - - let mut rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); - - rb1.and_inplace(&rb2); - println!("{:?}", rb1); - - rb3.add(5); - rb3.or_inplace(&rb1); - - println!("{:?}", rb1); - - rb3.add(5); - rb3.or_inplace(&rb1); - - println!("{:?}", rb3.to_vec()); - println!("{:?}", rb3); - println!("{:?}", rb4); - - rb4 = Bitmap::fast_or(&[&rb1, &rb2, &rb3]); - - println!("{:?}", rb4); -} - -fn expected_serialized_bitmap() -> Bitmap { - let mut bitmap = Bitmap::new(); - bitmap.add_range(0x0_0000..0x0_9000); - bitmap.add_range(0x0_A000..0x1_0000); - bitmap.add(0x2_0000); - bitmap.add(0x2_0005); - for i in (0x8_0000..0x9_0000).step_by(2) { - bitmap.add(i); - } - bitmap -} - -#[test] -fn test_portable_view() { - let buffer = fs::read("tests/data/portable_bitmap.bin").unwrap(); - let bitmap = unsafe { BitmapView::deserialize::(&buffer) }; - let expected = expected_serialized_bitmap(); - assert_eq!(bitmap, expected); - assert!(bitmap.iter().eq(expected.iter())) -} - -#[test] -fn test_native() { - let buffer = fs::read("tests/data/native_bitmap.bin").unwrap(); - let bitmap = Bitmap::deserialize::(&buffer); - let expected = expected_serialized_bitmap(); - assert_eq!(bitmap, expected); - assert!(bitmap.iter().eq(expected.iter())) -} - -#[test] -fn test_frozen_view() { - let mut buffer = fs::read("tests/data/frozen_bitmap.bin").unwrap(); - // Ensure inserting zeros won't move the data - buffer.reserve(32); - let offset = 32 - (buffer.as_ptr() as usize) % 32; - buffer.splice(..0, iter::repeat(0).take(offset)); - - let bitmap = unsafe { BitmapView::deserialize::(&buffer[offset..]) }; - let expected = expected_serialized_bitmap(); - assert_eq!(bitmap, expected); - assert!(bitmap.iter().eq(expected.iter())) -} - -#[test] -fn test_treemap_deserialize_cpp() { - match fs::read("tests/data/testcpp.bin") { - Ok(buffer) => { - let treemap = Treemap::try_deserialize::(&buffer).unwrap(); - - for i in 100..1000 { - assert!(treemap.contains(i)); - } - - assert!(treemap.contains(std::u32::MAX as u64)); - assert!(treemap.contains(std::u64::MAX)); - } - Err(err) => panic!("Cannot read test file {}", err), - } -} - -#[test] -fn test_treemap_deserialize_jvm() { - match fs::read("tests/data/testjvm.bin") { - Ok(buffer) => { - let treemap = Treemap::try_deserialize::(&buffer).unwrap(); - - for i in 100..1000 { - assert!(treemap.contains(i)); - } - - assert!(treemap.contains(std::u32::MAX as u64)); - assert!(treemap.contains(std::u64::MAX)); - } - Err(err) => panic!("Cannot read test file {}", err), - } -} - -#[test] -fn test_treemap_max_andnot_empty() { - let single_max = Treemap::of(&[std::u64::MAX]); - let empty = Treemap::new(); - let diff = single_max.andnot(&empty); - assert_eq!(diff, single_max); - - let mut diff = single_max.clone(); - diff.andnot_inplace(&empty); - assert_eq!(diff, single_max); -} - -#[test] -fn treemap_run_optimized() { - let mut initial = Bitmap::new(); - initial.add(1); - initial.add(2); - initial.add(3); - initial.add(4); - initial.add(5); - initial.add(100); - initial.add(1000); - let optimized = { - let mut result = initial.clone(); - result.run_optimize(); - result - }; - - let tree_unoptimized = Treemap { - map: BTreeMap::from([(1, initial.clone()), (2, initial)]), - }; - let tree_optimized = Treemap { - map: BTreeMap::from([(1, optimized.clone()), (2, optimized)]), - }; - - let mut test = tree_unoptimized.clone(); - test.run_optimize(); - assert_eq!( - test.get_serialized_size_in_bytes::(), - tree_optimized.get_serialized_size_in_bytes::() - ); - test.remove_run_compression(); - assert_eq!( - test.get_serialized_size_in_bytes::(), - tree_unoptimized.get_serialized_size_in_bytes::() - ); -} - -#[test] -fn serialize_into_existing_vec_frozen() { - let mut buffer = vec![0; 13]; - let bitmap = Bitmap::of(&[1, 2, 3, 4, 5]); - - let data = bitmap.serialize_into::(&mut buffer); - assert_eq!(unsafe { BitmapView::deserialize::(data) }, bitmap); - assert!(unsafe { data.as_ptr().offset_from(buffer.as_ptr()) } >= 13); -} - -#[test] -fn serialize_into_existing_vec_portable() { - let mut buffer = vec![0; 13]; - let bitmap = Bitmap::of(&[1, 2, 3, 4, 5]); - let data = bitmap.serialize_into::(&mut buffer); - assert_eq!(Bitmap::try_deserialize::(data).unwrap(), bitmap); - assert!(unsafe { data.as_ptr().offset_from(buffer.as_ptr()) } >= 13); -} - -#[test] -fn serialize_into_existing_vec_native() { - let mut buffer = vec![0; 13]; - let bitmap = Bitmap::of(&[1, 2, 3, 4, 5]); - let data = bitmap.serialize_into::(&mut buffer); - assert_eq!(Bitmap::try_deserialize::(data).unwrap(), bitmap); - assert!(unsafe { data.as_ptr().offset_from(buffer.as_ptr()) } >= 13); -} - -proptest! { - #[test] - fn bitmap_cardinality_roundtrip( - indices in prop::collection::vec(proptest::num::u32::ANY, 1..3000) - ) { - let original = Bitmap::of(&indices); - let mut a = indices; - a.sort_unstable(); - a.dedup(); - prop_assert_eq!(a.len(), original.cardinality() as usize); - } - - #[test] - fn treemap_cardinality_roundtrip( - indices in prop::collection::vec(proptest::num::u64::ANY, 1..3000) - ) { - let original = Treemap::of(&indices); - let mut a = indices; - a.sort_unstable(); - a.dedup(); - prop_assert_eq!(a.len(), original.cardinality() as usize); - } - - #[test] - fn test_bitmap_serialization_roundtrip( - indices in prop::collection::vec(proptest::num::u32::ANY, 1..3000) - ) { - let original = Bitmap::of(&indices); - - let buffer = original.serialize::(); - - let deserialized = Bitmap::deserialize::(&buffer); - - prop_assert_eq!(original , deserialized); - } - - #[test] - fn test_treemap_native_serialization_roundtrip( - indices in prop::collection::vec(proptest::num::u64::ANY, 1..3000) - ) { - let original = Treemap::of(&indices); - - let buffer = original.serialize::(); - - let deserialized = Treemap::try_deserialize::(&buffer).unwrap(); - - prop_assert_eq!(original , deserialized); - } - - #[test] - fn test_treemap_jvm_serialization_roundtrip( - indices in prop::collection::vec(proptest::num::u64::ANY, 1..3000) - ) { - let original = Treemap::of(&indices); - - let buffer = original.serialize::(); - - let deserialized = Treemap::try_deserialize::(&buffer).unwrap(); - - prop_assert_eq!(original , deserialized); - } -} - -proptest! { - #[test] - fn frozen_bitmap_portable_roundtrip( - indices in prop::collection::vec(proptest::num::u32::ANY, 0..3000) - ) { - use croaring::BitmapView; - - let original = Bitmap::of(&indices); - let serialized = original.serialize::(); - let deserialized = unsafe { BitmapView::deserialize::(&serialized) }; - assert_eq!(&original, &*deserialized); - assert!(original.iter().eq(deserialized.iter())); - } - - #[test] - fn native_bitmap_roundtrip( - indices in prop::collection::vec(proptest::num::u32::ANY, 0..3000) - ) { - use croaring::Bitmap; - - let original = Bitmap::of(&indices); - let serialized = original.serialize::(); - let deserialized = Bitmap::deserialize::(&serialized[..]); - assert_eq!(&original, &deserialized); - assert!(original.iter().eq(deserialized.iter())); - } - - #[test] - fn frozen_bitmap_roundtrip( - indices in prop::collection::vec(proptest::num::u32::ANY, 0..3000) - ) { - use croaring::BitmapView; - - let original = Bitmap::of(&indices); - let mut buf = Vec::new(); - let serialized: &[u8] = original.serialize_into::(&mut buf); - let deserialized = unsafe { BitmapView::deserialize::(serialized) }; - assert_eq!(&original, &*deserialized); - assert!(original.iter().eq(deserialized.iter())); - } -} diff --git a/fuzz/.gitignore b/fuzz/.gitignore deleted file mode 100644 index 1a45eee..0000000 --- a/fuzz/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -corpus -artifacts -coverage diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml deleted file mode 100644 index 8532d7a..0000000 --- a/fuzz/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "croaring-fuzz" -version = "0.0.0" -publish = false -edition = "2021" - -[package.metadata] -cargo-fuzz = true - -[dependencies] -libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] } -bitvec = "1.0.1" - -croaring = { path = "../croaring" } - - -# Prevent this from interfering with workspaces -[workspace] -members = ["."] - -[profile.release] -debug = 1 - -[[bin]] -name = "fuzz_ops" -path = "fuzz_targets/fuzz_ops.rs" -test = false -doc = false - -[[bin]] -name = "against_bitvec" -path = "fuzz_targets/against_bitvec.rs" -test = false -doc = false - -[[bin]] -name = "deserialize" -path = "fuzz_targets/deserialize.rs" -test = false -doc = false diff --git a/fuzz/fuzz_targets/against_bitvec.rs b/fuzz/fuzz_targets/against_bitvec.rs deleted file mode 100644 index 895a8f6..0000000 --- a/fuzz/fuzz_targets/against_bitvec.rs +++ /dev/null @@ -1,271 +0,0 @@ -#![no_main] - -use crate::arbitrary_ops::*; -use bitvec::prelude::*; -use croaring::{Bitmap, Frozen, Native, Portable}; -use libfuzzer_sys::arbitrary; -use libfuzzer_sys::arbitrary::Arbitrary; -use libfuzzer_sys::fuzz_target; - -mod arbitrary_ops; - -fuzz_target!(|input: FuzzInput| { - let mut lhs = Bitmap::new(); - let mut rhs = Bitmap::new(); - - let mut lhs_check = bitvec![0; 4 * 0x1_0000]; - let mut rhs_check = bitvec![0; 4 * 0x1_0000]; - - for op in input.lhs_ops { - op.on_roaring(&mut lhs); - op.on_bitvec(&mut lhs_check); - check_equal(&lhs, &lhs_check); - } - for op in input.rhs_ops { - op.on_roaring(&mut rhs); - op.on_bitvec(&mut rhs_check); - check_equal(&rhs, &rhs_check); - } - - for op in &input.comp_ops { - op.on_roaring(&mut lhs, &rhs); - op.on_bitvec(&mut lhs_check, &rhs); - check_equal(&lhs, &lhs_check); - } - - for op in &input.view_ops { - op.on_both(&rhs, &rhs_check); - op.on_both(&lhs, &lhs_check); - } -}); - -#[derive(Arbitrary, Debug)] -struct FuzzInput { - lhs_ops: Vec, - rhs_ops: Vec, - comp_ops: Vec, - view_ops: Vec, -} - -impl ReadBitmapOp { - fn on_both(&self, b: &Bitmap, v: &BitSlice) { - match *self { - ReadBitmapOp::ContainsRange(ref r) => { - assert_eq!( - v[r.start().0 as usize..=r.end().0 as usize].all(), - b.contains_range(r.start().0..=r.end().0) - ); - } - ReadBitmapOp::Contains(i) => { - assert_eq!(v[i.0 as usize], b.contains(i.0)); - } - ReadBitmapOp::RangeCardinality(ref r) => { - assert_eq!( - v[r.start().0 as usize..=r.end().0 as usize].count_ones() as u64, - b.range_cardinality(r.start().0..=r.end().0) - ); - } - ReadBitmapOp::Cardinality => { - assert_eq!(v.count_ones() as u64, b.cardinality()); - } - ReadBitmapOp::Flip(ref r) => { - b.flip(r.start().0..=r.end().0); - } - ReadBitmapOp::ToVec => { - let vec_iter = b.to_vec(); - assert!(vec_iter.into_iter().eq(v.iter_ones().map(|i| i as u32))); - } - ReadBitmapOp::GetPortableSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::GetNativeSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::GetFrozenSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::IsEmpty => { - assert_eq!(v.not_any(), b.is_empty()); - } - ReadBitmapOp::IntersectWithRange(ref r) => { - assert_eq!( - v[r.start().0 as usize..=r.end().0 as usize].any(), - b.intersect_with_range(r.start().0..=r.end().0) - ); - } - ReadBitmapOp::Minimum => { - assert_eq!(v.first_one().map(|i| i as u32), b.minimum()); - } - ReadBitmapOp::Maximum => { - assert_eq!(v.last_one().map(|i| i as u32), b.maximum()); - } - ReadBitmapOp::Rank(i) => { - assert_eq!( - v.iter_ones().take_while(|&n| n <= i.0 as usize).count() as u64, - b.rank(i.0), - ); - } - ReadBitmapOp::Index(Num(i)) => { - let actual = b.position(i); - if let Some(actual) = actual { - assert!(v[i as usize]); - assert_eq!(v[..i as usize].count_ones(), actual as usize); - } else { - assert!(!v[i as usize]); - } - } - ReadBitmapOp::Select(i) => { - assert_eq!( - v.iter_ones().nth(i.0 as usize).map(|n| n as u32), - b.select(i.0), - ); - } - ReadBitmapOp::Statistics => { - b.statistics(); - } - ReadBitmapOp::Clone => { - drop(b.clone()); - } - ReadBitmapOp::Debug => { - use std::io::Write; - write!(std::io::sink(), "{:?}", b).unwrap(); - } - ReadBitmapOp::WithIter(ref iter_ops) => { - let mut iter = b.iter(); - for op in iter_ops { - match *op { - IterOperation::ResetAtOrAfter(i) => { - iter.reset_at_or_after(i); - } - IterOperation::ReadNext => { - iter.next(); - } - IterOperation::NextMany(n) => { - let mut v = vec![0; n as usize]; - iter.next_many(&mut v); - } - } - } - } - ReadBitmapOp::AddOffset(i) => { - b.add_offset(i); - } - } - b.internal_validate().unwrap(); - } -} - -impl MutableBitmapOperation { - fn on_bitvec(&self, b: &mut BitSlice) { - match *self { - MutableBitmapOperation::Add(i) | MutableBitmapOperation::AddChecked(i) => { - b.set(i.0 as usize, true); - } - MutableBitmapOperation::AddMany(ref items) => { - for i in items { - b.set(i.0 as usize, true); - } - } - MutableBitmapOperation::AddRange(ref r) => { - b[r.start().0 as usize..=r.end().0 as usize].fill(true); - } - MutableBitmapOperation::RemoveRange(ref r) => { - b[r.start().0 as usize..=r.end().0 as usize].fill(false); - } - MutableBitmapOperation::Clear => { - b.fill(false); - } - MutableBitmapOperation::Remove(i) | MutableBitmapOperation::RemoveChecked(i) => { - b.set(i.0 as usize, false); - } - MutableBitmapOperation::FlipInplace(ref r) => { - let _ = !&mut b[r.start().0 as usize..=r.end().0 as usize]; - } - MutableBitmapOperation::ShrinkToFit - | MutableBitmapOperation::RunOptimize - | MutableBitmapOperation::RemoveRunCompression => {} - MutableBitmapOperation::MakeBitmap { key } => { - if key < (MAX_NUM / 0x1_0000) as u16 { - let key = usize::from(key); - let start = key * 0x1_0000; - let end = start + 9 * 1024; - for i in (start..end).step_by(2) { - b.set(i, true); - } - } - } - MutableBitmapOperation::MakeRange { key } => { - if key < (MAX_NUM / 0x1_0000) as u16 { - let key = usize::from(key); - let start = key * 0x1_0000; - let end = start + 0x0_FFFF; - b[start..=end].fill(true); - } - } - } - } -} - -impl BitmapCompOperation { - fn on_bitvec(&self, lhs: &mut BitSlice, rhs: &Bitmap) { - match *self { - BitmapCompOperation::Eq - | BitmapCompOperation::IsSubset - | BitmapCompOperation::IsStrictSubset - | BitmapCompOperation::Intersect - | BitmapCompOperation::JacardIndex => {} - BitmapCompOperation::And => { - let tmp = to_bitvec(rhs, lhs.len()); - *lhs &= &tmp; - } - BitmapCompOperation::Or => { - for i in rhs.iter() { - let i = i as usize; - if i >= lhs.len() { - break; - } - lhs.set(i, true); - } - } - BitmapCompOperation::Xor => { - for i in rhs.iter() { - let i = i as usize; - if i >= lhs.len() { - break; - } - let old_val = *lhs.get(i).unwrap(); - lhs.set(i, !old_val); - } - } - BitmapCompOperation::AndNot => { - for i in rhs.iter() { - let i = i as usize; - if i >= lhs.len() { - break; - } - lhs.set(i, false); - } - } - } - rhs.internal_validate().unwrap(); - } -} - -fn to_bitvec(b: &Bitmap, max: usize) -> BitVec { - let mut res = bitvec![0; max]; - for i in b.iter() { - let i = i as usize; - if i >= max { - break; - } - res.set(i, true); - } - res -} - -fn check_equal(b: &Bitmap, v: &BitSlice) { - let lhs = b.iter().take_while(|&i| i < v.len() as u32); - let rhs = v.iter_ones().map(|i| i as u32); - - assert!(lhs.eq(rhs), "{b:?}") -} diff --git a/fuzz/fuzz_targets/arbitrary_ops/mod.rs b/fuzz/fuzz_targets/arbitrary_ops/mod.rs deleted file mode 100644 index d509d35..0000000 --- a/fuzz/fuzz_targets/arbitrary_ops/mod.rs +++ /dev/null @@ -1,212 +0,0 @@ -use croaring::Bitmap; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; -use std::mem; -use std::ops::RangeInclusive; - -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] -#[repr(transparent)] -pub struct Num(pub u32); - -pub const MAX_NUM: u32 = 0x1_0000 * 4; - -impl<'a> Arbitrary<'a> for Num { - fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - Ok(Self(u.int_in_range(0..=(MAX_NUM - 1))?)) - } -} - -#[derive(Arbitrary, Debug)] -pub enum MutableBitmapOperation { - Add(Num), - AddChecked(Num), - AddMany(Vec), - AddRange(RangeInclusive), - RemoveRange(RangeInclusive), - Clear, - Remove(Num), - RemoveChecked(Num), - FlipInplace(RangeInclusive), - ShrinkToFit, - RunOptimize, - RemoveRunCompression, - // Probably turn it into a bitmap - MakeBitmap { key: u16 }, - MakeRange { key: u16 }, -} - -#[derive(Arbitrary, Debug)] -pub enum ReadBitmapOp { - ContainsRange(RangeInclusive), - Contains(Num), - RangeCardinality(RangeInclusive), - Cardinality, - Flip(RangeInclusive), - ToVec, - GetPortableSerializedSizeInBytes, - GetNativeSerializedSizeInBytes, - GetFrozenSerializedSizeInBytes, - IsEmpty, - AddOffset(i64), - IntersectWithRange(RangeInclusive), - Minimum, - Maximum, - Rank(Num), - Index(Num), - Select(Num), - Statistics, - Clone, - Debug, - WithIter(Vec), -} - -#[derive(Arbitrary, Debug)] -pub enum BitmapCompOperation { - Eq, - IsSubset, - IsStrictSubset, - Intersect, - JacardIndex, - And, - Or, - Xor, - AndNot, -} - -#[derive(Arbitrary, Debug)] -pub enum IterOperation { - ResetAtOrAfter(u32), - ReadNext, - NextMany(u16), -} - -impl MutableBitmapOperation { - pub fn on_roaring(&self, b: &mut Bitmap) { - match *self { - MutableBitmapOperation::Add(i) => { - b.add(i.0); - } - MutableBitmapOperation::AddChecked(i) => { - b.add_checked(i.0); - } - MutableBitmapOperation::AddMany(ref items) => { - let items: &[u32] = unsafe { mem::transmute(&items[..]) }; - b.add_many(&items); - } - MutableBitmapOperation::AddRange(ref r) => { - b.add_range(r.start().0..=r.end().0); - } - MutableBitmapOperation::RemoveRange(ref r) => { - b.remove_range(r.start().0..=r.end().0); - } - MutableBitmapOperation::Clear => { - b.clear(); - } - MutableBitmapOperation::Remove(i) => { - b.remove(i.0); - } - MutableBitmapOperation::RemoveChecked(i) => { - b.remove_checked(i.0); - } - MutableBitmapOperation::FlipInplace(ref r) => { - b.flip_inplace(r.start().0..=r.end().0); - } - MutableBitmapOperation::ShrinkToFit => { - b.shrink_to_fit(); - } - MutableBitmapOperation::RunOptimize => { - b.run_optimize(); - } - MutableBitmapOperation::RemoveRunCompression => { - b.remove_run_compression(); - } - MutableBitmapOperation::MakeBitmap { key } => { - let key = u32::from(key); - let start = key * 0x1_0000; - let end = start + 9 * 1024; - for i in (start..end).step_by(2) { - b.add(i); - } - } - MutableBitmapOperation::MakeRange { key } => { - let key = u32::from(key); - let start = key * 0x1_0000; - let end = start + 0x0_FFFF; - b.add_range(start..=end) - } - } - b.internal_validate().unwrap(); - b.remove_range(MAX_NUM..); - b.internal_validate().unwrap(); - } -} - -impl BitmapCompOperation { - pub fn on_roaring(&self, lhs: &mut Bitmap, rhs: &Bitmap) { - match *self { - BitmapCompOperation::Eq => { - _ = lhs == rhs; - assert_eq!(lhs, lhs); - } - BitmapCompOperation::IsSubset => { - lhs.is_subset(rhs); - assert!(lhs.is_subset(lhs)); - } - BitmapCompOperation::IsStrictSubset => { - lhs.is_strict_subset(rhs); - assert!(!lhs.is_strict_subset(lhs)); - } - BitmapCompOperation::Intersect => { - lhs.intersect(rhs); - assert!(lhs.is_empty() || lhs.intersect(lhs)); - } - BitmapCompOperation::JacardIndex => { - lhs.jaccard_index(rhs); - lhs.jaccard_index(lhs); - } - BitmapCompOperation::And => { - assert_eq!(lhs.and(lhs), *lhs); - - let res = lhs.and(rhs); - res.internal_validate().unwrap(); - assert_eq!(res.cardinality(), lhs.and_cardinality(rhs)); - lhs.and_inplace(rhs); - assert_eq!(*lhs, res); - } - BitmapCompOperation::Or => { - assert_eq!(lhs.or(lhs), *lhs); - - let res = lhs.or(rhs); - res.internal_validate().unwrap(); - assert_eq!(res.cardinality(), lhs.or_cardinality(rhs)); - assert_eq!(res, Bitmap::fast_or(&[lhs, rhs])); - assert_eq!(res, Bitmap::fast_or_heap(&[lhs, rhs])); - - lhs.or_inplace(rhs); - assert_eq!(*lhs, res); - } - BitmapCompOperation::Xor => { - assert!(lhs.xor(lhs).is_empty()); - - let res = lhs.xor(rhs); - res.internal_validate().unwrap(); - assert_eq!(res.cardinality(), lhs.xor_cardinality(rhs)); - assert_eq!(res, Bitmap::fast_xor(&[lhs, rhs])); - - lhs.xor_inplace(rhs); - assert_eq!(*lhs, res); - } - BitmapCompOperation::AndNot => { - assert!(lhs.andnot(lhs).is_empty()); - - let res = lhs.andnot(rhs); - res.internal_validate().unwrap(); - assert_eq!(res.cardinality(), lhs.andnot_cardinality(rhs)); - - lhs.andnot_inplace(rhs); - assert_eq!(*lhs, res); - } - } - lhs.internal_validate().unwrap(); - rhs.internal_validate().unwrap(); - } -} diff --git a/fuzz/fuzz_targets/deserialize.rs b/fuzz/fuzz_targets/deserialize.rs deleted file mode 100644 index f4c1a09..0000000 --- a/fuzz/fuzz_targets/deserialize.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![no_main] - -use croaring::{Bitmap, Native, Portable}; -use libfuzzer_sys::fuzz_target; - -fn check_bitmap(input: &[u8]) { - let bitmap = Bitmap::try_deserialize::(input); - if let Some(mut bitmap) = bitmap { - bitmap.internal_validate().unwrap(); - - let start_cardinality = bitmap.cardinality(); - let mut new_cardinality = start_cardinality; - for i in 100..1000 { - if !bitmap.contains(i) { - bitmap.add(i); - new_cardinality += 1; - } - } - assert_eq!(new_cardinality, bitmap.cardinality()); - - let unsafe_version = unsafe { D::try_deserialize_unchecked(input) }; - assert_eq!(bitmap, unsafe_version); - } -} - -fuzz_target!(|input: &[u8]| { - check_bitmap::(input); - check_bitmap::(input); -}); diff --git a/fuzz/fuzz_targets/fuzz_ops.rs b/fuzz/fuzz_targets/fuzz_ops.rs deleted file mode 100644 index b5c6a91..0000000 --- a/fuzz/fuzz_targets/fuzz_ops.rs +++ /dev/null @@ -1,148 +0,0 @@ -#![no_main] - -use crate::arbitrary_ops::*; -use croaring::{Bitmap, BitmapView, Frozen, Native, Portable}; -use libfuzzer_sys::arbitrary; -use libfuzzer_sys::arbitrary::Arbitrary; -use libfuzzer_sys::fuzz_target; - -mod arbitrary_ops; - -fuzz_target!(|input: FuzzInput| { - let mut lhs = Bitmap::new(); - let mut rhs = Bitmap::new(); - - for op in &input.lhs_ops { - op.on_roaring(&mut lhs); - } - for op in &input.rhs_ops { - op.on_roaring(&mut rhs); - } - - for op in &input.comp_ops { - op.on_roaring(&mut lhs, &rhs); - } - - for op in &input.view_ops { - op.on_roaring(&rhs); - op.on_roaring(&lhs); - } - - let mut v = Vec::new(); - let to_compare = lhs.clone(); - check_serialized(&mut lhs, &to_compare, &mut v, &input); - check_serialized(&mut lhs, &rhs, &mut v, &input); -}); - -fn check_serialized(lhs: &mut Bitmap, to_compare: &Bitmap, v: &mut Vec, input: &FuzzInput) { - v.clear(); - - let data = to_compare.serialize::(); - let data2 = to_compare.serialize_into::(v); - let view1 = unsafe { BitmapView::deserialize::(&data) }; - assert_eq!(view1, *to_compare); - let view2 = unsafe { BitmapView::deserialize::(data2) }; - assert_eq!(view2, *to_compare); - - for op in &input.view_ops { - op.on_roaring(&view1); - op.on_roaring(&view2); - } - for op in &input.comp_ops { - op.on_roaring(lhs, &view1); - op.on_roaring(lhs, &view2); - } -} - -#[derive(Arbitrary, Debug)] -struct FuzzInput { - lhs_ops: Vec, - rhs_ops: Vec, - comp_ops: Vec, - view_ops: Vec, -} - -impl ReadBitmapOp { - pub fn on_roaring(&self, b: &Bitmap) { - match *self { - ReadBitmapOp::ContainsRange(ref r) => { - b.contains_range(r.start().0..=r.end().0); - } - ReadBitmapOp::Contains(i) => { - b.contains(i.0); - } - ReadBitmapOp::RangeCardinality(ref r) => { - b.range_cardinality(r.start().0..=r.end().0); - } - ReadBitmapOp::Cardinality => { - b.cardinality(); - } - ReadBitmapOp::Flip(ref r) => { - b.flip(r.start().0..=r.end().0); - } - ReadBitmapOp::ToVec => { - drop(b.to_vec()); - } - ReadBitmapOp::GetPortableSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::GetNativeSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::GetFrozenSerializedSizeInBytes => { - b.get_serialized_size_in_bytes::(); - } - ReadBitmapOp::IsEmpty => { - assert_eq!(b.is_empty(), b.cardinality() == 0); - } - ReadBitmapOp::IntersectWithRange(ref r) => { - b.intersect_with_range(r.start().0..=r.end().0); - } - ReadBitmapOp::Minimum => { - b.minimum(); - } - ReadBitmapOp::Maximum => { - b.maximum(); - } - ReadBitmapOp::Rank(i) => { - b.rank(i.0); - } - ReadBitmapOp::Index(i) => { - b.position(i.0); - } - ReadBitmapOp::Select(i) => { - b.select(i.0); - } - ReadBitmapOp::Statistics => { - b.statistics(); - } - ReadBitmapOp::Clone => { - drop(b.clone()); - } - ReadBitmapOp::Debug => { - use std::io::Write; - write!(std::io::sink(), "{:?}", b).unwrap(); - } - ReadBitmapOp::WithIter(ref iter_ops) => { - let mut iter = b.iter(); - for op in iter_ops { - match *op { - IterOperation::ResetAtOrAfter(i) => { - iter.reset_at_or_after(i); - } - IterOperation::ReadNext => { - iter.next(); - } - IterOperation::NextMany(n) => { - let mut v = vec![0; n as usize]; - assert!(iter.next_many(&mut v) <= n as usize); - } - } - } - } - ReadBitmapOp::AddOffset(i) => { - b.add_offset(i); - } - } - } -} diff --git a/fuzz/rust-toolchain.toml b/fuzz/rust-toolchain.toml deleted file mode 100644 index 5d56faf..0000000 --- a/fuzz/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "nightly" diff --git a/croaring-sys/CRoaring/roaring.c b/roaring.c similarity index 100% rename from croaring-sys/CRoaring/roaring.c rename to roaring.c diff --git a/croaring-sys/CRoaring/roaring.h b/roaring.h similarity index 100% rename from croaring-sys/CRoaring/roaring.h rename to roaring.h diff --git a/roaring_fast_or.c b/roaring_fast_or.c index a5a0c0a..3ac7723 100644 --- a/roaring_fast_or.c +++ b/roaring_fast_or.c @@ -1,4 +1,4 @@ -#include "croaring-sys/CRoaring/roaring.c" +#include "roaring.c" int main(void) { roaring_bitmap_t *r1 = roaring_bitmap_of(2, 500, 1000);