https://github.com/nir3x/fastpatternsscanner.cpp
FastPatternsScanner.cpp - Efficient Pattern Scanner for C++
https://github.com/nir3x/fastpatternsscanner.cpp
algorithm c-plus-plus cpp data-structures efficiency hashing pattern-scanning
Last synced: 3 months ago
JSON representation
FastPatternsScanner.cpp - Efficient Pattern Scanner for C++
- Host: GitHub
- URL: https://github.com/nir3x/fastpatternsscanner.cpp
- Owner: NIR3X
- License: agpl-3.0
- Created: 2024-02-12T09:33:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-16T06:19:19.000Z (over 1 year ago)
- Last Synced: 2024-02-17T04:36:30.423Z (over 1 year ago)
- Topics: algorithm, c-plus-plus, cpp, data-structures, efficiency, hashing, pattern-scanning
- Language: C++
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastPatternsScanner.cpp - Efficient Pattern Scanner for C++
FastPatternsScanner.cpp is a C++ implementation of a fast pattern scanner. It includes a class `CFastPatternsScanner` that allows efficient searching for patterns in data.
## Installation
To use this package, you can clone the repository and compile it using a C++ compiler:
```bash
git clone https://github.com/NIR3X/FastPatternsScanner.cpp
cd FastPatternsScanner.cpp
make
```## Usage
To use the `CFastPatternsScanner` class, follow these steps:
1. Include the `FastPatternsScanner.h` header file in your C++ project.
2. Create a `std::unordered_set>` containing the patterns you want to search for.
3. Instantiate a `CFastPatternsScanner` object with the patterns.
4. Use the `ContainsAny` method to search for patterns in your data.Example usage:
```cpp
#include "FastPatternsScanner.h"
#include
#includeint main() {
std::vector> patternsList = { {1}, {1, 2}, {1, 2, 3}, {48} };CFastPatternsScanner fastPatternsScanner({ patternsList.begin(), patternsList.end() });
assert(fastPatternsScanner.ContainsAny(std::vector {4, 1, 5, 6, 7}) == patternsList[0]);
assert(fastPatternsScanner.ContainsAny(std::vector {4, 5, 1, 2, 6}) == patternsList[1]);
assert(fastPatternsScanner.ContainsAny(std::vector {4, 5, 1, 2, 3}) == patternsList[2]);
assert(fastPatternsScanner.ContainsAny("9876543210") == patternsList[3]);std::cout << "PASS" << std::endl;
}
```## Efficiency
The search complexity of `CFastPatternsScanner` is O(n*m), where n is the length of the data and m is the length of the longest pattern. This represents the maximum complexity of the algorithm in the worst case scenario.
## License
[](https://www.gnu.org/licenses/agpl-3.0.html)
This program is Free Software: You can use, study share and improve it at your
will. Specifically you can redistribute and/or modify it under the terms of the
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html) as
published by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.