Skip to content

Commit

Permalink
Update some contents of String.h
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdove committed Oct 1, 2024
1 parent 6ea08b2 commit 7f1f77d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion data-structures/Array/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 数组

## 静态数组

![数组](./assets/array.png)

![Vector](./assets/vector.png)
## 动态数组

![Vector](./assets/vector.png)

## 字符串
1 change: 1 addition & 0 deletions data-structures/Array/__test__/test_Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <iostream>
#include "../include/Array.h"
#include "../include/Vector.h"
#include "../include/String.h"

void test_array(){
std::cout << "*****Array Test Begin*****" << std::endl;
Expand Down
20 changes: 20 additions & 0 deletions data-structures/Array/include/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@
class String{
public:
String();
String(const String& str);
String(const String& str, size_t pos, size_t len);
String(const char* s);
String(size_t n, const char c);
String& operator=(const String& str);
String& operator=(const char* s);
String& operator=(char c);
~String();
public:
// Capacity
bool empty() const;
size_t size() const;
size_t length() const;
size_t capacity() const;
void reserve(const size_t n);
void resize(size_t n);
void clear();
void shrink_to_fit();
Expand All @@ -24,6 +33,17 @@ class String{
String& operator+=(const String& str);
String& operator+=(const char *s);
String& operator+=(const char c);
String& append (const String& str);
String& append (const String& str, const size_t subpos, const size_t sublen);
String& append (const char* s);
String& append (const char* s, const size_t n);
String& append (const size_t n, const char c);
void push_back (const char c);
String& insert (const size_t pos, const String& str);
String& insert (const size_t pos, const String& str, const size_t subpos, const size_t sublen);
String& insert (const size_t pos, const char* s);
String& insert (const size_t pos, const char c);
String& insert (const size_t pos, const size_t n, const char c);
private:
Vector<char> _data;
};
Expand Down

0 comments on commit 7f1f77d

Please sign in to comment.