Skip to content

Commit e69fb2c

Browse files
committed
refactored constructors and destructors
1 parent f59bdce commit e69fb2c

3 files changed

Lines changed: 56 additions & 14 deletions

File tree

DSDoublyLL/dsdoublyll.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ class DSDoublyLL{
206206
* @brief DSDoublyLL - default constructor
207207
*/
208208
template <class T>
209-
DSDoublyLL<T>::DSDoublyLL(){
210-
211-
}
209+
DSDoublyLL<T>::DSDoublyLL(){}
212210

213211
/**
214212
* @brief DSDoublyLL - constructor

DSDoublyLL/dsnode.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ class DSNode{
2020
*/
2121
DSNode(T data);
2222

23+
/**
24+
* @brief DSNode - copy consructor
25+
* @param other - node to copy
26+
*/
27+
DSNode(DSNode<T>& other);
28+
2329
/**
2430
* @brief operator =
2531
* @param data - new data to replace current
@@ -41,10 +47,19 @@ DSNode<T>::DSNode(){
4147

4248
}
4349

50+
/**
51+
* @brief DSNode::DSNode - constrcutor
52+
* @param data - data of the new node
53+
*/
4454
template <class T>
45-
DSNode<T>::DSNode(T data){
46-
this->data = data;
47-
}
55+
DSNode<T>::DSNode(T data) : data(data){}
56+
57+
/**
58+
* @brief DSNode::DSNode - copy constructor
59+
* @param other - node to be copied
60+
*/
61+
template <class T>
62+
DSNode<T>::DSNode(DSNode<T>& other) : data(other.data){}
4863

4964
/**
5065
* @brief operator =

DSString/dsstring.h

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,54 @@ class DSString
6868
};
6969

7070
public:
71-
// default constructor
71+
/**
72+
* @brief DSString - default constructor
73+
*/
7274
DSString();
73-
// constructor - paramaters: const char* otherData
75+
76+
/**
77+
* @brief DSString - constructor
78+
* @param data - c-string to turn into string
79+
*/
7480
DSString(const char* data);
75-
// constructor - paramaters: const DSString& otherData
81+
82+
/**
83+
* @brief DSString - copy constructor
84+
* @param other - string to copy
85+
*/
7686
DSString(const DSString& other);
7787

78-
// returns the location of the passed char - parameters: const char searchChar
88+
/**
89+
* @brief findChar - find the first instance of a character in string
90+
* @param searchChar - character to find
91+
* @return
92+
*/
7993
int findChar(const char searchChar) const;
80-
// returns the location of the numInstance instance of the passed char - parameters: const char searchChar, const int numInstance
94+
95+
/**
96+
* @brief findChar - finds the location of the numInstance instance of the passed char
97+
* @param searchChar - character to search for
98+
* @param numInstance - n'th instance to search for
99+
* @return index of found char
100+
*/
81101
int findChar(const char searchChar, const int numInstance) const;
82102

83-
// removes a char from the given index
103+
/**
104+
* @brief deleteIndex - removes character from given index
105+
* @param index - index in which to remove
106+
*/
84107
void deleteIndex(const int index);
85108

86-
// default destructor
109+
/**
110+
* @brief ~DSString - Default destructor
111+
*/
87112
~DSString();
88113

89-
// assignment operator - params: const char* data
114+
/**
115+
* @brief operator = : assignment operator
116+
* @param data - character array to set this equal to
117+
* @return
118+
*/
90119
DSString& operator=(const char* data);
91120
// assignment operator - params: const DSString& other
92121
DSString& operator=(const DSString& other);

0 commit comments

Comments
 (0)