Skip to content

Commit

Permalink
Update at Friday, October 11, 2024 PM05:14:09 HKT
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdove committed Oct 11, 2024
1 parent d73ec77 commit 8f5c3b9
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions data-structures/Array/include/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,62 @@ class String{
Vector<char> _data;
};


// Constructor and Desttructor
String::String(){
String::String() : _data() {}

String::~String(){

}

String::~String(){
// Capacity
bool String::empty() const{
return _data.empty();
}

size_t String::size() const{
return _data.size();
}

size_t String::length() const
{
return _data.size();
}

size_t String::capacity() const{
return _data.capacity();
}

void String::reserve(const size_t n){
_data.reserve(n);
}

void String::resize(size_t n){
_data.resize(n);
}

void String::clear(){
_data.clear();
}

void String::shrink_to_fit(){
_data.shrink_to_fit();
}

// Elements access
char& String::front(){
return _data.front();
}

char& String::back(){
return _data.back();
}

char& String::at(const size_t index){
return _data.at(index);
}

char& String::operator[](const size_t index){
return _data[index];
}

#endif // STRING_H

0 comments on commit 8f5c3b9

Please sign in to comment.