You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move assignment operator, makes left value same as right value by harvesting its resources
64
-
@param other the assigned-from VectorString
65
-
@return the updated assigned-to VectorString
66
-
*/
63
+
Move assignment operator, makes left value same as right value by harvesting its resources
64
+
@param other the assigned-from VectorString
65
+
@return the updated assigned-to VectorString
66
+
*/
67
67
VectorString& operator=(VectorString&& other);
68
68
69
69
/**
70
-
Checks if the container has no elements, i.e. whether begin() == end()
71
-
@return true if the container is empty, false otherwise
72
-
*/
70
+
Checks if the container has no elements, i.e. whether begin() == end()
71
+
@return true if the container is empty, false otherwise
72
+
*/
73
73
boolempty() const;
74
74
75
75
/**
76
-
Size member function, returns the size of the vector
77
-
@return size of the vector
78
-
*/
76
+
Size member function, returns the size of the vector
77
+
@return size of the vector
78
+
*/
79
79
size_type size() const;
80
80
81
81
/**
82
-
Capacity member function, returns the capacity of the vector
83
-
@return capacity of the vector
84
-
*/
82
+
Capacity member function, returns the capacity of the vector
83
+
@return capacity of the vector
84
+
*/
85
85
size_type capacity() const;
86
86
87
87
/**
88
88
Reserve member function, increases the capacity of the vector to a value that's greater or equal to new_cap. If new_cap is greater than the current capacity(), new storage is allocated, otherwise the method does nothing.
89
-
@param new_cap new capacity inputted
90
-
*/
89
+
@param new_cap new capacity inputted
90
+
*/
91
91
voidreserve(size_type new_cap);
92
92
93
93
/**
94
94
Push Back member function, adds an element to the end of the vector if the capacity allows. Otherwise creates a new dynamic array of twice the former capacity - moving all the elements over and adding the new element.
95
-
@param value is the string value
96
-
*/
95
+
@param value is the string value
96
+
*/
97
97
voidpush_back(const std::string& value);
98
-
98
+
99
99
/**
100
-
Pop Back member function, removes the last element of the vector by updating the size of the vector
101
-
*/
100
+
Pop Back member function, removes the last element of the vector by updating the size of the vector
101
+
*/
102
102
voidpop_back();
103
103
104
104
/**
105
-
DeleteAt member function: accepts an index value that removes the element at the given index and shifts all elements backwards.
106
-
@param pos is the position at which the string value should be deleted
105
+
DeleteAt member function: accepts an index value that removes the element at the given index and shifts all elements backwards.
106
+
@param pos is the position at which the string value should be deleted
107
107
*/
108
108
voiddeleteAt (size_type pos);
109
109
110
110
/**
111
-
InsertAt member function, adds an element to the pos of the vector if the capacity allows. Otherwise creates a new dynamic array of twice the former capacity - moving all the elements over and adding the new element at pos
112
-
@param pos is the position at which the value string should be inserted
113
-
@param value is the string value
114
-
*/
111
+
InsertAt member function, adds an element to the pos of the vector if the capacity allows. Otherwise creates a new dynamic array of twice the former capacity - moving all the elements over and adding the new element at pos
112
+
@param pos is the position at which the value string should be inserted
113
+
@param value is the string value
114
+
*/
115
115
voidinsertAt (size_type pos, std::string value);
116
116
117
117
/**
118
-
At member function: return by reference, the value at the position index
119
-
@param pos is the position at which the value of string is returned
120
-
@return value of the string at position pos
121
-
*/
118
+
At member function: return by reference, the value at the position index
119
+
@param pos is the position at which the value of string is returned
120
+
@return value of the string at position pos
121
+
*/
122
122
std::string& at(size_type pos);
123
123
124
124
/**
125
-
At member function overloaded on const: return by reference to const, the value at the position index
126
-
@param pos is the position at which the value of string is returned
127
-
@return value of the string at position pos
128
-
*/
125
+
At member function overloaded on const: return by reference to const, the value at the position index
126
+
@param pos is the position at which the value of string is returned
127
+
@return value of the string at position pos
128
+
*/
129
129
const std::string& at(size_type pos) const;
130
-
130
+
131
131
private:
132
-
132
+
133
133
size_type vec_size; // size of the vector
134
134
size_type vec_capacity; // capacity of the vector
135
135
std::unique_ptr<std::string[]> data_; // pointer to the dynamic array of string vector, defaulted to nullptr
0 commit comments