-
Notifications
You must be signed in to change notification settings - Fork 0
/
alphabet.cpp
96 lines (69 loc) · 1.45 KB
/
alphabet.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* This is alphabet.cpp
*
*
*
*/
#include "alphabet.h"
#include <iostream>
alphabet :: alphabet(){
alphaSymbols.reset();
}
alphabet::alphabet (char * temp){
for(int i = 0; temp[i]!= '\0'; i++){
alphaSymbols.set(int(temp[i]));
}
}
bool alphabet::setAlphaSymbols (char * temp){
for(int i = 0; temp[i]!= '\0'; i++){
alphaSymbols.set(int(temp[i]));
}
return true;
}
bool alphabet::setAlphaSymbol (int my_index){
alphaSymbols.set(my_index);
return true;
}
alphabet alphabet::operator * (alphabet beta){
alphabet temp;
temp.alphaSymbols = alphaSymbols &= beta.alphaSymbols;
return temp;
}
alphabet alphabet:: operator + (alphabet beta){
alphabet temp;
temp.alphaSymbols = alphaSymbols |= beta.alphaSymbols;
return temp;
}
alphabet alphabet:: operator - (alphabet beta){
alphabet temp;
temp.alphaSymbols = alphaSymbols ^= beta.alphaSymbols;
return temp;
}
bool alphabet::isMember(int i){
if (alphaSymbols[i])
return true;
else
return false;
}
bool alphabet::isMember(char i){
if (alphaSymbols[int(i)])
return true;
else
return false;
}
void alphabet::disp () {
for (int i = 0 ; i < alphaSymbols.size(); i++)
cout<<alphaSymbols[i];
cout<<endl;
}
ostream& operator << (ostream& s, alphabet& a){
for(int i = 0 ; i < a.alphaSymbols.size(); i++){
if ( a.alphaSymbols[i])
s << char(i);
}
return s;
}
istream& operator >> (istream& s, alphabet& a){
s >> a.alphaSymbols;
return s;
}