data-structure-typed 2.4.0 → 2.4.2
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.
- package/CHANGELOG.md +1 -1
- package/README.md +2 -3
- package/README_CN.md +0 -1
- package/dist/cjs/index.cjs +85 -30
- package/dist/cjs-legacy/index.cjs +85 -30
- package/dist/esm/index.mjs +85 -30
- package/dist/esm-legacy/index.mjs +85 -30
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +17 -6
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +13 -5
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +12 -5
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +15 -4
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +6 -1
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +6 -1
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +6 -1
- package/dist/umd/data-structure-typed.js +85 -29
- package/dist/umd/data-structure-typed.min.js +4 -4
- package/package.json +11 -5
- package/src/data-structures/binary-tree/tree-map.ts +35 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +41 -20
- package/src/data-structures/binary-tree/tree-multi-set.ts +17 -6
- package/src/data-structures/binary-tree/tree-set.ts +19 -6
- package/src/data-structures/trie/trie.ts +6 -8
- package/src/types/data-structures/binary-tree/tree-map.ts +7 -1
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +7 -1
- package/src/types/data-structures/binary-tree/tree-set.ts +7 -1
- package/CMakeLists.txt +0 -52
- package/benchmark/report.html +0 -143
- package/benchmark/report.json +0 -1972
- package/build/CMakeCache.txt +0 -603
- package/build/CMakeFiles/4.0.3/CMakeCXXCompiler.cmake +0 -104
- package/build/CMakeFiles/4.0.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/build/CMakeFiles/4.0.3/CMakeSystem.cmake +0 -15
- package/build/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -920
- package/build/CMakeFiles/4.0.3/CompilerIdCXX/a.out +0 -0
- package/build/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +0 -1
- package/build/CMakeFiles/CMakeConfigureLog.yaml +0 -2146
- package/build/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- package/build/CMakeFiles/InstallScripts.json +0 -9
- package/build/CMakeFiles/Makefile.cmake +0 -100
- package/build/CMakeFiles/Makefile2 +0 -720
- package/build/CMakeFiles/TargetDirectories.txt +0 -23
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp.o +0 -0
- package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp.o.d +0 -835
- package/build/CMakeFiles/avl-tree-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/avl-tree-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/avl-tree-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/avl-tree-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/avl-tree-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/avl-tree-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/avl-tree-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/avl-tree-benchmark.dir/test/performance/data-structures/binary-tree/avl-tree.test.cpp.o +0 -0
- package/build/CMakeFiles/avl-tree-benchmark.dir/test/performance/data-structures/binary-tree/avl-tree.test.cpp.o.d +0 -835
- package/build/CMakeFiles/cmake.check_cache +0 -1
- package/build/CMakeFiles/deque-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/deque-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/deque-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.internal +0 -791
- package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.make +0 -2362
- package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/deque-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/deque-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/deque-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/deque-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/deque-benchmark.dir/test/performance/data-structures/queue/deque.test.cpp.o +0 -0
- package/build/CMakeFiles/deque-benchmark.dir/test/performance/data-structures/queue/deque.test.cpp.o.d +0 -787
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.internal +0 -790
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.make +0 -2359
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp.o +0 -0
- package/build/CMakeFiles/doubly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp.o.d +0 -786
- package/build/CMakeFiles/hash-map-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/hash-map-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/hash-map-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.internal +0 -790
- package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.make +0 -2359
- package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/hash-map-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/hash-map-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/hash-map-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/hash-map-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/hash-map-benchmark.dir/test/performance/data-structures/hash/hash-map.test.cpp.o +0 -0
- package/build/CMakeFiles/hash-map-benchmark.dir/test/performance/data-structures/hash/hash-map.test.cpp.o.d +0 -786
- package/build/CMakeFiles/heap-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/heap-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/heap-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.internal +0 -843
- package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.make +0 -2518
- package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/heap-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/heap-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/heap-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/heap-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/heap-benchmark.dir/test/performance/data-structures/heap/heap.test.cpp.o +0 -0
- package/build/CMakeFiles/heap-benchmark.dir/test/performance/data-structures/heap/heap.test.cpp.o.d +0 -839
- package/build/CMakeFiles/priority-queue-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/priority-queue-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/priority-queue-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.internal +0 -793
- package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.make +0 -2368
- package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/priority-queue-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/priority-queue-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/priority-queue-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/priority-queue-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/priority-queue-benchmark.dir/test/performance/data-structures/priority-queue/priority-queue.test.cpp.o +0 -0
- package/build/CMakeFiles/priority-queue-benchmark.dir/test/performance/data-structures/priority-queue/priority-queue.test.cpp.o.d +0 -789
- package/build/CMakeFiles/progress.marks +0 -1
- package/build/CMakeFiles/queue-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/queue-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/queue-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.internal +0 -793
- package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.make +0 -2368
- package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/queue-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/queue-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/queue-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/queue-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/queue-benchmark.dir/test/performance/data-structures/queue/queue.test.cpp.o +0 -0
- package/build/CMakeFiles/queue-benchmark.dir/test/performance/data-structures/queue/queue.test.cpp.o.d +0 -789
- package/build/CMakeFiles/red-black-tree-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/red-black-tree-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/red-black-tree-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/red-black-tree-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/red-black-tree-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/red-black-tree-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/red-black-tree-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/red-black-tree-benchmark.dir/test/performance/data-structures/binary-tree/red-black-tree.test.cpp.o +0 -0
- package/build/CMakeFiles/red-black-tree-benchmark.dir/test/performance/data-structures/binary-tree/red-black-tree.test.cpp.o.d +0 -835
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.internal +0 -790
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.make +0 -2359
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/singly-linked-list.test.cpp.o +0 -0
- package/build/CMakeFiles/singly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/singly-linked-list.test.cpp.o.d +0 -786
- package/build/CMakeFiles/stack-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/stack-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/stack-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.internal +0 -793
- package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.make +0 -2368
- package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/stack-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/stack-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/stack-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/stack-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/stack-benchmark.dir/test/performance/data-structures/stack/stack.test.cpp.o +0 -0
- package/build/CMakeFiles/stack-benchmark.dir/test/performance/data-structures/stack/stack.test.cpp.o.d +0 -789
- package/build/CMakeFiles/tree-map-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/tree-map-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/tree-map-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/tree-map-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/tree-map-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/tree-map-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/tree-map-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/tree-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-map.test.cpp.o +0 -0
- package/build/CMakeFiles/tree-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-map.test.cpp.o.d +0 -835
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp.o +0 -0
- package/build/CMakeFiles/tree-multi-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp.o.d +0 -835
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp.o +0 -0
- package/build/CMakeFiles/tree-multi-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp.o.d +0 -835
- package/build/CMakeFiles/tree-set-benchmark.dir/DependInfo.cmake +0 -23
- package/build/CMakeFiles/tree-set-benchmark.dir/build.make +0 -114
- package/build/CMakeFiles/tree-set-benchmark.dir/cmake_clean.cmake +0 -11
- package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.internal +0 -839
- package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.make +0 -2506
- package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.ts +0 -2
- package/build/CMakeFiles/tree-set-benchmark.dir/depend.make +0 -2
- package/build/CMakeFiles/tree-set-benchmark.dir/flags.make +0 -10
- package/build/CMakeFiles/tree-set-benchmark.dir/link.txt +0 -1
- package/build/CMakeFiles/tree-set-benchmark.dir/progress.make +0 -3
- package/build/CMakeFiles/tree-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-set.test.cpp.o +0 -0
- package/build/CMakeFiles/tree-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-set.test.cpp.o.d +0 -835
- package/build/Makefile +0 -783
- package/build/_deps/benchmark-build/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- package/build/_deps/benchmark-build/CMakeFiles/progress.marks +0 -1
- package/build/_deps/benchmark-build/Makefile +0 -140
- package/build/_deps/benchmark-build/benchmark.pc +0 -12
- package/build/_deps/benchmark-build/benchmarkConfig.cmake +0 -14
- package/build/_deps/benchmark-build/benchmarkConfigVersion.cmake +0 -65
- package/build/_deps/benchmark-build/benchmarkTargets.cmake +0 -84
- package/build/_deps/benchmark-build/cmake_install.cmake +0 -50
- package/build/_deps/benchmark-build/src/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/DependInfo.cmake +0 -41
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark.cc.o.d +0 -875
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_api_internal.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_api_internal.cc.o.d +0 -802
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_name.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_name.cc.o.d +0 -772
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o.d +0 -841
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_runner.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_runner.cc.o.d +0 -833
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/build.make +0 -402
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/check.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/check.cc.o.d +0 -784
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/cmake_clean.cmake +0 -47
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/cmake_clean_target.cmake +0 -3
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/colorprint.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/colorprint.cc.o.d +0 -791
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/commandlineflags.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/commandlineflags.cc.o.d +0 -795
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.internal +0 -15519
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.make +0 -17500
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.ts +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/complexity.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/complexity.cc.o.d +0 -793
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/console_reporter.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/console_reporter.cc.o.d +0 -802
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/counter.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/counter.cc.o.d +0 -773
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/csv_reporter.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/csv_reporter.cc.o.d +0 -799
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/depend.make +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/flags.make +0 -10
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/json_reporter.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/json_reporter.cc.o.d +0 -800
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/link.txt +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/perf_counters.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/perf_counters.cc.o.d +0 -807
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/progress.make +0 -21
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/reporter.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/reporter.cc.o.d +0 -798
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/statistics.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/statistics.cc.o.d +0 -800
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/string_util.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/string_util.cc.o.d +0 -795
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/sysinfo.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/sysinfo.cc.o.d +0 -933
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/timers.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/timers.cc.o.d +0 -904
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/DependInfo.cmake +0 -23
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o +0 -0
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o.d +0 -772
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/build.make +0 -114
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/cmake_clean.cmake +0 -11
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/cmake_clean_target.cmake +0 -3
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.internal +0 -776
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.make +0 -2317
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.ts +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/depend.make +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/flags.make +0 -10
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/link.txt +0 -2
- package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/progress.make +0 -3
- package/build/_deps/benchmark-build/src/CMakeFiles/progress.marks +0 -1
- package/build/_deps/benchmark-build/src/Makefile +0 -710
- package/build/_deps/benchmark-build/src/cmake_install.cmake +0 -45
- package/build/_deps/benchmark-build/src/libbenchmark.a +0 -0
- package/build/_deps/benchmark-build/src/libbenchmark_main.a +0 -0
- package/build/_deps/benchmark-src/.clang-format +0 -5
- package/build/_deps/benchmark-src/.clang-tidy +0 -7
- package/build/_deps/benchmark-src/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
- package/build/_deps/benchmark-src/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/build/_deps/benchmark-src/.github/install_bazel.sh +0 -13
- package/build/_deps/benchmark-src/.github/libcxx-setup.sh +0 -26
- package/build/_deps/benchmark-src/.github/workflows/bazel.yml +0 -35
- package/build/_deps/benchmark-src/.github/workflows/build-and-test-min-cmake.yml +0 -46
- package/build/_deps/benchmark-src/.github/workflows/build-and-test-perfcounters.yml +0 -51
- package/build/_deps/benchmark-src/.github/workflows/build-and-test.yml +0 -114
- package/build/_deps/benchmark-src/.github/workflows/clang-format-lint.yml +0 -17
- package/build/_deps/benchmark-src/.github/workflows/clang-tidy.yml +0 -38
- package/build/_deps/benchmark-src/.github/workflows/doxygen.yml +0 -28
- package/build/_deps/benchmark-src/.github/workflows/pylint.yml +0 -28
- package/build/_deps/benchmark-src/.github/workflows/sanitizer.yml +0 -96
- package/build/_deps/benchmark-src/.github/workflows/test_bindings.yml +0 -29
- package/build/_deps/benchmark-src/.github/workflows/wheels.yml +0 -79
- package/build/_deps/benchmark-src/.travis.yml +0 -208
- package/build/_deps/benchmark-src/.ycm_extra_conf.py +0 -115
- package/build/_deps/benchmark-src/AUTHORS +0 -71
- package/build/_deps/benchmark-src/BUILD.bazel +0 -87
- package/build/_deps/benchmark-src/CMakeLists.txt +0 -340
- package/build/_deps/benchmark-src/CONTRIBUTING.md +0 -58
- package/build/_deps/benchmark-src/CONTRIBUTORS +0 -95
- package/build/_deps/benchmark-src/LICENSE +0 -202
- package/build/_deps/benchmark-src/MODULE.bazel +0 -24
- package/build/_deps/benchmark-src/README.md +0 -223
- package/build/_deps/benchmark-src/WORKSPACE +0 -22
- package/build/_deps/benchmark-src/WORKSPACE.bzlmod +0 -2
- package/build/_deps/benchmark-src/_config.yml +0 -2
- package/build/_deps/benchmark-src/appveyor.yml +0 -50
- package/build/_deps/benchmark-src/bazel/benchmark_deps.bzl +0 -65
- package/build/_deps/benchmark-src/bindings/python/BUILD +0 -3
- package/build/_deps/benchmark-src/bindings/python/build_defs.bzl +0 -25
- package/build/_deps/benchmark-src/bindings/python/google_benchmark/BUILD +0 -40
- package/build/_deps/benchmark-src/bindings/python/google_benchmark/__init__.py +0 -162
- package/build/_deps/benchmark-src/bindings/python/google_benchmark/benchmark.cc +0 -184
- package/build/_deps/benchmark-src/bindings/python/google_benchmark/example.py +0 -136
- package/build/_deps/benchmark-src/bindings/python/nanobind.BUILD +0 -17
- package/build/_deps/benchmark-src/bindings/python/python_headers.BUILD +0 -6
- package/build/_deps/benchmark-src/cmake/AddCXXCompilerFlag.cmake +0 -78
- package/build/_deps/benchmark-src/cmake/CXXFeatureCheck.cmake +0 -82
- package/build/_deps/benchmark-src/cmake/Config.cmake.in +0 -7
- package/build/_deps/benchmark-src/cmake/GetGitVersion.cmake +0 -58
- package/build/_deps/benchmark-src/cmake/GoogleTest.cmake +0 -58
- package/build/_deps/benchmark-src/cmake/GoogleTest.cmake.in +0 -59
- package/build/_deps/benchmark-src/cmake/benchmark.pc.in +0 -12
- package/build/_deps/benchmark-src/cmake/gnu_posix_regex.cpp +0 -12
- package/build/_deps/benchmark-src/cmake/llvm-toolchain.cmake +0 -8
- package/build/_deps/benchmark-src/cmake/posix_regex.cpp +0 -14
- package/build/_deps/benchmark-src/cmake/pthread_affinity.cpp +0 -16
- package/build/_deps/benchmark-src/cmake/split_list.cmake +0 -3
- package/build/_deps/benchmark-src/cmake/std_regex.cpp +0 -10
- package/build/_deps/benchmark-src/cmake/steady_clock.cpp +0 -7
- package/build/_deps/benchmark-src/cmake/thread_safety_attributes.cpp +0 -4
- package/build/_deps/benchmark-src/docs/AssemblyTests.md +0 -149
- package/build/_deps/benchmark-src/docs/_config.yml +0 -3
- package/build/_deps/benchmark-src/docs/assets/images/icon.png +0 -0
- package/build/_deps/benchmark-src/docs/assets/images/icon.xcf +0 -0
- package/build/_deps/benchmark-src/docs/assets/images/icon_black.png +0 -0
- package/build/_deps/benchmark-src/docs/assets/images/icon_black.xcf +0 -0
- package/build/_deps/benchmark-src/docs/dependencies.md +0 -13
- package/build/_deps/benchmark-src/docs/index.md +0 -12
- package/build/_deps/benchmark-src/docs/perf_counters.md +0 -35
- package/build/_deps/benchmark-src/docs/platform_specific_build_instructions.md +0 -48
- package/build/_deps/benchmark-src/docs/python_bindings.md +0 -34
- package/build/_deps/benchmark-src/docs/random_interleaving.md +0 -13
- package/build/_deps/benchmark-src/docs/reducing_variance.md +0 -100
- package/build/_deps/benchmark-src/docs/releasing.md +0 -41
- package/build/_deps/benchmark-src/docs/tools.md +0 -343
- package/build/_deps/benchmark-src/docs/user_guide.md +0 -1266
- package/build/_deps/benchmark-src/include/benchmark/benchmark.h +0 -1991
- package/build/_deps/benchmark-src/include/benchmark/export.h +0 -47
- package/build/_deps/benchmark-src/pyproject.toml +0 -50
- package/build/_deps/benchmark-src/setup.py +0 -113
- package/build/_deps/benchmark-src/src/CMakeLists.txt +0 -170
- package/build/_deps/benchmark-src/src/arraysize.h +0 -33
- package/build/_deps/benchmark-src/src/benchmark.cc +0 -779
- package/build/_deps/benchmark-src/src/benchmark_api_internal.cc +0 -118
- package/build/_deps/benchmark-src/src/benchmark_api_internal.h +0 -87
- package/build/_deps/benchmark-src/src/benchmark_main.cc +0 -18
- package/build/_deps/benchmark-src/src/benchmark_name.cc +0 -59
- package/build/_deps/benchmark-src/src/benchmark_register.cc +0 -520
- package/build/_deps/benchmark-src/src/benchmark_register.h +0 -109
- package/build/_deps/benchmark-src/src/benchmark_runner.cc +0 -497
- package/build/_deps/benchmark-src/src/benchmark_runner.h +0 -131
- package/build/_deps/benchmark-src/src/check.cc +0 -11
- package/build/_deps/benchmark-src/src/check.h +0 -106
- package/build/_deps/benchmark-src/src/colorprint.cc +0 -200
- package/build/_deps/benchmark-src/src/colorprint.h +0 -33
- package/build/_deps/benchmark-src/src/commandlineflags.cc +0 -298
- package/build/_deps/benchmark-src/src/commandlineflags.h +0 -133
- package/build/_deps/benchmark-src/src/complexity.cc +0 -244
- package/build/_deps/benchmark-src/src/complexity.h +0 -55
- package/build/_deps/benchmark-src/src/console_reporter.cc +0 -206
- package/build/_deps/benchmark-src/src/counter.cc +0 -80
- package/build/_deps/benchmark-src/src/counter.h +0 -32
- package/build/_deps/benchmark-src/src/csv_reporter.cc +0 -161
- package/build/_deps/benchmark-src/src/cycleclock.h +0 -230
- package/build/_deps/benchmark-src/src/internal_macros.h +0 -115
- package/build/_deps/benchmark-src/src/json_reporter.cc +0 -320
- package/build/_deps/benchmark-src/src/log.h +0 -88
- package/build/_deps/benchmark-src/src/mutex.h +0 -155
- package/build/_deps/benchmark-src/src/perf_counters.cc +0 -282
- package/build/_deps/benchmark-src/src/perf_counters.h +0 -200
- package/build/_deps/benchmark-src/src/re.h +0 -158
- package/build/_deps/benchmark-src/src/reporter.cc +0 -118
- package/build/_deps/benchmark-src/src/statistics.cc +0 -209
- package/build/_deps/benchmark-src/src/statistics.h +0 -44
- package/build/_deps/benchmark-src/src/string_util.cc +0 -254
- package/build/_deps/benchmark-src/src/string_util.h +0 -70
- package/build/_deps/benchmark-src/src/sysinfo.cc +0 -855
- package/build/_deps/benchmark-src/src/thread_manager.h +0 -63
- package/build/_deps/benchmark-src/src/thread_timer.h +0 -86
- package/build/_deps/benchmark-src/src/timers.cc +0 -272
- package/build/_deps/benchmark-src/src/timers.h +0 -48
- package/build/_deps/benchmark-src/test/AssemblyTests.cmake +0 -67
- package/build/_deps/benchmark-src/test/BUILD +0 -127
- package/build/_deps/benchmark-src/test/CMakeLists.txt +0 -309
- package/build/_deps/benchmark-src/test/args_product_test.cc +0 -77
- package/build/_deps/benchmark-src/test/basic_test.cc +0 -180
- package/build/_deps/benchmark-src/test/benchmark_gtest.cc +0 -169
- package/build/_deps/benchmark-src/test/benchmark_min_time_flag_iters_test.cc +0 -66
- package/build/_deps/benchmark-src/test/benchmark_min_time_flag_time_test.cc +0 -90
- package/build/_deps/benchmark-src/test/benchmark_name_gtest.cc +0 -82
- package/build/_deps/benchmark-src/test/benchmark_random_interleaving_gtest.cc +0 -126
- package/build/_deps/benchmark-src/test/benchmark_setup_teardown_test.cc +0 -157
- package/build/_deps/benchmark-src/test/benchmark_test.cc +0 -274
- package/build/_deps/benchmark-src/test/clobber_memory_assembly_test.cc +0 -64
- package/build/_deps/benchmark-src/test/commandlineflags_gtest.cc +0 -228
- package/build/_deps/benchmark-src/test/complexity_test.cc +0 -228
- package/build/_deps/benchmark-src/test/cxx03_test.cc +0 -62
- package/build/_deps/benchmark-src/test/diagnostics_test.cc +0 -91
- package/build/_deps/benchmark-src/test/display_aggregates_only_test.cc +0 -45
- package/build/_deps/benchmark-src/test/donotoptimize_assembly_test.cc +0 -201
- package/build/_deps/benchmark-src/test/donotoptimize_test.cc +0 -69
- package/build/_deps/benchmark-src/test/filter_test.cc +0 -117
- package/build/_deps/benchmark-src/test/fixture_test.cc +0 -51
- package/build/_deps/benchmark-src/test/internal_threading_test.cc +0 -185
- package/build/_deps/benchmark-src/test/link_main_test.cc +0 -9
- package/build/_deps/benchmark-src/test/map_test.cc +0 -59
- package/build/_deps/benchmark-src/test/memory_manager_test.cc +0 -47
- package/build/_deps/benchmark-src/test/min_time_parse_gtest.cc +0 -30
- package/build/_deps/benchmark-src/test/multiple_ranges_test.cc +0 -96
- package/build/_deps/benchmark-src/test/options_test.cc +0 -77
- package/build/_deps/benchmark-src/test/output_test.h +0 -211
- package/build/_deps/benchmark-src/test/output_test_helper.cc +0 -519
- package/build/_deps/benchmark-src/test/perf_counters_gtest.cc +0 -307
- package/build/_deps/benchmark-src/test/perf_counters_test.cc +0 -92
- package/build/_deps/benchmark-src/test/register_benchmark_test.cc +0 -196
- package/build/_deps/benchmark-src/test/repetitions_test.cc +0 -214
- package/build/_deps/benchmark-src/test/report_aggregates_only_test.cc +0 -41
- package/build/_deps/benchmark-src/test/reporter_output_test.cc +0 -1130
- package/build/_deps/benchmark-src/test/skip_with_error_test.cc +0 -199
- package/build/_deps/benchmark-src/test/spec_arg_test.cc +0 -105
- package/build/_deps/benchmark-src/test/spec_arg_verbosity_test.cc +0 -43
- package/build/_deps/benchmark-src/test/state_assembly_test.cc +0 -68
- package/build/_deps/benchmark-src/test/statistics_gtest.cc +0 -35
- package/build/_deps/benchmark-src/test/string_util_gtest.cc +0 -199
- package/build/_deps/benchmark-src/test/templated_fixture_test.cc +0 -28
- package/build/_deps/benchmark-src/test/time_unit_gtest.cc +0 -37
- package/build/_deps/benchmark-src/test/user_counters_tabular_test.cc +0 -558
- package/build/_deps/benchmark-src/test/user_counters_test.cc +0 -561
- package/build/_deps/benchmark-src/test/user_counters_thousands_test.cc +0 -186
- package/build/_deps/benchmark-src/tools/BUILD.bazel +0 -19
- package/build/_deps/benchmark-src/tools/compare.py +0 -432
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test1_run1.json +0 -127
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test1_run2.json +0 -127
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test2_run.json +0 -81
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test3_run0.json +0 -65
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test3_run1.json +0 -65
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run.json +0 -96
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run0.json +0 -21
- package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run1.json +0 -21
- package/build/_deps/benchmark-src/tools/gbench/__init__.py +0 -8
- package/build/_deps/benchmark-src/tools/gbench/report.py +0 -1201
- package/build/_deps/benchmark-src/tools/gbench/util.py +0 -203
- package/build/_deps/benchmark-src/tools/libpfm.BUILD.bazel +0 -22
- package/build/_deps/benchmark-src/tools/requirements.txt +0 -2
- package/build/_deps/benchmark-src/tools/strip_asm.py +0 -151
- package/build/_deps/benchmark-subbuild/CMakeCache.txt +0 -133
- package/build/_deps/benchmark-subbuild/CMakeFiles/4.0.3/CMakeSystem.cmake +0 -15
- package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeConfigureLog.yaml +0 -11
- package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeRuleHashes.txt +0 -11
- package/build/_deps/benchmark-subbuild/CMakeFiles/InstallScripts.json +0 -7
- package/build/_deps/benchmark-subbuild/CMakeFiles/Makefile.cmake +0 -52
- package/build/_deps/benchmark-subbuild/CMakeFiles/Makefile2 +0 -122
- package/build/_deps/benchmark-subbuild/CMakeFiles/TargetDirectories.txt +0 -3
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate-complete +0 -0
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/DependInfo.cmake +0 -22
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/Labels.json +0 -46
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/Labels.txt +0 -14
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/build.make +0 -162
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/cmake_clean.cmake +0 -17
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/compiler_depend.make +0 -2
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/compiler_depend.ts +0 -2
- package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/progress.make +0 -10
- package/build/_deps/benchmark-subbuild/CMakeFiles/cmake.check_cache +0 -1
- package/build/_deps/benchmark-subbuild/CMakeFiles/progress.marks +0 -1
- package/build/_deps/benchmark-subbuild/CMakeLists.txt +0 -42
- package/build/_deps/benchmark-subbuild/Makefile +0 -162
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-build +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-configure +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-done +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-download +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-gitclone-lastrun.txt +0 -15
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-gitinfo.txt +0 -15
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-install +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-mkdir +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-patch +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-patch-info.txt +0 -6
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-test +0 -0
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-update-info.txt +0 -7
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-cfgcmd.txt +0 -1
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-gitclone.cmake +0 -87
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-gitupdate.cmake +0 -317
- package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-mkdirs.cmake +0 -27
- package/build/_deps/benchmark-subbuild/cmake_install.cmake +0 -56
- package/build/bin/avl-rb-range-search-benchmark +0 -0
- package/build/bin/avl-tree-benchmark +0 -0
- package/build/bin/deque-benchmark +0 -0
- package/build/bin/doubly-linked-list-benchmark +0 -0
- package/build/bin/hash-map-benchmark +0 -0
- package/build/bin/heap-benchmark +0 -0
- package/build/bin/priority-queue-benchmark +0 -0
- package/build/bin/queue-benchmark +0 -0
- package/build/bin/red-black-tree-benchmark +0 -0
- package/build/bin/singly-linked-list-benchmark +0 -0
- package/build/bin/stack-benchmark +0 -0
- package/build/bin/tree-map-benchmark +0 -0
- package/build/bin/tree-multi-map-benchmark +0 -0
- package/build/bin/tree-multi-set-benchmark +0 -0
- package/build/bin/tree-set-benchmark +0 -0
- package/build/cmake_install.cmake +0 -66
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs-legacy/index.cjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm-legacy/index.mjs.map +0 -1
- package/dist/umd/data-structure-typed.js.map +0 -1
- package/dist/umd/data-structure-typed.min.js.map +0 -1
- package/eslint.config.mjs +0 -73
- package/test/config.ts +0 -4
- package/test/integration/all-in-one.test.ts +0 -110
- package/test/integration/avl-tree.test.ts +0 -127
- package/test/integration/bst.test.ts +0 -385
- package/test/integration/compile.test.mjs +0 -159
- package/test/integration/compile.test.ts +0 -176
- package/test/integration/heap.test.js +0 -21
- package/test/integration/index.html +0 -462
- package/test/performance/benchmark-runner-enhanced.mjs +0 -818
- package/test/performance/cmake-benchmark-runner.mjs +0 -234
- package/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp +0 -112
- package/test/performance/data-structures/binary-tree/avl-rb-range-search.test.mjs +0 -51
- package/test/performance/data-structures/binary-tree/avl-tree.test.cpp +0 -181
- package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +0 -138
- package/test/performance/data-structures/binary-tree/binary-tree-overall.test.mjs +0 -85
- package/test/performance/data-structures/binary-tree/binary-tree.test.mjs +0 -100
- package/test/performance/data-structures/binary-tree/bst.test.mjs +0 -61
- package/test/performance/data-structures/binary-tree/red-black-tree-cjs.test.mjs +0 -259
- package/test/performance/data-structures/binary-tree/red-black-tree.test.cpp +0 -213
- package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +0 -275
- package/test/performance/data-structures/binary-tree/tree-map.test.cpp +0 -129
- package/test/performance/data-structures/binary-tree/tree-map.test.mjs +0 -171
- package/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp +0 -205
- package/test/performance/data-structures/binary-tree/tree-multi-map.test.mjs +0 -106
- package/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp +0 -217
- package/test/performance/data-structures/binary-tree/tree-multi-set.test.mjs +0 -91
- package/test/performance/data-structures/binary-tree/tree-set.test.cpp +0 -127
- package/test/performance/data-structures/binary-tree/tree-set.test.mjs +0 -174
- package/test/performance/data-structures/comparison/comparison.test.mjs +0 -99
- package/test/performance/data-structures/graph/directed-graph.test.mjs +0 -38
- package/test/performance/data-structures/hash/hash-map.test.cpp +0 -183
- package/test/performance/data-structures/hash/hash-map.test.mjs +0 -187
- package/test/performance/data-structures/heap/heap.test.cpp +0 -61
- package/test/performance/data-structures/heap/heap.test.mjs +0 -31
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp +0 -84
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.mjs +0 -125
- package/test/performance/data-structures/linked-list/singly-linked-list.test.cpp +0 -77
- package/test/performance/data-structures/linked-list/singly-linked-list.test.mjs +0 -84
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.mjs +0 -40
- package/test/performance/data-structures/priority-queue/priority-queue.test.cpp +0 -59
- package/test/performance/data-structures/priority-queue/priority-queue.test.mjs +0 -64
- package/test/performance/data-structures/queue/deque.test.cpp +0 -119
- package/test/performance/data-structures/queue/deque.test.mjs +0 -144
- package/test/performance/data-structures/queue/queue.test.cpp +0 -59
- package/test/performance/data-structures/queue/queue.test.mjs +0 -77
- package/test/performance/data-structures/stack/stack.test.cpp +0 -40
- package/test/performance/data-structures/stack/stack.test.mjs +0 -69
- package/test/performance/data-structures/trie/trie.test.mjs +0 -43
- package/test/performance/reportor-enhanced.mjs +0 -871
- package/test/performance/runner-config.json +0 -51
- package/test/types/index.ts +0 -1
- package/test/types/utils/big-o.ts +0 -1
- package/test/types/utils/index.ts +0 -2
- package/test/types/utils/json2html.ts +0 -5
- package/test/unit/data-structures/base/iterable-element-base.coverage.test.ts +0 -106
- package/test/unit/data-structures/base/iterable-element-base.more-branches.coverage.test.ts +0 -61
- package/test/unit/data-structures/base/linear-base.array.coverage.test.ts +0 -168
- package/test/unit/data-structures/base/linear-base.concat-else.coverage.test.ts +0 -82
- package/test/unit/data-structures/base/linear-base.coverage.test.ts +0 -72
- package/test/unit/data-structures/base/linear-base.more-branches.coverage.test.ts +0 -414
- package/test/unit/data-structures/binary-tree/avl-tree-node.familyPosition-root-left.coverage.test.ts +0 -17
- package/test/unit/data-structures/binary-tree/avl-tree.more-branches-2.coverage.test.ts +0 -99
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -729
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +0 -345
- package/test/unit/data-structures/binary-tree/binary-indexed-tree.more-branches.coverage.test.ts +0 -18
- package/test/unit/data-structures/binary-tree/binary-tree.more-branches.coverage.test.ts +0 -56
- package/test/unit/data-structures/binary-tree/binary-tree.remaining-branches.coverage.test.ts +0 -232
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -1912
- package/test/unit/data-structures/binary-tree/bst.bound-by-predicate.coverage.test.ts +0 -33
- package/test/unit/data-structures/binary-tree/bst.coverage.test.ts +0 -94
- package/test/unit/data-structures/binary-tree/bst.deletebykey.coverage.test.ts +0 -70
- package/test/unit/data-structures/binary-tree/bst.deletewhere.coverage.test.ts +0 -37
- package/test/unit/data-structures/binary-tree/bst.floor-lower-predicate.coverage.test.ts +0 -29
- package/test/unit/data-structures/binary-tree/bst.floor-setmany.coverage.test.ts +0 -72
- package/test/unit/data-structures/binary-tree/bst.getnode.range-ensure.coverage.test.ts +0 -22
- package/test/unit/data-structures/binary-tree/bst.misc-branches.coverage.test.ts +0 -100
- package/test/unit/data-structures/binary-tree/bst.more-branches-2.coverage.test.ts +0 -133
- package/test/unit/data-structures/binary-tree/bst.more-branches-3.coverage.test.ts +0 -45
- package/test/unit/data-structures/binary-tree/bst.more-branches-4.coverage.test.ts +0 -36
- package/test/unit/data-structures/binary-tree/bst.more-branches-5.coverage.test.ts +0 -40
- package/test/unit/data-structures/binary-tree/bst.more.coverage.test.ts +0 -39
- package/test/unit/data-structures/binary-tree/bst.node-family.coverage.test.ts +0 -29
- package/test/unit/data-structures/binary-tree/bst.range-pruning.coverage.test.ts +0 -43
- package/test/unit/data-structures/binary-tree/bst.search-fastpath.coverage.test.ts +0 -30
- package/test/unit/data-structures/binary-tree/bst.test.ts +0 -3472
- package/test/unit/data-structures/binary-tree/data/cost-of-living-by-country.ts +0 -259
- package/test/unit/data-structures/binary-tree/overall.test.ts +0 -219
- package/test/unit/data-structures/binary-tree/red-black-tree.boundary-corruption-repair.coverage.test.ts +0 -66
- package/test/unit/data-structures/binary-tree/red-black-tree.boundary-max-update.coverage.test.ts +0 -18
- package/test/unit/data-structures/binary-tree/red-black-tree.boundary-null.coverage.test.ts +0 -53
- package/test/unit/data-structures/binary-tree/red-black-tree.boundary-stale-cache.coverage.test.ts +0 -25
- package/test/unit/data-structures/binary-tree/red-black-tree.boundary-update.coverage.test.ts +0 -23
- package/test/unit/data-structures/binary-tree/red-black-tree.cache-delete.coverage.test.ts +0 -49
- package/test/unit/data-structures/binary-tree/red-black-tree.cache-edge.coverage.test.ts +0 -37
- package/test/unit/data-structures/binary-tree/red-black-tree.cache-stale-insert.coverage.test.ts +0 -39
- package/test/unit/data-structures/binary-tree/red-black-tree.coverage.test.ts +0 -334
- package/test/unit/data-structures/binary-tree/red-black-tree.delete-fixup.coverage.test.ts +0 -68
- package/test/unit/data-structures/binary-tree/red-black-tree.delete-successor.coverage.test.ts +0 -75
- package/test/unit/data-structures/binary-tree/red-black-tree.factories.coverage.test.ts +0 -26
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-cache-compare-update.coverage.test.ts +0 -74
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-cache-no-update.coverage.test.ts +0 -44
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-cache-nullish.coverage.test.ts +0 -61
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-mapmode-defined.coverage.test.ts +0 -35
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-mapmode-undefined.coverage.test.ts +0 -43
- package/test/unit/data-structures/binary-tree/red-black-tree.hint-more.coverage.test.ts +0 -99
- package/test/unit/data-structures/binary-tree/red-black-tree.hint.coverage.test.ts +0 -60
- package/test/unit/data-structures/binary-tree/red-black-tree.insert-cache-nullish.coverage.test.ts +0 -29
- package/test/unit/data-structures/binary-tree/red-black-tree.insert-header-parent-nullish.coverage.test.ts +0 -17
- package/test/unit/data-structures/binary-tree/red-black-tree.internal-walk.coverage.test.ts +0 -57
- package/test/unit/data-structures/binary-tree/red-black-tree.minmax-cache.test.ts +0 -65
- package/test/unit/data-structures/binary-tree/red-black-tree.misc-inputs.coverage.test.ts +0 -17
- package/test/unit/data-structures/binary-tree/red-black-tree.more-branches-2.coverage.test.ts +0 -121
- package/test/unit/data-structures/binary-tree/red-black-tree.more-branches-3.coverage.test.ts +0 -55
- package/test/unit/data-structures/binary-tree/red-black-tree.more-branches-4.coverage.test.ts +0 -44
- package/test/unit/data-structures/binary-tree/red-black-tree.predsucc.coverage.test.ts +0 -40
- package/test/unit/data-structures/binary-tree/red-black-tree.remaining-branches.coverage.test.ts +0 -123
- package/test/unit/data-structures/binary-tree/red-black-tree.set-inputs.coverage.test.ts +0 -64
- package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-parent-cache.coverage.test.ts +0 -79
- package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-remaining.coverage.test.ts +0 -44
- package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-uncovered.coverage.test.ts +0 -74
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +0 -936
- package/test/unit/data-structures/binary-tree/red-black-tree.update-branches.coverage.test.ts +0 -30
- package/test/unit/data-structures/binary-tree/segment-tree.more-branches.coverage.test.ts +0 -31
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +0 -104
- package/test/unit/data-structures/binary-tree/tree-map.test.ts +0 -270
- package/test/unit/data-structures/binary-tree/tree-multi-map.coverage.test.ts +0 -245
- package/test/unit/data-structures/binary-tree/tree-multi-map.legacy.test.ts.skip +0 -1115
- package/test/unit/data-structures/binary-tree/tree-multi-map.more-branches-2.coverage.test.ts.skip +0 -59
- package/test/unit/data-structures/binary-tree/tree-multi-map.rfc.test.ts +0 -99
- package/test/unit/data-structures/binary-tree/tree-multi-map.simplified.test.ts +0 -482
- package/test/unit/data-structures/binary-tree/tree-multi-set.test.ts +0 -545
- package/test/unit/data-structures/binary-tree/tree-set.test.ts +0 -187
- package/test/unit/data-structures/graph/abstract-graph.more-branches-2.coverage.test.ts +0 -40
- package/test/unit/data-structures/graph/abstract-graph.more-branches-3.coverage.test.ts +0 -65
- package/test/unit/data-structures/graph/abstract-graph.more-branches-4.coverage.test.ts +0 -98
- package/test/unit/data-structures/graph/abstract-graph.more-branches-5.coverage.test.ts +0 -51
- package/test/unit/data-structures/graph/abstract-graph.more-branches.coverage.test.ts +0 -62
- package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -117
- package/test/unit/data-structures/graph/directed-graph.more-branches-2.coverage.test.ts +0 -38
- package/test/unit/data-structures/graph/directed-graph.more-branches-3.coverage.test.ts +0 -25
- package/test/unit/data-structures/graph/directed-graph.more-branches.coverage.test.ts +0 -82
- package/test/unit/data-structures/graph/directed-graph.test.ts +0 -1185
- package/test/unit/data-structures/graph/map-graph.more-branches.coverage.test.ts +0 -22
- package/test/unit/data-structures/graph/map-graph.test.ts +0 -148
- package/test/unit/data-structures/graph/overall.test.ts +0 -49
- package/test/unit/data-structures/graph/salty-edges.json +0 -875
- package/test/unit/data-structures/graph/salty-vertexes.json +0 -200
- package/test/unit/data-structures/graph/undirected-graph.more-branches-2.coverage.test.ts +0 -35
- package/test/unit/data-structures/graph/undirected-graph.more-branches.coverage.test.ts +0 -87
- package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -782
- package/test/unit/data-structures/hash/hash-map.more-branches.coverage.test.ts +0 -64
- package/test/unit/data-structures/hash/hash-map.test.ts +0 -1125
- package/test/unit/data-structures/hash/hash-map.toEntryFn-branch.coverage.test.ts +0 -9
- package/test/unit/data-structures/heap/heap.misc-branches.coverage.test.ts +0 -110
- package/test/unit/data-structures/heap/heap.remaining-branches.coverage.test.ts +0 -22
- package/test/unit/data-structures/heap/heap.test.ts +0 -760
- package/test/unit/data-structures/heap/max-heap.coverage.test.ts +0 -29
- package/test/unit/data-structures/heap/max-heap.test.ts +0 -98
- package/test/unit/data-structures/heap/min-heap.test.ts +0 -117
- package/test/unit/data-structures/linked-list/doubly-linked-list.more-branches.coverage.test.ts +0 -72
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +0 -1150
- package/test/unit/data-structures/linked-list/linked-list.test.ts +0 -8
- package/test/unit/data-structures/linked-list/linked-list.unshiftMany-else.coverage.test.ts +0 -15
- package/test/unit/data-structures/linked-list/singly-linked-list.coverage.test.ts +0 -221
- package/test/unit/data-structures/linked-list/singly-linked-list.more-branches.coverage.test.ts +0 -86
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -836
- package/test/unit/data-structures/linked-list/skip-linked-list.more-branches.coverage.test.ts +0 -31
- package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +0 -13
- package/test/unit/data-structures/linked-list/skip-list.test.ts +0 -86
- package/test/unit/data-structures/matrix/matrix.more-branches.coverage.test.ts +0 -81
- package/test/unit/data-structures/matrix/matrix.pivotElement-nullish.coverage.test.ts +0 -28
- package/test/unit/data-structures/matrix/matrix.test.ts +0 -377
- package/test/unit/data-structures/matrix/navigator.test.ts +0 -244
- package/test/unit/data-structures/priority-queue/max-priority-queue.more-branches.coverage.test.ts +0 -10
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +0 -160
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +0 -78
- package/test/unit/data-structures/priority-queue/priority-queue.coverage.test.ts +0 -21
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -101
- package/test/unit/data-structures/queue/deque.coverage.test.ts +0 -173
- package/test/unit/data-structures/queue/deque.more-branches-2.coverage.test.ts +0 -39
- package/test/unit/data-structures/queue/deque.more-branches-3.coverage.test.ts +0 -9
- package/test/unit/data-structures/queue/deque.more-branches.coverage.test.ts +0 -95
- package/test/unit/data-structures/queue/deque.test.ts +0 -936
- package/test/unit/data-structures/queue/queue.coverage.test.ts +0 -138
- package/test/unit/data-structures/queue/queue.more-branches-2.coverage.test.ts +0 -27
- package/test/unit/data-structures/queue/queue.test.ts +0 -703
- package/test/unit/data-structures/stack/stack.coverage.test.ts +0 -112
- package/test/unit/data-structures/stack/stack.test.ts +0 -438
- package/test/unit/data-structures/tree/tree.more-branches.coverage.test.ts +0 -9
- package/test/unit/data-structures/tree/tree.test.ts +0 -58
- package/test/unit/data-structures/trie/trie.more-branches-2.coverage.test.ts +0 -51
- package/test/unit/data-structures/trie/trie.test.ts +0 -1181
- package/test/unit/unrestricted-interconversion.test.ts +0 -299
- package/test/unit/utils/utils.test.ts +0 -174
- package/test/utils/array.ts +0 -5517
- package/test/utils/big-o.ts +0 -228
- package/test/utils/console.ts +0 -31
- package/test/utils/index.ts +0 -8
- package/test/utils/is.ts +0 -56
- package/test/utils/json2html.ts +0 -164
- package/test/utils/number.ts +0 -13
- package/test/utils/patch.ts +0 -33
- package/test/utils/perf.mjs +0 -34
- package/test/utils/performanc.ts +0 -7
- package/test/utils/string.ts +0 -49
- package/tsconfig.types.json +0 -15
- package/tsup.config.js +0 -63
- package/tsup.umd.config.js +0 -29
|
@@ -1,1150 +0,0 @@
|
|
|
1
|
-
import { DoublyLinkedList, DoublyLinkedListNode } from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('DoublyLinkedListNode', () => {
|
|
4
|
-
it('should DoublyLinkedListNode', () => {
|
|
5
|
-
const node1 = new DoublyLinkedListNode<number>(2);
|
|
6
|
-
expect(node1.value).toBe(2);
|
|
7
|
-
node1.value = 1;
|
|
8
|
-
expect(node1.value).toBe(1);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('DoublyLinkedList Operation Test', () => {
|
|
13
|
-
let list: DoublyLinkedList<number>;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
list = DoublyLinkedList.fromArray([1, 2, 3, 4, 5]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should out of bound index', () => {
|
|
20
|
-
expect(list.getNodeAt(-1)).toBe(undefined);
|
|
21
|
-
expect(list.getNodeAt(5)).toBe(undefined);
|
|
22
|
-
expect(list.addAt(5, 6)).toBe(true);
|
|
23
|
-
expect(list.addAt(-1, 6)).toBe(false);
|
|
24
|
-
expect(list.addAt(7, 6)).toBe(false);
|
|
25
|
-
expect(list.addAt(100, 6)).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should addBefore', () => {
|
|
29
|
-
expect(list.addBefore(1, 0)).toBe(true);
|
|
30
|
-
expect(list.addBefore(list.getNode(1)!, 2)).toBe(true);
|
|
31
|
-
expect([...list]).toEqual([0, 2, 1, 2, 3, 4, 5]);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should deleteAt', () => {
|
|
35
|
-
expect(list.deleteAt(1)).toBe(2);
|
|
36
|
-
expect(list.deleteAt(-1)).toBe(undefined);
|
|
37
|
-
expect(list.deleteAt(list.length)).toBe(undefined);
|
|
38
|
-
expect(list.length).toBe(4);
|
|
39
|
-
expect(list.deleteAt(4)).toBe(undefined);
|
|
40
|
-
expect([...list]).toEqual([1, 3, 4, 5]);
|
|
41
|
-
expect(list.isEmpty()).toBe(false);
|
|
42
|
-
expect(list.deleteAt(3)).toBe(5);
|
|
43
|
-
expect([...list]).toEqual([1, 3, 4]);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should delete tail', () => {
|
|
47
|
-
expect(list.delete(list.tail)).toBe(true);
|
|
48
|
-
expect(list.tail?.value).toBe(4);
|
|
49
|
-
expect(list.delete(6)).toBe(false);
|
|
50
|
-
expect(list.tail?.value).toBe(4);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should clone', function () {
|
|
54
|
-
const dList = new DoublyLinkedList<string>();
|
|
55
|
-
dList.push('1');
|
|
56
|
-
dList.push('6');
|
|
57
|
-
dList.push('2');
|
|
58
|
-
dList.push('0');
|
|
59
|
-
dList.push('5');
|
|
60
|
-
dList.push('9');
|
|
61
|
-
dList.delete('2');
|
|
62
|
-
expect([...dList]).toEqual(['1', '6', '0', '5', '9']);
|
|
63
|
-
const cloned = dList.clone();
|
|
64
|
-
expect([...cloned]).toEqual(['1', '6', '0', '5', '9']);
|
|
65
|
-
dList.delete('5');
|
|
66
|
-
expect([...dList]).toEqual(['1', '6', '0', '9']);
|
|
67
|
-
expect([...cloned]).toEqual(['1', '6', '0', '5', '9']);
|
|
68
|
-
expect(cloned.toVisual()).toEqual(['1', '6', '0', '5', '9']);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should find undefined', () => {
|
|
72
|
-
expect(list.find(value => value === 6)).toBe(undefined);
|
|
73
|
-
expect(list.find(value => value === 4)).toBe(4);
|
|
74
|
-
expect(list.find(value => value === 3)).toBe(3);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should indexOf -1', () => {
|
|
78
|
-
expect(list.indexOf(6)).toBe(-1);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should getBackward undefined', () => {
|
|
82
|
-
expect(list.getBackward(node => node.value === 0)).toBe(undefined);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should addAfter tail', () => {
|
|
86
|
-
expect(list.addAfter(list.tail!, 6)).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should addAfter tail', () => {
|
|
90
|
-
expect([...list]).toEqual([1, 2, 3, 4, 5]);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
describe('DoublyLinkedList Operation Test', () => {
|
|
95
|
-
let list: DoublyLinkedList<number>;
|
|
96
|
-
let objectList: DoublyLinkedList<{
|
|
97
|
-
keyA: number;
|
|
98
|
-
}>;
|
|
99
|
-
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
list = new DoublyLinkedList();
|
|
102
|
-
objectList = new DoublyLinkedList();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should initialize an empty list', () => {
|
|
106
|
-
expect(list.length).toBe(0);
|
|
107
|
-
expect(list.head).toBe(undefined);
|
|
108
|
-
expect(list.tail).toBe(undefined);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should initialize with toElementFn', () => {
|
|
112
|
-
const dl = new DoublyLinkedList([{ key: 1 }, { key: 2 }, { key: 3 }], { toElementFn: ({ key }) => key });
|
|
113
|
-
expect([...dl]).toEqual([1, 2, 3]);
|
|
114
|
-
expect(dl.first).toBe(1);
|
|
115
|
-
expect(dl.last).toBe(3);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should push elements to the list', () => {
|
|
119
|
-
list.push(1);
|
|
120
|
-
list.push(2);
|
|
121
|
-
list.push(3);
|
|
122
|
-
expect(list.length).toBe(3);
|
|
123
|
-
expect(list.head!.value).toBe(1);
|
|
124
|
-
expect(list.tail!.value).toBe(3);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('push with maxLen', () => {
|
|
128
|
-
const list = new DoublyLinkedList<number>([], { maxLen: 10 });
|
|
129
|
-
for (let i = 0; i < 1000; i++) {
|
|
130
|
-
list.push(i);
|
|
131
|
-
}
|
|
132
|
-
expect(list.maxLen).toBe(10);
|
|
133
|
-
expect(list.length).toBe(10);
|
|
134
|
-
expect(list.first).toBe(990);
|
|
135
|
-
|
|
136
|
-
list.clear();
|
|
137
|
-
for (let i = 0; i < 1000; i++) {
|
|
138
|
-
list.unshift(i);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
expect(list.maxLen).toBe(10);
|
|
142
|
-
expect(list.length).toBe(10);
|
|
143
|
-
expect(list.last).toBe(990);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should pop elements from the end of the list', () => {
|
|
147
|
-
list.push(1);
|
|
148
|
-
list.push(2);
|
|
149
|
-
const poppedValue = list.pop();
|
|
150
|
-
expect(poppedValue).toBe(2);
|
|
151
|
-
expect(list.length).toBe(1);
|
|
152
|
-
expect(list.head!.value).toBe(1);
|
|
153
|
-
expect(list.tail!.value).toBe(1);
|
|
154
|
-
list.pop();
|
|
155
|
-
expect([...list]).toEqual([]);
|
|
156
|
-
list.pop();
|
|
157
|
-
expect([...list]).toEqual([]);
|
|
158
|
-
});
|
|
159
|
-
it('should insert elements at specific positions', () => {
|
|
160
|
-
expect(list.at(0)).toBe(undefined);
|
|
161
|
-
list.push(1);
|
|
162
|
-
list.push(2);
|
|
163
|
-
list.push(3);
|
|
164
|
-
|
|
165
|
-
// Inserting at the beginning
|
|
166
|
-
list.addAt(0, 0);
|
|
167
|
-
expect(list.length).toBe(4);
|
|
168
|
-
expect(list.at(0)).toBe(0);
|
|
169
|
-
expect(list.at(1)).toBe(1);
|
|
170
|
-
|
|
171
|
-
// Inserting in the middle
|
|
172
|
-
list.addAt(2, 1.5);
|
|
173
|
-
expect(list.length).toBe(5);
|
|
174
|
-
expect(list.at(2)).toBe(1.5);
|
|
175
|
-
expect(list.at(3)).toBe(2);
|
|
176
|
-
|
|
177
|
-
// Inserting at the end
|
|
178
|
-
list.addAt(5, 4);
|
|
179
|
-
expect(list.length).toBe(6);
|
|
180
|
-
expect(list.at(5)).toBe(4);
|
|
181
|
-
expect(list.tail!.value).toBe(4);
|
|
182
|
-
expect(list.at(-1)).toBe(undefined);
|
|
183
|
-
expect(list.at(6)).toBe(undefined);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('should delete elements at specific positions', () => {
|
|
187
|
-
list.push(1);
|
|
188
|
-
list.push(2);
|
|
189
|
-
list.push(3);
|
|
190
|
-
|
|
191
|
-
// Deleting from the beginning
|
|
192
|
-
const deletedValue = list.deleteAt(0);
|
|
193
|
-
expect(deletedValue).toBe(1);
|
|
194
|
-
expect(list.length).toBe(2);
|
|
195
|
-
expect(list.head!.value).toBe(2);
|
|
196
|
-
|
|
197
|
-
// Deleting from the middle
|
|
198
|
-
list.deleteAt(0); // Deleting the second element
|
|
199
|
-
expect(list.length).toBe(1);
|
|
200
|
-
expect(list.head!.value).toBe(3);
|
|
201
|
-
|
|
202
|
-
// Deleting from the end
|
|
203
|
-
list.deleteAt(0);
|
|
204
|
-
expect(list.length).toBe(0);
|
|
205
|
-
expect(list.head).toBe(undefined);
|
|
206
|
-
expect(list.tail).toBe(undefined);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should delete elements by value', () => {
|
|
210
|
-
list.push(1);
|
|
211
|
-
list.push(2);
|
|
212
|
-
list.push(3);
|
|
213
|
-
|
|
214
|
-
list.delete(2);
|
|
215
|
-
expect(list.length).toBe(2);
|
|
216
|
-
expect(list.head!.value).toBe(1);
|
|
217
|
-
expect(list.tail!.value).toBe(3);
|
|
218
|
-
|
|
219
|
-
list.delete(1);
|
|
220
|
-
expect(list.length).toBe(1);
|
|
221
|
-
expect(list.head!.value).toBe(3);
|
|
222
|
-
|
|
223
|
-
list.delete(3);
|
|
224
|
-
expect(list.length).toBe(0);
|
|
225
|
-
expect(list.head).toBe(undefined);
|
|
226
|
-
expect(list.tail).toBe(undefined);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('should reverse the linked list', () => {
|
|
230
|
-
list.push(1);
|
|
231
|
-
list.push(2);
|
|
232
|
-
list.push(3);
|
|
233
|
-
|
|
234
|
-
list.reverse();
|
|
235
|
-
|
|
236
|
-
expect(list.toArray()).toEqual([3, 2, 1]);
|
|
237
|
-
expect(list.toReversedArray()).toEqual([1, 2, 3]);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('should map elements using a callback function', () => {
|
|
241
|
-
list.push(1);
|
|
242
|
-
list.push(2);
|
|
243
|
-
list.push(3);
|
|
244
|
-
|
|
245
|
-
const mappedList = list.map(value => value * 2);
|
|
246
|
-
|
|
247
|
-
expect(mappedList.toArray()).toEqual([2, 4, 6]);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('should filter elements using a callback function', () => {
|
|
251
|
-
list.push(1);
|
|
252
|
-
list.push(2);
|
|
253
|
-
list.push(3);
|
|
254
|
-
list.push(4);
|
|
255
|
-
|
|
256
|
-
const filteredList = list.filter(value => value % 2 === 0);
|
|
257
|
-
|
|
258
|
-
expect(filteredList.toArray()).toEqual([2, 4]);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('should reduce elements using a callback function and an initial value', () => {
|
|
262
|
-
list.push(1);
|
|
263
|
-
list.push(2);
|
|
264
|
-
list.push(3);
|
|
265
|
-
list.push(4);
|
|
266
|
-
|
|
267
|
-
const sum = list.reduce((acc, value) => acc + value, 0);
|
|
268
|
-
|
|
269
|
-
expect(sum).toBe(10);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('should insert an element after a specific value', () => {
|
|
273
|
-
list.push(1);
|
|
274
|
-
list.push(2);
|
|
275
|
-
list.push(3);
|
|
276
|
-
|
|
277
|
-
list.addAfter(2, 2.5);
|
|
278
|
-
|
|
279
|
-
expect(list.toArray()).toEqual([1, 2, 2.5, 3]);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('should insert an element before a specific value', () => {
|
|
283
|
-
list.push(1);
|
|
284
|
-
list.push(2);
|
|
285
|
-
list.push(3);
|
|
286
|
-
|
|
287
|
-
list.addBefore(2, 1.5);
|
|
288
|
-
|
|
289
|
-
expect(list.toArray()).toEqual([1, 1.5, 2, 3]);
|
|
290
|
-
});
|
|
291
|
-
it('should find the first element that satisfies a condition', () => {
|
|
292
|
-
list.push(1);
|
|
293
|
-
list.push(2);
|
|
294
|
-
list.push(3);
|
|
295
|
-
|
|
296
|
-
const found = list.find(value => value % 2 === 0);
|
|
297
|
-
|
|
298
|
-
expect(found).toBe(2);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('should find the index of an element', () => {
|
|
302
|
-
list.push(1);
|
|
303
|
-
list.push(2);
|
|
304
|
-
list.push(3);
|
|
305
|
-
|
|
306
|
-
const index = list.indexOf(2);
|
|
307
|
-
|
|
308
|
-
expect(index).toBe(1);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('should find the last element that satisfies a condition', () => {
|
|
312
|
-
list.push(1);
|
|
313
|
-
list.push(2);
|
|
314
|
-
list.push(3);
|
|
315
|
-
list.push(4);
|
|
316
|
-
|
|
317
|
-
const lastEven = list.getBackward(node => node.value % 2 === 0);
|
|
318
|
-
|
|
319
|
-
expect(lastEven).toBe(4);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('should clear the linked list', () => {
|
|
323
|
-
list.push(1);
|
|
324
|
-
list.push(2);
|
|
325
|
-
list.push(3);
|
|
326
|
-
|
|
327
|
-
list.clear();
|
|
328
|
-
|
|
329
|
-
expect(list.length).toBe(0);
|
|
330
|
-
expect(list.head).toBe(undefined);
|
|
331
|
-
expect(list.tail).toBe(undefined);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('should create a reversed array of values', () => {
|
|
335
|
-
list.push(1);
|
|
336
|
-
list.push(2);
|
|
337
|
-
list.push(3);
|
|
338
|
-
|
|
339
|
-
const reversedArray = list.toReversedArray();
|
|
340
|
-
|
|
341
|
-
expect(reversedArray).toEqual([3, 2, 1]);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it('should reverse the linked list', () => {
|
|
345
|
-
list.push(1);
|
|
346
|
-
list.push(2);
|
|
347
|
-
list.push(3);
|
|
348
|
-
|
|
349
|
-
list.reverse();
|
|
350
|
-
|
|
351
|
-
expect(list.toArray()).toEqual([3, 2, 1]);
|
|
352
|
-
expect(list.head?.value).toBe(3);
|
|
353
|
-
expect(list.tail?.value).toBe(1);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it('should iterate over each element and apply a callback', () => {
|
|
357
|
-
list.push(1);
|
|
358
|
-
list.push(2);
|
|
359
|
-
list.push(3);
|
|
360
|
-
|
|
361
|
-
const result: number[] = [];
|
|
362
|
-
list.forEach(value => {
|
|
363
|
-
result.push(value * 2);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
expect(result).toEqual([2, 4, 6]);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it('should create a new linked list by applying a mapping function', () => {
|
|
370
|
-
list.push(1);
|
|
371
|
-
list.push(2);
|
|
372
|
-
list.push(3);
|
|
373
|
-
|
|
374
|
-
const mappedList = list.map(value => value * 2);
|
|
375
|
-
|
|
376
|
-
expect(mappedList.toArray()).toEqual([2, 4, 6]);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('should create a new linked list by filtering elements', () => {
|
|
380
|
-
list.push(1);
|
|
381
|
-
list.push(2);
|
|
382
|
-
list.push(3);
|
|
383
|
-
list.push(4);
|
|
384
|
-
|
|
385
|
-
const filteredList = list.filter(value => value % 2 === 0);
|
|
386
|
-
|
|
387
|
-
expect(filteredList.toArray()).toEqual([2, 4]);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it('should reduce the linked list to a single value', () => {
|
|
391
|
-
list.push(1);
|
|
392
|
-
list.push(2);
|
|
393
|
-
list.push(3);
|
|
394
|
-
|
|
395
|
-
const sum = list.reduce((acc, value) => acc + value, 0);
|
|
396
|
-
|
|
397
|
-
expect(sum).toBe(6);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
it('should insert a new value after an existing value', () => {
|
|
401
|
-
list.push(1);
|
|
402
|
-
list.push(2);
|
|
403
|
-
list.push(3);
|
|
404
|
-
|
|
405
|
-
const success = list.addAfter(2, 4);
|
|
406
|
-
expect(success).toBe(true);
|
|
407
|
-
expect(list.toArray()).toEqual([1, 2, 4, 3]);
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it('should insert a new value before an existing value', () => {
|
|
411
|
-
list.push(1);
|
|
412
|
-
list.push(2);
|
|
413
|
-
list.push(3);
|
|
414
|
-
|
|
415
|
-
const success = list.addBefore(2, 0);
|
|
416
|
-
expect(success).toBe(true);
|
|
417
|
-
expect(list.toArray()).toEqual([1, 0, 2, 3]);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('should not insert a new value after a non-existing value', () => {
|
|
421
|
-
list.push(1);
|
|
422
|
-
list.push(2);
|
|
423
|
-
list.push(3);
|
|
424
|
-
|
|
425
|
-
const success = list.addAfter(4, 5);
|
|
426
|
-
expect(success).toBe(false);
|
|
427
|
-
expect(list.toArray()).toEqual([1, 2, 3]);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('should not insert a new value before a non-existing value', () => {
|
|
431
|
-
list.push(1);
|
|
432
|
-
list.push(2);
|
|
433
|
-
list.push(3);
|
|
434
|
-
|
|
435
|
-
const success = list.addBefore(4, 0);
|
|
436
|
-
expect(success).toBe(false);
|
|
437
|
-
expect(list.toArray()).toEqual([1, 2, 3]);
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it('should insert and manipulate objects with numeric properties', () => {
|
|
441
|
-
const obj1 = { keyA: 10 };
|
|
442
|
-
const obj2 = { keyA: 20 };
|
|
443
|
-
const obj3 = { keyA: 30 };
|
|
444
|
-
|
|
445
|
-
objectList.push(obj1);
|
|
446
|
-
objectList.push(obj2);
|
|
447
|
-
objectList.push(obj3);
|
|
448
|
-
|
|
449
|
-
expect(objectList.toArray()).toEqual([obj1, obj2, obj3]);
|
|
450
|
-
|
|
451
|
-
const newObj = { keyA: 25 }; // Corrected newObj value
|
|
452
|
-
const insertSuccess = objectList.addBefore(obj2, newObj);
|
|
453
|
-
expect(insertSuccess).toBe(true);
|
|
454
|
-
|
|
455
|
-
const getNode = objectList.getNode(newObj); // Use newObj instead of obj2
|
|
456
|
-
expect(getNode?.value).toEqual(newObj);
|
|
457
|
-
|
|
458
|
-
const deleted = objectList.delete(newObj); // Use newObj instead of obj2
|
|
459
|
-
expect(deleted).toBe(true);
|
|
460
|
-
|
|
461
|
-
const poppedObj = objectList.pop();
|
|
462
|
-
expect(poppedObj).toBe(obj3);
|
|
463
|
-
|
|
464
|
-
const shiftedObj = objectList.shift();
|
|
465
|
-
expect(shiftedObj).toBe(obj1);
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
describe('DoublyLinkedList Additional Methods', () => {
|
|
470
|
-
// Slice method implementation and test
|
|
471
|
-
test('slice should return a new list with specified range', () => {
|
|
472
|
-
const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
473
|
-
const slicedList = list.slice(1, 4);
|
|
474
|
-
|
|
475
|
-
expect(slicedList.toArray()).toEqual([2, 3, 4]);
|
|
476
|
-
expect(list.length).toBe(5); // Original list unchanged
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
// Splice method implementation
|
|
480
|
-
test('splice should modify list and return removed elements', () => {
|
|
481
|
-
const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
482
|
-
const removedList = list.splice(2, 2, 6, 7);
|
|
483
|
-
|
|
484
|
-
expect(list.toArray()).toEqual([1, 2, 6, 7, 5]);
|
|
485
|
-
expect(removedList.toArray()).toEqual([3, 4]);
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
// Concat method test
|
|
489
|
-
test('concat should combine multiple lists', () => {
|
|
490
|
-
const list1 = new DoublyLinkedList([1, 2]);
|
|
491
|
-
const list2 = new DoublyLinkedList([3, 4]);
|
|
492
|
-
const list3 = new DoublyLinkedList([5, 6]);
|
|
493
|
-
|
|
494
|
-
const concatenatedList = list1.concat(list2, list3);
|
|
495
|
-
expect(concatenatedList.toArray()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
// Sort method test
|
|
499
|
-
test('sort should order elements in ascending order', () => {
|
|
500
|
-
const list = new DoublyLinkedList([5, 2, 8, 1, 9]);
|
|
501
|
-
list.sort((a, b) => a - b);
|
|
502
|
-
|
|
503
|
-
expect(list.toArray()).toEqual([1, 2, 5, 8, 9]);
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
// Reverse method test
|
|
507
|
-
test('reverse should invert the list order', () => {
|
|
508
|
-
const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
509
|
-
list.reverse();
|
|
510
|
-
|
|
511
|
-
expect(list.toArray()).toEqual([5, 4, 3, 2, 1]);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
// Join method test
|
|
515
|
-
test('join should convert list to string with separator', () => {
|
|
516
|
-
const list = new DoublyLinkedList(['a', 'b', 'c']);
|
|
517
|
-
|
|
518
|
-
expect(list.join('-')).toBe('a-b-c');
|
|
519
|
-
expect(list.join()).toBe('a,b,c');
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
// IndexOf method test
|
|
523
|
-
test('indexOf should return first occurrence index', () => {
|
|
524
|
-
const list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
525
|
-
|
|
526
|
-
expect(list.indexOf(2)).toBe(1);
|
|
527
|
-
expect(list.indexOf(4)).toBe(-1);
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
// LastIndexOf method test
|
|
531
|
-
test('lastIndexOf should return last occurrence index', () => {
|
|
532
|
-
const list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
533
|
-
|
|
534
|
-
expect(list.lastIndexOf(2)).toBe(3);
|
|
535
|
-
expect(list.lastIndexOf(4)).toBe(-1);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
// findIndex method test
|
|
539
|
-
test('findIndex should return first occurrence index', () => {
|
|
540
|
-
const list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
541
|
-
expect(list.findIndex(item => item === 2)).toBe(1);
|
|
542
|
-
expect(list.findIndex(item => item === 4)).toBe(-1);
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
// fill method test
|
|
546
|
-
test('fill should return fill all the list', () => {
|
|
547
|
-
let list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
548
|
-
expect([...list.fill(9)]).toEqual([9, 9, 9, 9, 9]);
|
|
549
|
-
list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
550
|
-
expect([...list.fill(9, 2, 3)]).toEqual([1, 2, 9, 2, 1]);
|
|
551
|
-
list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
552
|
-
expect([...list.fill(9, -3, -2)]).toEqual([1, 2, 9, 2, 1]);
|
|
553
|
-
list = new DoublyLinkedList([1, 2, 3, 2, 1]);
|
|
554
|
-
expect([...list.fill(9, -2, -3)]).toEqual([1, 2, 3, 2, 1]);
|
|
555
|
-
});
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
describe('iterable methods', () => {
|
|
559
|
-
it('should forEach, some, every, filter, map, reduce of the deque', () => {
|
|
560
|
-
const dl = new DoublyLinkedList<number>();
|
|
561
|
-
dl.push(1);
|
|
562
|
-
dl.push(2);
|
|
563
|
-
dl.push(3);
|
|
564
|
-
|
|
565
|
-
const mockCallback = jest.fn();
|
|
566
|
-
dl.forEach(element => {
|
|
567
|
-
mockCallback(element);
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
expect(mockCallback.mock.calls.length).toBe(3);
|
|
571
|
-
expect(mockCallback.mock.calls[0]).toEqual([1]);
|
|
572
|
-
expect(mockCallback.mock.calls[1]).toEqual([2]);
|
|
573
|
-
expect(mockCallback.mock.calls[2]).toEqual([3]);
|
|
574
|
-
|
|
575
|
-
expect(dl.every(element => element > 0)).toBe(true);
|
|
576
|
-
expect(dl.every(element => element > 1)).toBe(false);
|
|
577
|
-
expect(dl.some(element => element > 2)).toBe(true);
|
|
578
|
-
|
|
579
|
-
expect([...dl.filter(element => element > 2)]).toEqual([3]);
|
|
580
|
-
expect([...dl.map(element => element * 2)]).toEqual([2, 4, 6]);
|
|
581
|
-
expect(dl.reduce((accumulator, element) => accumulator + element, 0)).toEqual(6);
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
it('values', () => {
|
|
585
|
-
const dl = new DoublyLinkedList<number>();
|
|
586
|
-
dl.shift();
|
|
587
|
-
expect([...dl]).toEqual([]);
|
|
588
|
-
dl.unshift(1);
|
|
589
|
-
dl.push(2);
|
|
590
|
-
dl.push(3);
|
|
591
|
-
dl.delete(2);
|
|
592
|
-
dl.unshift(0);
|
|
593
|
-
dl.shift();
|
|
594
|
-
dl.pop();
|
|
595
|
-
dl.unshift(3);
|
|
596
|
-
expect([...dl.values()]).toEqual([3, 1]);
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
it('some', () => {
|
|
600
|
-
const dl = new DoublyLinkedList<number>();
|
|
601
|
-
dl.push(1);
|
|
602
|
-
dl.push(2);
|
|
603
|
-
dl.push(3);
|
|
604
|
-
dl.delete(2);
|
|
605
|
-
dl.unshift(0);
|
|
606
|
-
dl.shift();
|
|
607
|
-
dl.pop();
|
|
608
|
-
dl.unshift(3);
|
|
609
|
-
expect(dl.some(value => value > 1)).toBe(true);
|
|
610
|
-
expect(dl.some(value => value > 100)).toBe(false);
|
|
611
|
-
});
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
describe('classic use', () => {
|
|
615
|
-
it('@example basic DoublyLinkedList creation and push operation', () => {
|
|
616
|
-
// Create a simple DoublyLinkedList with initial values
|
|
617
|
-
const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
|
|
618
|
-
|
|
619
|
-
// Verify the list maintains insertion order
|
|
620
|
-
expect([...list]).toEqual([1, 2, 3, 4, 5]);
|
|
621
|
-
|
|
622
|
-
// Check length
|
|
623
|
-
expect(list.length).toBe(5);
|
|
624
|
-
|
|
625
|
-
// Push a new element to the end
|
|
626
|
-
list.push(6);
|
|
627
|
-
expect(list.length).toBe(6);
|
|
628
|
-
expect([...list]).toEqual([1, 2, 3, 4, 5, 6]);
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
it('@example DoublyLinkedList pop and shift operations', () => {
|
|
632
|
-
const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
633
|
-
|
|
634
|
-
// Pop removes from the end
|
|
635
|
-
const last = list.pop();
|
|
636
|
-
expect(last).toBe(50);
|
|
637
|
-
|
|
638
|
-
// Shift removes from the beginning
|
|
639
|
-
const first = list.shift();
|
|
640
|
-
expect(first).toBe(10);
|
|
641
|
-
|
|
642
|
-
// Verify remaining elements
|
|
643
|
-
expect([...list]).toEqual([20, 30, 40]);
|
|
644
|
-
expect(list.length).toBe(3);
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
it('@example DoublyLinkedList for...of iteration and map operation', () => {
|
|
648
|
-
const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
649
|
-
|
|
650
|
-
// Iterate through list
|
|
651
|
-
const doubled = list.map(value => value * 2);
|
|
652
|
-
expect(doubled.length).toBe(5);
|
|
653
|
-
|
|
654
|
-
// Use for...of loop
|
|
655
|
-
const result: number[] = [];
|
|
656
|
-
for (const item of list) {
|
|
657
|
-
result.push(item);
|
|
658
|
-
}
|
|
659
|
-
expect(result).toEqual([1, 2, 3, 4, 5]);
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
it('@example Browser history', () => {
|
|
663
|
-
const browserHistory = new DoublyLinkedList<string>();
|
|
664
|
-
|
|
665
|
-
browserHistory.push('home page');
|
|
666
|
-
browserHistory.push('search page');
|
|
667
|
-
browserHistory.push('details page');
|
|
668
|
-
|
|
669
|
-
expect(browserHistory.last).toBe('details page');
|
|
670
|
-
expect(browserHistory.pop()).toBe('details page');
|
|
671
|
-
expect(browserHistory.last).toBe('search page');
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
it('@example DoublyLinkedList for LRU cache implementation', () => {
|
|
675
|
-
interface CacheEntry {
|
|
676
|
-
key: string;
|
|
677
|
-
value: string;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
// Simulate LRU cache using DoublyLinkedList
|
|
681
|
-
// DoublyLinkedList is perfect because:
|
|
682
|
-
// - O(1) delete from any position
|
|
683
|
-
// - O(1) push to end
|
|
684
|
-
// - Bidirectional traversal for LRU policy
|
|
685
|
-
|
|
686
|
-
const cacheList = new DoublyLinkedList<CacheEntry>();
|
|
687
|
-
const maxSize = 3;
|
|
688
|
-
|
|
689
|
-
// Add cache entries
|
|
690
|
-
cacheList.push({ key: 'user:1', value: 'Alice' });
|
|
691
|
-
cacheList.push({ key: 'user:2', value: 'Bob' });
|
|
692
|
-
cacheList.push({ key: 'user:3', value: 'Charlie' });
|
|
693
|
-
|
|
694
|
-
// Try to add a new entry when cache is full
|
|
695
|
-
if (cacheList.length >= maxSize) {
|
|
696
|
-
// Remove the oldest (first) entry
|
|
697
|
-
const evicted = cacheList.shift();
|
|
698
|
-
expect(evicted?.key).toBe('user:1');
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// Add new entry
|
|
702
|
-
cacheList.push({ key: 'user:4', value: 'Diana' });
|
|
703
|
-
|
|
704
|
-
// Verify current cache state
|
|
705
|
-
expect(cacheList.length).toBe(3);
|
|
706
|
-
const cachedKeys = [...cacheList].map(entry => entry.key);
|
|
707
|
-
expect(cachedKeys).toEqual(['user:2', 'user:3', 'user:4']);
|
|
708
|
-
|
|
709
|
-
// Access entry (in real LRU, this would move it to end)
|
|
710
|
-
const foundEntry = [...cacheList].find(entry => entry.key === 'user:2');
|
|
711
|
-
expect(foundEntry?.value).toBe('Bob');
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
it('DoublyLinkedList unshift and bidirectional traversal', () => {
|
|
715
|
-
const list = new DoublyLinkedList<number>([20, 30, 40]);
|
|
716
|
-
|
|
717
|
-
// Unshift adds to the beginning
|
|
718
|
-
list.unshift(10);
|
|
719
|
-
expect([...list]).toEqual([10, 20, 30, 40]);
|
|
720
|
-
|
|
721
|
-
// Access elements by index (bidirectional advantage)
|
|
722
|
-
const second = list.at(1);
|
|
723
|
-
expect(second).toBe(20);
|
|
724
|
-
|
|
725
|
-
const last = list.at(list.length - 1);
|
|
726
|
-
expect(last).toBe(40);
|
|
727
|
-
|
|
728
|
-
expect(list.length).toBe(4);
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
it('text editor operation history', () => {
|
|
732
|
-
const actions = [
|
|
733
|
-
{ type: 'insert', content: 'first line of text' },
|
|
734
|
-
{ type: 'insert', content: 'second line of text' },
|
|
735
|
-
{ type: 'delete', content: 'delete the first line' }
|
|
736
|
-
];
|
|
737
|
-
const editorHistory = new DoublyLinkedList<{ type: string; content: string }>(actions);
|
|
738
|
-
|
|
739
|
-
expect(editorHistory.last?.type).toBe('delete');
|
|
740
|
-
expect(editorHistory.pop()?.content).toBe('delete the first line');
|
|
741
|
-
expect(editorHistory.last?.type).toBe('insert');
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
it('Use DoublyLinkedList to implement music player', () => {
|
|
745
|
-
// Define the Song interface
|
|
746
|
-
interface Song {
|
|
747
|
-
title: string;
|
|
748
|
-
artist: string;
|
|
749
|
-
duration: number; // duration in seconds
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
class Player {
|
|
753
|
-
private playlist: DoublyLinkedList<Song>;
|
|
754
|
-
private currentSong: ReturnType<typeof this.playlist.getNodeAt> | undefined;
|
|
755
|
-
|
|
756
|
-
constructor(songs: Song[]) {
|
|
757
|
-
this.playlist = new DoublyLinkedList<Song>();
|
|
758
|
-
songs.forEach(song => this.playlist.push(song));
|
|
759
|
-
this.currentSong = this.playlist.head;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// Play the next song in the playlist
|
|
763
|
-
playNext(): Song | undefined {
|
|
764
|
-
if (!this.currentSong?.next) {
|
|
765
|
-
this.currentSong = this.playlist.head; // Loop to the first song
|
|
766
|
-
} else {
|
|
767
|
-
this.currentSong = this.currentSong.next;
|
|
768
|
-
}
|
|
769
|
-
return this.currentSong?.value;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// Play the previous song in the playlist
|
|
773
|
-
playPrevious(): Song | undefined {
|
|
774
|
-
if (!this.currentSong?.prev) {
|
|
775
|
-
this.currentSong = this.playlist.tail; // Loop to the last song
|
|
776
|
-
} else {
|
|
777
|
-
this.currentSong = this.currentSong.prev;
|
|
778
|
-
}
|
|
779
|
-
return this.currentSong?.value;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// Get the current song
|
|
783
|
-
getCurrentSong(): Song | undefined {
|
|
784
|
-
return this.currentSong?.value;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// Loop through the playlist twice
|
|
788
|
-
loopThroughPlaylist(): Song[] {
|
|
789
|
-
const playedSongs: Song[] = [];
|
|
790
|
-
const initialNode = this.currentSong;
|
|
791
|
-
|
|
792
|
-
// Loop through the playlist twice
|
|
793
|
-
for (let i = 0; i < this.playlist.length * 2; i++) {
|
|
794
|
-
playedSongs.push(this.currentSong!.value);
|
|
795
|
-
this.currentSong = this.currentSong!.next || this.playlist.head; // Loop back to the start if needed
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// Reset the current song to the initial song
|
|
799
|
-
this.currentSong = initialNode;
|
|
800
|
-
return playedSongs;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
const songs = [
|
|
805
|
-
{ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
|
|
806
|
-
{ title: 'Hotel California', artist: 'Eagles', duration: 391 },
|
|
807
|
-
{ title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
|
|
808
|
-
{ title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 }
|
|
809
|
-
];
|
|
810
|
-
let player = new Player(songs);
|
|
811
|
-
// should play the next song
|
|
812
|
-
player = new Player(songs);
|
|
813
|
-
const firstSong = player.getCurrentSong();
|
|
814
|
-
const nextSong = player.playNext();
|
|
815
|
-
|
|
816
|
-
// Expect the next song to be "Hotel California by Eagles"
|
|
817
|
-
expect(nextSong).toEqual({ title: 'Hotel California', artist: 'Eagles', duration: 391 });
|
|
818
|
-
expect(firstSong).toEqual({ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 });
|
|
819
|
-
|
|
820
|
-
// should play the previous song
|
|
821
|
-
player = new Player(songs);
|
|
822
|
-
player.playNext(); // Move to the second song
|
|
823
|
-
const currentSong = player.getCurrentSong();
|
|
824
|
-
const previousSong = player.playPrevious();
|
|
825
|
-
|
|
826
|
-
// Expect the previous song to be "Bohemian Rhapsody by Queen"
|
|
827
|
-
expect(previousSong).toEqual({ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 });
|
|
828
|
-
expect(currentSong).toEqual({ title: 'Hotel California', artist: 'Eagles', duration: 391 });
|
|
829
|
-
|
|
830
|
-
// should loop to the first song when playing next from the last song
|
|
831
|
-
player = new Player(songs);
|
|
832
|
-
player.playNext(); // Move to the second song
|
|
833
|
-
player.playNext(); // Move to the third song
|
|
834
|
-
player.playNext(); // Move to the fourth song
|
|
835
|
-
|
|
836
|
-
const nextSongToFirst = player.playNext(); // Should loop to the first song
|
|
837
|
-
|
|
838
|
-
// Expect the next song to be "Bohemian Rhapsody by Queen"
|
|
839
|
-
expect(nextSongToFirst).toEqual({ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 });
|
|
840
|
-
|
|
841
|
-
// should loop to the last song when playing previous from the first song
|
|
842
|
-
player = new Player(songs);
|
|
843
|
-
player.playNext(); // Move to the first song
|
|
844
|
-
player.playNext(); // Move to the second song
|
|
845
|
-
player.playNext(); // Move to the third song
|
|
846
|
-
player.playNext(); // Move to the fourth song
|
|
847
|
-
|
|
848
|
-
const previousToLast = player.playPrevious(); // Should loop to the last song
|
|
849
|
-
|
|
850
|
-
// Expect the previous song to be "Billie Jean by Michael Jackson"
|
|
851
|
-
expect(previousToLast).toEqual({ title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 });
|
|
852
|
-
|
|
853
|
-
// should loop through the entire playlist
|
|
854
|
-
player = new Player(songs);
|
|
855
|
-
const playedSongs = player.loopThroughPlaylist();
|
|
856
|
-
|
|
857
|
-
// The expected order of songs for two loops
|
|
858
|
-
expect(playedSongs).toEqual([
|
|
859
|
-
{ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
|
|
860
|
-
{ title: 'Hotel California', artist: 'Eagles', duration: 391 },
|
|
861
|
-
{ title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
|
|
862
|
-
{ title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 },
|
|
863
|
-
{ title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
|
|
864
|
-
{ title: 'Hotel California', artist: 'Eagles', duration: 391 },
|
|
865
|
-
{ title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
|
|
866
|
-
{ title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 }
|
|
867
|
-
]);
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
it('Use DoublyLinkedList to implement LRU cache', () => {
|
|
871
|
-
interface CacheEntry<K, V> {
|
|
872
|
-
key: K;
|
|
873
|
-
value: V;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
class LRUCache<K = string, V = any> {
|
|
877
|
-
private readonly capacity: number;
|
|
878
|
-
private list: DoublyLinkedList<CacheEntry<K, V>>;
|
|
879
|
-
private map: Map<K, DoublyLinkedListNode<CacheEntry<K, V>>>;
|
|
880
|
-
|
|
881
|
-
constructor(capacity: number) {
|
|
882
|
-
if (capacity <= 0) {
|
|
883
|
-
throw new Error('lru cache capacity must be greater than 0');
|
|
884
|
-
}
|
|
885
|
-
this.capacity = capacity;
|
|
886
|
-
this.list = new DoublyLinkedList<CacheEntry<K, V>>();
|
|
887
|
-
this.map = new Map<K, DoublyLinkedListNode<CacheEntry<K, V>>>();
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
// Get the current cache length
|
|
891
|
-
get length(): number {
|
|
892
|
-
return this.list.length;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
// Check if it is empty
|
|
896
|
-
get isEmpty(): boolean {
|
|
897
|
-
return this.list.isEmpty();
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// Get cached value
|
|
901
|
-
get(key: K): V | undefined {
|
|
902
|
-
const node = this.map.get(key);
|
|
903
|
-
|
|
904
|
-
if (!node) return undefined;
|
|
905
|
-
|
|
906
|
-
// Move the visited node to the head of the linked list (most recently used)
|
|
907
|
-
this.moveToFront(node);
|
|
908
|
-
|
|
909
|
-
return node.value.value;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// Set cache value
|
|
913
|
-
set(key: K, value: V): void {
|
|
914
|
-
// Check if it already exists
|
|
915
|
-
const node = this.map.get(key);
|
|
916
|
-
|
|
917
|
-
if (node) {
|
|
918
|
-
// Update value and move to head
|
|
919
|
-
node.value.value = value;
|
|
920
|
-
this.moveToFront(node);
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// Check capacity
|
|
925
|
-
if (this.list.length >= this.capacity) {
|
|
926
|
-
// Delete the least recently used element (the tail of the linked list)
|
|
927
|
-
const removedNode = this.list.tail;
|
|
928
|
-
if (removedNode) {
|
|
929
|
-
this.map.delete(removedNode.value.key);
|
|
930
|
-
this.list.pop();
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// Create new node and add to head
|
|
935
|
-
const newEntry: CacheEntry<K, V> = { key, value };
|
|
936
|
-
this.list.unshift(newEntry);
|
|
937
|
-
|
|
938
|
-
// Save node reference in map
|
|
939
|
-
const newNode = this.list.head;
|
|
940
|
-
if (newNode) {
|
|
941
|
-
this.map.set(key, newNode);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
// Delete specific key
|
|
946
|
-
delete(key: K): boolean {
|
|
947
|
-
const node = this.map.get(key);
|
|
948
|
-
if (!node) return false;
|
|
949
|
-
|
|
950
|
-
// Remove from linked list
|
|
951
|
-
this.list.delete(node);
|
|
952
|
-
// Remove from map
|
|
953
|
-
this.map.delete(key);
|
|
954
|
-
|
|
955
|
-
return true;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// Clear cache
|
|
959
|
-
clear(): void {
|
|
960
|
-
this.list.clear();
|
|
961
|
-
this.map.clear();
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
// Move the node to the head of the linked list
|
|
965
|
-
private moveToFront(node: DoublyLinkedListNode<CacheEntry<K, V>>): void {
|
|
966
|
-
this.list.delete(node);
|
|
967
|
-
this.list.unshift(node.value);
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// should set and get values correctly
|
|
972
|
-
const cache = new LRUCache<string, number>(3);
|
|
973
|
-
cache.set('a', 1);
|
|
974
|
-
cache.set('b', 2);
|
|
975
|
-
cache.set('c', 3);
|
|
976
|
-
|
|
977
|
-
expect(cache.get('a')).toBe(1);
|
|
978
|
-
expect(cache.get('b')).toBe(2);
|
|
979
|
-
expect(cache.get('c')).toBe(3);
|
|
980
|
-
|
|
981
|
-
// The least recently used element should be evicted when capacity is exceeded
|
|
982
|
-
cache.clear();
|
|
983
|
-
cache.set('a', 1);
|
|
984
|
-
cache.set('b', 2);
|
|
985
|
-
cache.set('c', 3);
|
|
986
|
-
cache.set('d', 4); // This will eliminate 'a'
|
|
987
|
-
|
|
988
|
-
expect(cache.get('a')).toBeUndefined();
|
|
989
|
-
expect(cache.get('b')).toBe(2);
|
|
990
|
-
expect(cache.get('c')).toBe(3);
|
|
991
|
-
expect(cache.get('d')).toBe(4);
|
|
992
|
-
|
|
993
|
-
// The priority of an element should be updated when it is accessed
|
|
994
|
-
cache.clear();
|
|
995
|
-
cache.set('a', 1);
|
|
996
|
-
cache.set('b', 2);
|
|
997
|
-
cache.set('c', 3);
|
|
998
|
-
|
|
999
|
-
cache.get('a'); // access 'a'
|
|
1000
|
-
cache.set('d', 4); // This will eliminate 'b'
|
|
1001
|
-
|
|
1002
|
-
expect(cache.get('a')).toBe(1);
|
|
1003
|
-
expect(cache.get('b')).toBeUndefined();
|
|
1004
|
-
expect(cache.get('c')).toBe(3);
|
|
1005
|
-
expect(cache.get('d')).toBe(4);
|
|
1006
|
-
|
|
1007
|
-
// Should support updating existing keys
|
|
1008
|
-
cache.clear();
|
|
1009
|
-
cache.set('a', 1);
|
|
1010
|
-
cache.set('a', 10);
|
|
1011
|
-
|
|
1012
|
-
expect(cache.get('a')).toBe(10);
|
|
1013
|
-
|
|
1014
|
-
// Should support deleting specified keys
|
|
1015
|
-
cache.clear();
|
|
1016
|
-
cache.set('a', 1);
|
|
1017
|
-
cache.set('b', 2);
|
|
1018
|
-
|
|
1019
|
-
expect(cache.delete('a')).toBe(true);
|
|
1020
|
-
expect(cache.get('a')).toBeUndefined();
|
|
1021
|
-
expect(cache.length).toBe(1);
|
|
1022
|
-
|
|
1023
|
-
// Should support clearing cache
|
|
1024
|
-
cache.clear();
|
|
1025
|
-
cache.set('a', 1);
|
|
1026
|
-
cache.set('b', 2);
|
|
1027
|
-
cache.clear();
|
|
1028
|
-
|
|
1029
|
-
expect(cache.length).toBe(0);
|
|
1030
|
-
expect(cache.isEmpty).toBe(true);
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
it('Finding lyrics by timestamp in Coldplay\'s "Fix You"', () => {
|
|
1034
|
-
// Create a DoublyLinkedList to store song lyrics with timestamps
|
|
1035
|
-
const lyricsList = new DoublyLinkedList<{ time: number; text: string }>();
|
|
1036
|
-
|
|
1037
|
-
// Detailed lyrics with precise timestamps (in milliseconds)
|
|
1038
|
-
const lyrics = [
|
|
1039
|
-
{ time: 0, text: "When you try your best, but you don't succeed" },
|
|
1040
|
-
{ time: 4000, text: 'When you get what you want, but not what you need' },
|
|
1041
|
-
{ time: 8000, text: "When you feel so tired, but you can't sleep" },
|
|
1042
|
-
{ time: 12000, text: 'Stuck in reverse' },
|
|
1043
|
-
{ time: 16000, text: 'And the tears come streaming down your face' },
|
|
1044
|
-
{ time: 20000, text: "When you lose something you can't replace" },
|
|
1045
|
-
{ time: 24000, text: 'When you love someone, but it goes to waste' },
|
|
1046
|
-
{ time: 28000, text: 'Could it be worse?' },
|
|
1047
|
-
{ time: 32000, text: 'Lights will guide you home' },
|
|
1048
|
-
{ time: 36000, text: 'And ignite your bones' },
|
|
1049
|
-
{ time: 40000, text: 'And I will try to fix you' }
|
|
1050
|
-
];
|
|
1051
|
-
|
|
1052
|
-
// Populate the DoublyLinkedList with lyrics
|
|
1053
|
-
lyrics.forEach(lyric => lyricsList.push(lyric));
|
|
1054
|
-
|
|
1055
|
-
// Test different scenarios of lyric synchronization
|
|
1056
|
-
|
|
1057
|
-
// 1. Find lyric at exact timestamp
|
|
1058
|
-
const exactTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 36000);
|
|
1059
|
-
expect(exactTimeLyric?.text).toBe('And ignite your bones');
|
|
1060
|
-
|
|
1061
|
-
// 2. Find lyric between timestamps
|
|
1062
|
-
const betweenTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 22000);
|
|
1063
|
-
expect(betweenTimeLyric?.text).toBe("When you lose something you can't replace");
|
|
1064
|
-
|
|
1065
|
-
// 3. Find first lyric when timestamp is less than first entry
|
|
1066
|
-
const earlyTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= -1000);
|
|
1067
|
-
expect(earlyTimeLyric).toBeUndefined();
|
|
1068
|
-
|
|
1069
|
-
// 4. Find last lyric when timestamp is after last entry
|
|
1070
|
-
const lateTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 50000);
|
|
1071
|
-
expect(lateTimeLyric?.text).toBe('And I will try to fix you');
|
|
1072
|
-
});
|
|
1073
|
-
|
|
1074
|
-
it('Cpu process schedules', () => {
|
|
1075
|
-
class Process {
|
|
1076
|
-
constructor(
|
|
1077
|
-
public id: number,
|
|
1078
|
-
public priority: number
|
|
1079
|
-
) {}
|
|
1080
|
-
|
|
1081
|
-
execute(): string {
|
|
1082
|
-
return `Process ${this.id} executed.`;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
class Scheduler {
|
|
1087
|
-
private queue: DoublyLinkedList<Process>;
|
|
1088
|
-
|
|
1089
|
-
constructor() {
|
|
1090
|
-
this.queue = new DoublyLinkedList<Process>();
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
addProcess(process: Process): void {
|
|
1094
|
-
// Insert processes into a queue based on priority, keeping priority in descending order
|
|
1095
|
-
let current = this.queue.head;
|
|
1096
|
-
while (current && current.value.priority >= process.priority) {
|
|
1097
|
-
current = current.next;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
if (!current) {
|
|
1101
|
-
this.queue.push(process);
|
|
1102
|
-
} else {
|
|
1103
|
-
this.queue.addBefore(current, process);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
executeNext(): string | undefined {
|
|
1108
|
-
// Execute tasks at the head of the queue in order
|
|
1109
|
-
const process = this.queue.shift();
|
|
1110
|
-
return process ? process.execute() : undefined;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
listProcesses(): string[] {
|
|
1114
|
-
return this.queue.toArray().map(process => `Process ${process.id} (Priority: ${process.priority})`);
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
clear(): void {
|
|
1118
|
-
this.queue.clear();
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
// should add processes based on priority
|
|
1123
|
-
let scheduler = new Scheduler();
|
|
1124
|
-
scheduler.addProcess(new Process(1, 10));
|
|
1125
|
-
scheduler.addProcess(new Process(2, 20));
|
|
1126
|
-
scheduler.addProcess(new Process(3, 15));
|
|
1127
|
-
|
|
1128
|
-
expect(scheduler.listProcesses()).toEqual([
|
|
1129
|
-
'Process 2 (Priority: 20)',
|
|
1130
|
-
'Process 3 (Priority: 15)',
|
|
1131
|
-
'Process 1 (Priority: 10)'
|
|
1132
|
-
]);
|
|
1133
|
-
|
|
1134
|
-
// should execute the highest priority process
|
|
1135
|
-
scheduler = new Scheduler();
|
|
1136
|
-
scheduler.addProcess(new Process(1, 10));
|
|
1137
|
-
scheduler.addProcess(new Process(2, 20));
|
|
1138
|
-
|
|
1139
|
-
expect(scheduler.executeNext()).toBe('Process 2 executed.');
|
|
1140
|
-
expect(scheduler.listProcesses()).toEqual(['Process 1 (Priority: 10)']);
|
|
1141
|
-
|
|
1142
|
-
// should clear all processes
|
|
1143
|
-
scheduler = new Scheduler();
|
|
1144
|
-
scheduler.addProcess(new Process(1, 10));
|
|
1145
|
-
scheduler.addProcess(new Process(2, 20));
|
|
1146
|
-
|
|
1147
|
-
scheduler.clear();
|
|
1148
|
-
expect(scheduler.listProcesses()).toEqual([]);
|
|
1149
|
-
});
|
|
1150
|
-
});
|