-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSString.h
More file actions
40 lines (33 loc) · 982 Bytes
/
SString.h
File metadata and controls
40 lines (33 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
*功能:这个是定长的串的顺序存储
*时间:2015年7月15日17:16:01
*文件:SString.h
*作者:cutter_point
*/
#ifndef SSTRING_H
#define SSTRING_H
#define MAXSTRLEN 255
class SString
{
unsigned char* ch; //我们的串的顺序存储空间
unsigned int length; //我们有效元素的个数
public:
SString(){}
SString(unsigned char c[], int lenth){ ch = new unsigned char[MAXSTRLEN + 1]; ch = c; this->length = lenth; } //申请堆存储空间
//一个匹配子串的算法实现
/************************************************************************/
/*
返回子串T在主串S中第pos位置之后的位置,若不存在,返回0
*/
/************************************************************************/
int BFindex(SString T, int pos);
//得到这个字符串的长度
unsigned int getLength();
unsigned char* getCh();
//设置相应的值
void setCh(unsigned char *c) { ch = c; }
void setLength(unsigned int len) { length = len; }
//unsigned char* getCh() { return ch; }
//unsigned int getLength() { return length; }
};
#endif