File tree 6 files changed +18
-19
lines changed
6 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ ArrayList::ArrayList(const ArrayList &arrayToCopy)
28
28
ArrayList::ArrayList (ArrayList&& arrayToMove)
29
29
{
30
30
std::cout << " Arraylist move constructor is called." << std::endl;
31
- this ->capacity = arrayToMove.capacity ;
32
- this ->used = arrayToMove.used ;
33
- this ->pArray = arrayToMove.pArray ;
31
+ this ->capacity = arrayToMove.getCapacity () ;
32
+ this ->used = arrayToMove.size () ;
33
+ this ->pArray = arrayToMove.getPArray () ;
34
34
arrayToMove.capacity = 0 ;
35
35
arrayToMove.used = 0 ;
36
36
arrayToMove.pArray = nullptr ;
@@ -63,9 +63,9 @@ ArrayList& ArrayList::operator=(ArrayList &&rhs)
63
63
if (&rhs != this )
64
64
{
65
65
delete[] this ->pArray ;
66
- this ->capacity = rhs.capacity ;
67
- this ->used = rhs.used ;
68
- this ->pArray = rhs.pArray ;
66
+ this ->capacity = rhs.getCapacity () ;
67
+ this ->used = rhs.size () ;
68
+ this ->pArray = rhs.getPArray () ;
69
69
rhs.capacity = 0 ;
70
70
rhs.used = 0 ;
71
71
rhs.pArray = nullptr ;
Original file line number Diff line number Diff line change @@ -42,12 +42,11 @@ Token::Token(const Token& token)
42
42
Token::Token (Token&& token)
43
43
{
44
44
std::cout << " Token move constructor is called." << std::endl;
45
- this ->cstr = token.cstr ;
46
- this ->frequency = token.frequency ;
47
- this ->number_list = token.number_list ;
45
+ this ->cstr = token.c_str () ;
46
+ this ->number_list = std::move ( token.number_list ) ;
47
+ this ->frequency = token.getFrequency () ;
48
48
token.cstr = nullptr ;
49
49
token.frequency = 0 ;
50
- // token.number_list = nullptr; --> why is this not working?
51
50
}
52
51
53
52
// copy assignment operator
@@ -77,9 +76,9 @@ Token& Token::operator=(Token &&rhs)
77
76
if (&rhs != this )
78
77
{
79
78
delete[] this ->cstr ;
80
- this ->frequency = rhs.frequency ;
81
- this ->number_list = rhs.number_list ;
82
- this ->cstr = rhs.cstr ;
79
+ this ->frequency = rhs.getFrequency () ;
80
+ this ->number_list = std::move ( rhs.number_list ) ;
81
+ this ->cstr = rhs.c_str () ;
83
82
rhs.cstr = nullptr ;
84
83
rhs.frequency = 0 ;
85
84
}
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ class Token
14
14
15
15
public:
16
16
// constructors
17
- Token (); // default constructor
18
- Token (const char * chars, int line_num); // normal constructor
19
- Token (const Token& token); // copy constructor
20
- Token (Token&& token); // move constructor
17
+ Token (); // default constructor
18
+ explicit Token (const char * chars, int line_num); // normal constructor
19
+ Token (const Token& token); // copy constructor
20
+ Token (Token&& token); // move constructor
21
21
22
22
// assignment operators
23
23
Token& operator =(const Token& rhs); // copy assignment operator
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class TokenList {
26
26
private:
27
27
TNode* head{ nullptr }; // points to the first node in the list
28
28
TNode* tail{ nullptr }; // points to the last node in the list
29
- size_t size{ 0 }; // counts the number of noded in the list
29
+ size_t size{ 0 }; // counts the number of nodes in the list
30
30
31
31
bool remove (TNode* nodePtr);
32
32
TNode* lookup (const Token& aToken) const ;
@@ -42,7 +42,7 @@ class TokenList {
42
42
TokenList& operator =(const TokenList& rhs); // copy assignment operator
43
43
TokenList& operator =(TokenList&& rhs); // move assignment operator
44
44
45
- ~TokenList ();
45
+ ~TokenList (); // destructor
46
46
47
47
// member functions
48
48
bool empty () const ;
You can’t perform that action at this time.
0 commit comments