inkcpp_rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +84 -0
- data/LICENSE +7 -0
- data/README.md +3 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +10 -0
- data/bin/tapioca +29 -0
- data/ext/inkcpp_rb/extconf.rb +19 -0
- data/ext/inkcpp_rb/inkcpp/.clang-format +99 -0
- data/ext/inkcpp_rb/inkcpp/.github/FUNDING.yml +1 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/build.yml +344 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/release.yml +49 -0
- data/ext/inkcpp_rb/inkcpp/.gitignore +25 -0
- data/ext/inkcpp_rb/inkcpp/.gitmodules +9 -0
- data/ext/inkcpp_rb/inkcpp/CMakeLists.txt +170 -0
- data/ext/inkcpp_rb/inkcpp/CODE_OF_CONDUCT.md +76 -0
- data/ext/inkcpp_rb/inkcpp/CONTRIBUTING.md +55 -0
- data/ext/inkcpp_rb/inkcpp/Config.cmake.in +2 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/CMakeLists.txt +13 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.c +38 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink.json +1 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/InkCPP_DEMO.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/CreateThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/HandleChoice.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ListElementOf.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalRuntime.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ObseverChange.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/TagListGetValue.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/YieldResume.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Doxyfile +2825 -0
- data/ext/inkcpp_rb/inkcpp/LICENSE.txt +22 -0
- data/ext/inkcpp_rb/inkcpp/Minimal.runsettings +8 -0
- data/ext/inkcpp_rb/inkcpp/README.md +192 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/CMakeLists.txt +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/array.h +481 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/avl_array.h +833 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/casting.h +93 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.cpp +124 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.h +406 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.cpp +52 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.h +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/executioner.h +179 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functional.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.h +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.cpp +289 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.h +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/header.cpp +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/choice.h +106 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/functional.h +327 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/globals.h +196 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/list.h +187 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/runner.h +291 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/snapshot.h +61 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story.h +219 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story_ptr.h +233 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/traits.h +270 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/types.h +169 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.cpp +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.h +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.cpp +276 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.h +356 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.cpp +841 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.h +450 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.h +529 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operation_bases.h +164 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operations.h +100 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.cpp +528 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.h +153 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/platform.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/random.h +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.cpp +1396 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.h +336 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/simple_restorable_stack.h +335 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.cpp +182 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.h +91 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_interface.h +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.cpp +618 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.h +243 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.cpp +361 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.h +92 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_ptr.cpp +75 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.cpp +125 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.h +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.cpp +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.h +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_utils.h +207 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/system.cpp +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/tuple.hpp +151 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.cpp +279 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.h +666 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/CMakeLists.txt +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/include/inkcpp.h +393 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp.cpp +344 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp_c.pc.in +10 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/ExternalFunction.c +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Globals.c +98 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Lists.c +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Observer.c +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Snapshot.c +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/CMakeLists.txt +49 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/inkcpp_cl.cpp +215 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.cpp +209 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.h +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/CMakeLists.txt +37 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.cpp +446 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.cpp +166 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.h +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/command.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/compiler.cpp +96 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.cpp +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.h +104 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compilation_results.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compiler.h +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json.hpp +24596 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.cpp +411 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.h +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h +55 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/CMakeLists.txt +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/example.py +78 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/src/module.cpp +317 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/conftest.py +53 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_ExternalFunctions.py +35 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Globals.py +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Lists.py +43 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Observer.py +27 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Snapshot.py +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/unreal_example.ink +71 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Array.cpp +115 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/CMakeLists.txt +117 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Callstack.cpp +392 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/EmptyStringForDivert.cpp +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ExternalFunctionsExecuteProperly.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/FallbackFunction.cpp +77 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Globals.cpp +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/InkyJson.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LabelCondition.cpp +60 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Lists.cpp +144 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp +46 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Main.cpp +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/MoveTo.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NewLines.cpp +76 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NoEarlyTags.cpp +33 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Observer.cpp +245 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Pointer.cpp +191 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Restorable.cpp +294 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/SpaceAfterBracketChoice.cpp +45 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Stack.cpp +224 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Tags.cpp +131 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ThirdTierChoiceAfterBrackets.cpp +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/UTF8.cpp +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Value.cpp +210 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/catch.hpp +17970 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/AHF.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ChoiceBracketStory.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/EmptyStringForDivert.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ExternalFunctionsExecuteProperly.ink +11 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/FallBack.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/GlobalStory.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LabelConditionStory.ink +5 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LinesStory.ink +42 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListLogicStory.ink +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LookaheadSafe.ink +14 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/MoveTo.ink +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/NoEarlyTags.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ObserverStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/SimpleStoryFlow.ink +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TagsStory.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TheIntercept.ink +1686 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ThirdTierChoiceAfterBracketsStory.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF-8-demo.txt +212 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF8Story.ink +218 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inklecate.json +154 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inky.json +160 -0
- data/ext/inkcpp_rb/inkcpp/notes/ArchitectureNotes.md +54 -0
- data/ext/inkcpp_rb/inkcpp/notes/ListNotes.md +69 -0
- data/ext/inkcpp_rb/inkcpp/notes/OperationNotes.md +35 -0
- data/ext/inkcpp_rb/inkcpp/notes/TagsNotes.md +24 -0
- data/ext/inkcpp_rb/inkcpp/notes/WhitespaceNotes.md +28 -0
- data/ext/inkcpp_rb/inkcpp/proofing/README.md +3 -0
- data/ext/inkcpp_rb/inkcpp/proofing/inkcpp_runtime_driver +12 -0
- data/ext/inkcpp_rb/inkcpp/pyproject.toml +63 -0
- data/ext/inkcpp_rb/inkcpp/setup.py +166 -0
- data/ext/inkcpp_rb/inkcpp/shared/CMakeLists.txt +14 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/command.h +172 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/header.h +46 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/config.h +53 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/system.h +307 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/version.h +14 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestAllSequenceTypes.ink +59 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestArithmetic.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicStringLiterals.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicTunnel.ink +10 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBlanksInInlineSequences.ink +51 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCallStackEvaluation.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceCount.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceDivertsToDone.ink +6 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceWithBracketsOnly.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCompareDivertTargets.ink +26 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestComplexTunnels.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestConditionalChoiceInWeave.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestTunnelOnwardsAfterTunnel.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/unreal/CMakeLists.txt +51 -0
- data/ext/inkcpp_rb/inkcpp/unreal/UE_example.ink +92 -0
- data/ext/inkcpp_rb/inkcpp/unreal/blueprint_filter.js +377 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Resources/Icon128.png +0 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkAsset.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkChoice.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkRuntime.cpp +265 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkThread.cpp +239 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkVar.cpp +143 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/TagList.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/inkcpp.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkAsset.h +50 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkChoice.h +58 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkDelegates.h +139 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkList.h +102 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkRuntime.h +177 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkSnapshot.h +30 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkThread.h +215 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkVar.h +245 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/TagList.h +77 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/inkcpp.h +217 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/inkcpp.Build.cs +62 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.cpp +237 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.h +43 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inkcpp_editor.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in +24 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Public/inkcpp_editor.h +9 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/inkcpp_editor.Build.cs +61 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/inkcpp.uplugin +44 -0
- data/ext/inkcpp_rb/inkcpp/unreal/render.css +1 -0
- data/ext/inkcpp_rb/inkcpp_rb.cpp +321 -0
- data/inkcpp_rb.gemspec +54 -0
- data/rbi/inkcpp_rb.rbi +211 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
- data/sorbet/rbi/gems/minitest@5.25.4.rbi +1547 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/prism@1.3.0.rbi +40040 -0
- data/sorbet/rbi/gems/rake-compiler@1.2.8.rbi +9 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3033 -0
- data/sorbet/rbi/gems/rbi@0.2.2.rbi +4527 -0
- data/sorbet/rbi/gems/rice@4.3.3.rbi +44 -0
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
- data/sorbet/rbi/gems/tapioca@0.16.7.rbi +3611 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18379 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +400 -0
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright
|
|
3
|
+
// \author (c) Marco Paland (info@paland.com)
|
|
4
|
+
// 2017, PALANDesign Hannover, Germany
|
|
5
|
+
//
|
|
6
|
+
// \license The MIT License (MIT)
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
// in the Software without restriction, including without limitation the rights
|
|
11
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
// furnished to do so, subject to the following conditions:
|
|
14
|
+
//
|
|
15
|
+
// The above copyright notice and this permission notice shall be included in
|
|
16
|
+
// all copies or substantial portions of the Software.
|
|
17
|
+
//
|
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
// THE SOFTWARE.
|
|
25
|
+
//
|
|
26
|
+
// \brief avl_array class
|
|
27
|
+
// This is an AVL tree implementation using an array as data structure.
|
|
28
|
+
// avl_array combines the insert/delete and find advantages (log n) of an AVL tree
|
|
29
|
+
// with a static allocated arrays and minimal storage overhead.
|
|
30
|
+
// If memory is critical the 'Fast' template parameter can be set to false which
|
|
31
|
+
// removes the parent member of every node. This saves sizeof(size_type) * Size bytes,
|
|
32
|
+
// but slowes down the insert and delete operation by factor 10 due to 'parent search'.
|
|
33
|
+
// The find opeartion is not affected cause finding doesn't need a parent.
|
|
34
|
+
//
|
|
35
|
+
// usage:
|
|
36
|
+
// #include "avl_array.h"
|
|
37
|
+
// avl_array<int, int, int, 1024> avl;
|
|
38
|
+
// avl.insert(1, 1);
|
|
39
|
+
//
|
|
40
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
41
|
+
|
|
42
|
+
#ifndef _AVL_ARRAY_H_
|
|
43
|
+
#define _AVL_ARRAY_H_
|
|
44
|
+
|
|
45
|
+
#include "system.h"
|
|
46
|
+
|
|
47
|
+
#include <cstdint>
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* \param Key The key type. The type (class) must provide a 'less than' and 'equal to' operator
|
|
52
|
+
* \param T The Data type
|
|
53
|
+
* \param size_type Container size type
|
|
54
|
+
* \param Size Container size
|
|
55
|
+
* \param Fast If true every node stores an extra parent index. This increases memory but speed up insert/erase by factor 10
|
|
56
|
+
*/
|
|
57
|
+
template<typename Key, typename T, typename size_type, const size_type Size, const bool Fast = true>
|
|
58
|
+
class avl_array
|
|
59
|
+
{
|
|
60
|
+
// child index pointer class
|
|
61
|
+
typedef struct tag_child_type {
|
|
62
|
+
size_type left;
|
|
63
|
+
size_type right;
|
|
64
|
+
} child_type;
|
|
65
|
+
|
|
66
|
+
// node storage, due to possible structure packing effects, single arrays are used instead of a 'node' structure
|
|
67
|
+
Key key_[Size]; // node key
|
|
68
|
+
T val_[Size]; // node value
|
|
69
|
+
std::int8_t balance_[Size]; // subtree balance
|
|
70
|
+
child_type child_[Size]; // node childs
|
|
71
|
+
size_type size_; // actual size
|
|
72
|
+
size_type root_; // root node
|
|
73
|
+
size_type parent_[Fast ? Size : 1]; // node parent, use one element if not needed (zero sized array is not allowed)
|
|
74
|
+
|
|
75
|
+
// invalid index (like 'nullptr' in a pointer implementation)
|
|
76
|
+
static const size_type INVALID_IDX = Size;
|
|
77
|
+
|
|
78
|
+
// iterator class
|
|
79
|
+
template<bool Const>
|
|
80
|
+
class tag_avl_array_iterator
|
|
81
|
+
{
|
|
82
|
+
template<bool Con, typename T1, typename T2>
|
|
83
|
+
using if_t = ink::runtime::internal::if_t<Con, T1, T2>;
|
|
84
|
+
if_t<Const, const avl_array*, avl_array*>
|
|
85
|
+
instance_; // array instance
|
|
86
|
+
size_type idx_; // actual node
|
|
87
|
+
|
|
88
|
+
friend avl_array; // avl_array may access index pointer
|
|
89
|
+
|
|
90
|
+
public:
|
|
91
|
+
|
|
92
|
+
// ctor
|
|
93
|
+
tag_avl_array_iterator(if_t<Const, const avl_array*,avl_array*> instance = nullptr, size_type idx = 0U)
|
|
94
|
+
: instance_(instance)
|
|
95
|
+
, idx_(idx)
|
|
96
|
+
{ }
|
|
97
|
+
|
|
98
|
+
template<bool C = Const, typename = ink::runtime::internal::enable_if_t<C>>
|
|
99
|
+
tag_avl_array_iterator(const tag_avl_array_iterator<false>& itr)
|
|
100
|
+
: instance_(itr.instance_)
|
|
101
|
+
, idx_(itr.idx_)
|
|
102
|
+
{}
|
|
103
|
+
|
|
104
|
+
inline tag_avl_array_iterator& operator=(const tag_avl_array_iterator& other)
|
|
105
|
+
{
|
|
106
|
+
instance_ = other.instance_;
|
|
107
|
+
idx_ = other.idx_;
|
|
108
|
+
return *this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
inline bool operator==(const tag_avl_array_iterator& rhs) const
|
|
112
|
+
{ return idx_ == rhs.idx_; }
|
|
113
|
+
|
|
114
|
+
inline bool operator!=(const tag_avl_array_iterator& rhs) const
|
|
115
|
+
{ return !(*this == rhs); }
|
|
116
|
+
|
|
117
|
+
// dereference - access value
|
|
118
|
+
inline if_t<Const, const T&, T&> operator*() const
|
|
119
|
+
{ return val(); }
|
|
120
|
+
|
|
121
|
+
// access value
|
|
122
|
+
inline if_t<Const, const T&, T&> val() const
|
|
123
|
+
{ return instance_->val_[idx_]; }
|
|
124
|
+
|
|
125
|
+
// access key
|
|
126
|
+
inline const Key& key() const
|
|
127
|
+
{ return instance_->key_[idx_]; }
|
|
128
|
+
|
|
129
|
+
// returns unique number for each entry
|
|
130
|
+
// the numbers are unique as long no operation are executed
|
|
131
|
+
// on the avl
|
|
132
|
+
inline size_t temp_identifier() const { return instance_->size() - idx_ - 1; }
|
|
133
|
+
|
|
134
|
+
// preincrement
|
|
135
|
+
tag_avl_array_iterator& operator++()
|
|
136
|
+
{
|
|
137
|
+
// end reached?
|
|
138
|
+
if (idx_ >= Size) {
|
|
139
|
+
return *this;
|
|
140
|
+
}
|
|
141
|
+
// take left most child of right child, if not existent, take parent
|
|
142
|
+
size_type i = instance_->child_[idx_].right;
|
|
143
|
+
if (i != instance_->INVALID_IDX) {
|
|
144
|
+
// successor is the furthest left node of right subtree
|
|
145
|
+
for (; i != instance_->INVALID_IDX; i = instance_->child_[i].left) {
|
|
146
|
+
idx_ = i;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// have already processed the left subtree, and
|
|
151
|
+
// there is no right subtree. move up the tree,
|
|
152
|
+
// looking for a parent for which nodePtr is a left child,
|
|
153
|
+
// stopping if the parent becomes NULL. a non-NULL parent
|
|
154
|
+
// is the successor. if parent is NULL, the original node
|
|
155
|
+
// was the last node inorder, and its successor
|
|
156
|
+
// is the end of the list
|
|
157
|
+
i = instance_->get_parent(idx_);
|
|
158
|
+
while ((i != instance_->INVALID_IDX) && (idx_ == instance_->child_[i].right)) {
|
|
159
|
+
idx_ = i;
|
|
160
|
+
i = instance_->get_parent(idx_);
|
|
161
|
+
}
|
|
162
|
+
idx_ = i;
|
|
163
|
+
}
|
|
164
|
+
return *this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// postincrement
|
|
168
|
+
inline tag_avl_array_iterator operator++(int)
|
|
169
|
+
{
|
|
170
|
+
tag_avl_array_iterator _copy = *this;
|
|
171
|
+
++(*this);
|
|
172
|
+
return _copy;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
public:
|
|
178
|
+
|
|
179
|
+
typedef T value_type;
|
|
180
|
+
typedef T* pointer;
|
|
181
|
+
typedef const T* const_pointer;
|
|
182
|
+
typedef T& reference;
|
|
183
|
+
typedef const T& const_reference;
|
|
184
|
+
typedef Key key_type;
|
|
185
|
+
typedef tag_avl_array_iterator<false> iterator;
|
|
186
|
+
typedef tag_avl_array_iterator<true> const_iterator;
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
// ctor
|
|
190
|
+
avl_array()
|
|
191
|
+
: size_(0U)
|
|
192
|
+
, root_(Size)
|
|
193
|
+
{ }
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
// iterators
|
|
197
|
+
inline iterator begin()
|
|
198
|
+
{
|
|
199
|
+
size_type i = INVALID_IDX;
|
|
200
|
+
if (root_ != INVALID_IDX) {
|
|
201
|
+
// find smallest element, it's the farthest node left from root
|
|
202
|
+
for (i = root_; child_[i].left != INVALID_IDX; i = child_[i].left);
|
|
203
|
+
}
|
|
204
|
+
return iterator(this, i);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
inline const_iterator begin() const
|
|
208
|
+
{
|
|
209
|
+
return const_iterator(const_cast<avl_array&>(*this).begin());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
inline iterator end()
|
|
213
|
+
{ return iterator(this, INVALID_IDX); }
|
|
214
|
+
|
|
215
|
+
inline const_iterator end() const
|
|
216
|
+
{
|
|
217
|
+
return const_iterator(this, INVALID_IDX);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
// capacity
|
|
222
|
+
inline size_type size() const
|
|
223
|
+
{ return size_; }
|
|
224
|
+
|
|
225
|
+
inline bool empty() const
|
|
226
|
+
{ return size_ == static_cast<size_type>(0); }
|
|
227
|
+
|
|
228
|
+
inline size_type max_size() const
|
|
229
|
+
{ return Size; }
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Clear the container
|
|
234
|
+
*/
|
|
235
|
+
inline void clear()
|
|
236
|
+
{
|
|
237
|
+
size_ = 0U;
|
|
238
|
+
root_ = INVALID_IDX;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Insert or update an element
|
|
244
|
+
* \param key The key to insert. If the key already exists, it is updated
|
|
245
|
+
* \param val Value to insert or update
|
|
246
|
+
* \return True if the key was successfully inserted or updated, false if container is full
|
|
247
|
+
*/
|
|
248
|
+
bool insert(const key_type& key, const value_type& val)
|
|
249
|
+
{
|
|
250
|
+
if (root_ == INVALID_IDX) {
|
|
251
|
+
key_[size_] = key;
|
|
252
|
+
val_[size_] = val;
|
|
253
|
+
balance_[size_] = 0;
|
|
254
|
+
child_[size_] = { INVALID_IDX, INVALID_IDX };
|
|
255
|
+
set_parent(size_, INVALID_IDX);
|
|
256
|
+
root_ = size_++;
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
for (size_type i = root_; i != INVALID_IDX; i = (key < key_[i]) ? child_[i].left : child_[i].right) {
|
|
261
|
+
if (key < key_[i]) {
|
|
262
|
+
if (child_[i].left == INVALID_IDX) {
|
|
263
|
+
if (size_ >= max_size()) {
|
|
264
|
+
// container is full
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
key_[size_] = key;
|
|
268
|
+
val_[size_] = val;
|
|
269
|
+
balance_[size_] = 0;
|
|
270
|
+
child_[size_] = { INVALID_IDX, INVALID_IDX };
|
|
271
|
+
set_parent(size_, i);
|
|
272
|
+
child_[i].left = size_++;
|
|
273
|
+
insert_balance(i, 1);
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else if (key_[i] == key) {
|
|
278
|
+
// found same key, update node
|
|
279
|
+
val_[i] = val;
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
if (child_[i].right == INVALID_IDX) {
|
|
284
|
+
if (size_ >= max_size()) {
|
|
285
|
+
// container is full
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
key_[size_] = key;
|
|
289
|
+
val_[size_] = val;
|
|
290
|
+
balance_[size_] = 0;
|
|
291
|
+
child_[size_] = { INVALID_IDX, INVALID_IDX };
|
|
292
|
+
set_parent(size_, i);
|
|
293
|
+
child_[i].right = size_++;
|
|
294
|
+
insert_balance(i, -1);
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// node doesn't fit (should not happen) - discard it anyway
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Find an element
|
|
306
|
+
* \param key The key to find
|
|
307
|
+
* \param val If key is found, the value of the element is set
|
|
308
|
+
* \return True if key was found
|
|
309
|
+
*/
|
|
310
|
+
inline bool find(const key_type& key, value_type& val) const
|
|
311
|
+
{
|
|
312
|
+
for (size_type i = root_; i != INVALID_IDX;) {
|
|
313
|
+
if (key < key_[i]) {
|
|
314
|
+
i = child_[i].left;
|
|
315
|
+
}
|
|
316
|
+
else if (key == key_[i]) {
|
|
317
|
+
// found key
|
|
318
|
+
val = val_[i];
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
i = child_[i].right;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// key not found
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Find an element and return an iterator as result
|
|
332
|
+
* \param key The key to find
|
|
333
|
+
* \return Iterator if key was found, else end() is returned
|
|
334
|
+
*/
|
|
335
|
+
inline iterator find(const key_type& key)
|
|
336
|
+
{
|
|
337
|
+
for (size_type i = root_; i != INVALID_IDX;) {
|
|
338
|
+
if (key < key_[i]) {
|
|
339
|
+
i = child_[i].left;
|
|
340
|
+
} else if (key == key_[i]) {
|
|
341
|
+
// found key
|
|
342
|
+
return iterator(this, i);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
i = child_[i].right;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// key not found, return end() iterator
|
|
349
|
+
return end();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
inline const_iterator find(const key_type& key) const
|
|
353
|
+
{
|
|
354
|
+
return const_iterator(const_cast<avl_array&>(*this).find(key));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Count elements with a specific key
|
|
360
|
+
* Searches the container for elements with a key equivalent to key and returns the number of matches.
|
|
361
|
+
* Because all elements are unique, the function can only return 1 (if the element is found) or zero (otherwise).
|
|
362
|
+
* \param key The key to find/count
|
|
363
|
+
* \return 0 if key was not found, 1 if key was found
|
|
364
|
+
*/
|
|
365
|
+
inline size_type count(const key_type& key)
|
|
366
|
+
{
|
|
367
|
+
return find(key) != end() ? 1U : 0U;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Remove element by key
|
|
373
|
+
* \param key The key of the element to remove
|
|
374
|
+
* \return True if the element ws removed, false if key was not found
|
|
375
|
+
*/
|
|
376
|
+
inline bool erase(const key_type& key)
|
|
377
|
+
{
|
|
378
|
+
return erase(find(key));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Remove element by iterator position
|
|
384
|
+
* THIS ERASE OPERATION INVALIDATES ALL ITERATORS!
|
|
385
|
+
* \param position The iterator position of the element to remove
|
|
386
|
+
* \return True if the element was successfully removed, false if error
|
|
387
|
+
*/
|
|
388
|
+
bool erase(iterator position)
|
|
389
|
+
{
|
|
390
|
+
if (empty() || (position == end())) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const size_type node = position.idx_;
|
|
395
|
+
const size_type left = child_[node].left;
|
|
396
|
+
const size_type right = child_[node].right;
|
|
397
|
+
|
|
398
|
+
if (left == INVALID_IDX) {
|
|
399
|
+
if (right == INVALID_IDX) {
|
|
400
|
+
if (node == root_) {
|
|
401
|
+
root_ = INVALID_IDX;
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
const size_type parent = get_parent(node);
|
|
405
|
+
if (child_[parent].left == node) {
|
|
406
|
+
child_[parent].left = INVALID_IDX;
|
|
407
|
+
delete_balance(parent, -1);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
child_[parent].right = INVALID_IDX;
|
|
411
|
+
delete_balance(parent, 1);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
const size_type parent = get_parent(node);
|
|
417
|
+
child_[parent].left == node ? child_[parent].left = right : child_[parent].right = right;
|
|
418
|
+
|
|
419
|
+
set_parent(right, parent);
|
|
420
|
+
|
|
421
|
+
delete_balance(right, 0);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else if (right == INVALID_IDX) {
|
|
425
|
+
const size_type parent = get_parent(node);
|
|
426
|
+
child_[parent].left == node ? child_[parent].left = left : child_[parent].right = left;
|
|
427
|
+
|
|
428
|
+
set_parent(left, parent);
|
|
429
|
+
|
|
430
|
+
delete_balance(left, 0);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
size_type successor = right;
|
|
434
|
+
if (child_[successor].left == INVALID_IDX) {
|
|
435
|
+
const size_type parent = get_parent(node);
|
|
436
|
+
child_[successor].left = left;
|
|
437
|
+
balance_[successor] = balance_[node];
|
|
438
|
+
set_parent(successor, parent);
|
|
439
|
+
set_parent(left, successor);
|
|
440
|
+
|
|
441
|
+
if (node == root_) {
|
|
442
|
+
root_ = successor;
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
if (child_[parent].left == node) {
|
|
446
|
+
child_[parent].left = successor;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
child_[parent].right = successor;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
delete_balance(successor, 1);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
while (child_[successor].left != INVALID_IDX) {
|
|
456
|
+
successor = child_[successor].left;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const size_type parent = get_parent(node);
|
|
460
|
+
const size_type successor_parent = get_parent(successor);
|
|
461
|
+
const size_type successor_right = child_[successor].right;
|
|
462
|
+
|
|
463
|
+
if (child_[successor_parent].left == successor) {
|
|
464
|
+
child_[successor_parent].left = successor_right;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
child_[successor_parent].right = successor_right;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
set_parent(successor_right, successor_parent);
|
|
471
|
+
set_parent(successor, parent);
|
|
472
|
+
set_parent(right, successor);
|
|
473
|
+
set_parent(left, successor);
|
|
474
|
+
child_[successor].left = left;
|
|
475
|
+
child_[successor].right = right;
|
|
476
|
+
balance_[successor] = balance_[node];
|
|
477
|
+
|
|
478
|
+
if (node == root_) {
|
|
479
|
+
root_ = successor;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
if (child_[parent].left == node) {
|
|
483
|
+
child_[parent].left = successor;
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
child_[parent].right = successor;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
delete_balance(successor_parent, -1);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
size_--;
|
|
493
|
+
|
|
494
|
+
// relocate the node at the end to the deleted node, if it's not the deleted one
|
|
495
|
+
if (node != size_) {
|
|
496
|
+
if (root_ == size_) {
|
|
497
|
+
root_ = node;
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
const size_type parent = get_parent(size_);
|
|
501
|
+
if (parent != INVALID_IDX) { // should never be invalid, but anyway for security
|
|
502
|
+
child_[parent].left == size_ ? child_[parent].left = node : child_[parent].right = node;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// correct childs parent
|
|
507
|
+
set_parent(child_[size_].left, node);
|
|
508
|
+
set_parent(child_[size_].right, node);
|
|
509
|
+
|
|
510
|
+
// move content
|
|
511
|
+
replace(node, size_);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Integrity (self) test
|
|
520
|
+
* \return True if the tree intergity is correct, false if error (should not happen normally)
|
|
521
|
+
*/
|
|
522
|
+
bool test() const
|
|
523
|
+
{
|
|
524
|
+
// check root
|
|
525
|
+
if (empty() && (root_ != INVALID_IDX)) {
|
|
526
|
+
// invalid root
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
if (size() && root_ >= size()) {
|
|
530
|
+
// root out of bounds
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// check tree
|
|
535
|
+
for (size_type i = 0U; i < size(); ++i)
|
|
536
|
+
{
|
|
537
|
+
if ((child_[i].left != INVALID_IDX) && (!(key_[child_[i].left] < key_[i]) || (key_[child_[i].left] == key_[i]))) {
|
|
538
|
+
// wrong key order to the left
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
if ((child_[i].right != INVALID_IDX) && ((key_[child_[i].right] < key_[i]) || (key_[child_[i].right] == key_[i]))) {
|
|
542
|
+
// wrong key order to the right
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
const size_type parent = get_parent(i);
|
|
546
|
+
if ((i != root_) && (parent == INVALID_IDX)) {
|
|
547
|
+
// no parent
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
if ((i == root_) && (parent != INVALID_IDX)) {
|
|
551
|
+
// invalid root parent
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// check passed
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
561
|
+
// Helper functions
|
|
562
|
+
private:
|
|
563
|
+
|
|
564
|
+
// find parent element
|
|
565
|
+
inline size_type get_parent(size_type node) const
|
|
566
|
+
{
|
|
567
|
+
if (Fast) {
|
|
568
|
+
return parent_[node];
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
const Key key_node = key_[node];
|
|
572
|
+
for (size_type i = root_; i != INVALID_IDX; i = (key_node < key_[i]) ? child_[i].left : child_[i].right) {
|
|
573
|
+
if ((child_[i].left == node) || (child_[i].right == node)) {
|
|
574
|
+
// found parent
|
|
575
|
+
return i;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
// parent not found
|
|
579
|
+
return INVALID_IDX;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
// set parent element (only in Fast version)
|
|
585
|
+
inline void set_parent(size_type node, size_type parent)
|
|
586
|
+
{
|
|
587
|
+
if (Fast) {
|
|
588
|
+
if (node != INVALID_IDX) {
|
|
589
|
+
parent_[node] = parent;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
inline void replace(size_type target, size_type source)
|
|
596
|
+
{
|
|
597
|
+
key_[target] = key_[source];
|
|
598
|
+
val_[target] = val_[source];
|
|
599
|
+
balance_[target] = balance_[source];
|
|
600
|
+
child_[target] = child_[source];
|
|
601
|
+
set_parent(target, get_parent(source));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
void insert_balance(size_type node, std::int8_t balance)
|
|
606
|
+
{
|
|
607
|
+
while (node != INVALID_IDX) {
|
|
608
|
+
balance = (balance_[node] += balance);
|
|
609
|
+
|
|
610
|
+
if (balance == 0) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
else if (balance == 2) {
|
|
614
|
+
if (balance_[child_[node].left] == 1) {
|
|
615
|
+
rotate_right(node);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
rotate_left_right(node);
|
|
619
|
+
}
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
else if (balance == -2) {
|
|
623
|
+
if (balance_[child_[node].right] == -1) {
|
|
624
|
+
rotate_left(node);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
rotate_right_left(node);
|
|
628
|
+
}
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const size_type parent = get_parent(node);
|
|
633
|
+
if (parent != INVALID_IDX) {
|
|
634
|
+
balance = child_[parent].left == node ? 1 : -1;
|
|
635
|
+
}
|
|
636
|
+
node = parent;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
void delete_balance(size_type node, std::int8_t balance)
|
|
642
|
+
{
|
|
643
|
+
while (node != INVALID_IDX) {
|
|
644
|
+
balance = (balance_[node] += balance);
|
|
645
|
+
|
|
646
|
+
if (balance == -2) {
|
|
647
|
+
if (balance_[child_[node].right] <= 0) {
|
|
648
|
+
node = rotate_left(node);
|
|
649
|
+
if (balance_[node] == 1) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
node = rotate_right_left(node);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
else if (balance == 2) {
|
|
658
|
+
if (balance_[child_[node].left] >= 0) {
|
|
659
|
+
node = rotate_right(node);
|
|
660
|
+
if (balance_[node] == -1) {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
node = rotate_left_right(node);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
else if (balance != 0) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (node != INVALID_IDX) {
|
|
673
|
+
const size_type parent = get_parent(node);
|
|
674
|
+
if (parent != INVALID_IDX) {
|
|
675
|
+
balance = child_[parent].left == node ? -1 : 1;
|
|
676
|
+
}
|
|
677
|
+
node = parent;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
size_type rotate_left(size_type node)
|
|
684
|
+
{
|
|
685
|
+
const size_type right = child_[node].right;
|
|
686
|
+
const size_type right_left = child_[right].left;
|
|
687
|
+
const size_type parent = get_parent(node);
|
|
688
|
+
|
|
689
|
+
set_parent(right, parent);
|
|
690
|
+
set_parent(node, right);
|
|
691
|
+
set_parent(right_left, node);
|
|
692
|
+
child_[right].left = node;
|
|
693
|
+
child_[node].right = right_left;
|
|
694
|
+
|
|
695
|
+
if (node == root_) {
|
|
696
|
+
root_ = right;
|
|
697
|
+
}
|
|
698
|
+
else if (child_[parent].right == node) {
|
|
699
|
+
child_[parent].right = right;
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
child_[parent].left = right;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
balance_[right]++;
|
|
706
|
+
balance_[node] = -balance_[right];
|
|
707
|
+
|
|
708
|
+
return right;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
size_type rotate_right(size_type node)
|
|
713
|
+
{
|
|
714
|
+
const size_type left = child_[node].left;
|
|
715
|
+
const size_type left_right = child_[left].right;
|
|
716
|
+
const size_type parent = get_parent(node);
|
|
717
|
+
|
|
718
|
+
set_parent(left, parent);
|
|
719
|
+
set_parent(node, left);
|
|
720
|
+
set_parent(left_right, node);
|
|
721
|
+
child_[left].right = node;
|
|
722
|
+
child_[node].left = left_right;
|
|
723
|
+
|
|
724
|
+
if (node == root_) {
|
|
725
|
+
root_ = left;
|
|
726
|
+
}
|
|
727
|
+
else if (child_[parent].left == node) {
|
|
728
|
+
child_[parent].left = left;
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
child_[parent].right = left;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
balance_[left]--;
|
|
735
|
+
balance_[node] = -balance_[left];
|
|
736
|
+
|
|
737
|
+
return left;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
size_type rotate_left_right(size_type node)
|
|
742
|
+
{
|
|
743
|
+
const size_type left = child_[node].left;
|
|
744
|
+
const size_type left_right = child_[left].right;
|
|
745
|
+
const size_type left_right_right = child_[left_right].right;
|
|
746
|
+
const size_type left_right_left = child_[left_right].left;
|
|
747
|
+
const size_type parent = get_parent(node);
|
|
748
|
+
|
|
749
|
+
set_parent(left_right, parent);
|
|
750
|
+
set_parent(left, left_right);
|
|
751
|
+
set_parent(node, left_right);
|
|
752
|
+
set_parent(left_right_right, node);
|
|
753
|
+
set_parent(left_right_left, left);
|
|
754
|
+
child_[node].left = left_right_right;
|
|
755
|
+
child_[left].right = left_right_left;
|
|
756
|
+
child_[left_right].left = left;
|
|
757
|
+
child_[left_right].right = node;
|
|
758
|
+
|
|
759
|
+
if (node == root_) {
|
|
760
|
+
root_ = left_right;
|
|
761
|
+
}
|
|
762
|
+
else if (child_[parent].left == node) {
|
|
763
|
+
child_[parent].left = left_right;
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
child_[parent].right = left_right;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (balance_[left_right] == 0) {
|
|
770
|
+
balance_[node] = 0;
|
|
771
|
+
balance_[left] = 0;
|
|
772
|
+
}
|
|
773
|
+
else if (balance_[left_right] == -1) {
|
|
774
|
+
balance_[node] = 0;
|
|
775
|
+
balance_[left] = 1;
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
balance_[node] = -1;
|
|
779
|
+
balance_[left] = 0;
|
|
780
|
+
}
|
|
781
|
+
balance_[left_right] = 0;
|
|
782
|
+
|
|
783
|
+
return left_right;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
size_type rotate_right_left(size_type node)
|
|
788
|
+
{
|
|
789
|
+
const size_type right = child_[node].right;
|
|
790
|
+
const size_type right_left = child_[right].left;
|
|
791
|
+
const size_type right_left_left = child_[right_left].left;
|
|
792
|
+
const size_type right_left_right = child_[right_left].right;
|
|
793
|
+
const size_type parent = get_parent(node);
|
|
794
|
+
|
|
795
|
+
set_parent(right_left, parent);
|
|
796
|
+
set_parent(right, right_left);
|
|
797
|
+
set_parent(node, right_left);
|
|
798
|
+
set_parent(right_left_left, node);
|
|
799
|
+
set_parent(right_left_right, right);
|
|
800
|
+
child_[node].right = right_left_left;
|
|
801
|
+
child_[right].left = right_left_right;
|
|
802
|
+
child_[right_left].right = right;
|
|
803
|
+
child_[right_left].left = node;
|
|
804
|
+
|
|
805
|
+
if (node == root_) {
|
|
806
|
+
root_ = right_left;
|
|
807
|
+
}
|
|
808
|
+
else if (child_[parent].right == node) {
|
|
809
|
+
child_[parent].right = right_left;
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
child_[parent].left = right_left;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (balance_[right_left] == 0) {
|
|
816
|
+
balance_[node] = 0;
|
|
817
|
+
balance_[right] = 0;
|
|
818
|
+
}
|
|
819
|
+
else if (balance_[right_left] == 1) {
|
|
820
|
+
balance_[node] = 0;
|
|
821
|
+
balance_[right] = -1;
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
balance_[node] = 1;
|
|
825
|
+
balance_[right] = 0;
|
|
826
|
+
}
|
|
827
|
+
balance_[right_left] = 0;
|
|
828
|
+
|
|
829
|
+
return right_left;
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
#endif // _AVL_ARRAY_H_
|