File tree Expand file tree Collapse file tree 1 file changed +51
-3
lines changed
data-structures/Array/include Expand file tree Collapse file tree 1 file changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,62 @@ class String{
48
48
Vector<char > _data;
49
49
};
50
50
51
-
52
51
// Constructor and Desttructor
53
- String::String (){
52
+ String::String () : _data() {}
53
+
54
+ String::~String (){
54
55
55
56
}
56
57
57
- String::~String (){
58
+ // Capacity
59
+ bool String::empty () const {
60
+ return _data.empty ();
61
+ }
62
+
63
+ size_t String::size () const {
64
+ return _data.size ();
65
+ }
66
+
67
+ size_t String::length () const
68
+ {
69
+ return _data.size ();
70
+ }
71
+
72
+ size_t String::capacity () const {
73
+ return _data.capacity ();
74
+ }
75
+
76
+ void String::reserve (const size_t n){
77
+ _data.reserve (n);
78
+ }
79
+
80
+ void String::resize (size_t n){
81
+ _data.resize (n);
82
+ }
83
+
84
+ void String::clear (){
85
+ _data.clear ();
86
+ }
87
+
88
+ void String::shrink_to_fit (){
89
+ _data.shrink_to_fit ();
90
+ }
91
+
92
+ // Elements access
93
+ char & String::front (){
94
+ return _data.front ();
95
+ }
96
+
97
+ char & String::back (){
98
+ return _data.back ();
99
+ }
100
+
101
+ char & String::at (const size_t index){
102
+ return _data.at (index);
103
+ }
58
104
105
+ char & String::operator [](const size_t index){
106
+ return _data[index];
59
107
}
60
108
61
109
#endif // STRING_H
You can’t perform that action at this time.
0 commit comments