Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Algorithm.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
20
21#pragma once
22#include <cstddef>
23#include <cstdint>
24#include <vector>
25
26namespace sstr {
27
28struct SChar;
29
30typedef int (*FindFunction)(const char *, const char *);
31
32extern int KMP(const char *str, const char *sub);
33
34extern int BM(const char *str, const char *sub);
35
36extern int BM(const uint32_t *str, size_t size, std::vector<SChar> &sub);
37
38extern int NORMAL(const char *str, const char *sub);
39
40// GCOVR_EXCL_START
41
49template<typename T>
50inline void LeftShiftElement(T *header, size_t len, size_t begin, size_t count) {
51 for (size_t i = 0; i < len - begin; i++) {
52 header[begin + i] = header[begin + count + i];
53 }
54}
55
63template<typename T>
64inline void RightShiftElement(T *header, size_t len, size_t begin, size_t count) {
65 for (size_t i = 0; i < len - begin; i++) {
66 header[len - 1 + count - i] = header[len - 1 - i];
67 }
68}
69
70// GCOVR_EXCL_STOP
71
72} // namespace sstr