-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/vector #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Create License
Pull Request Test Coverage Report for Build 30
💛 - Coveralls |
TusharChugh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added suggestions to improve the code
include/vector/Vector.h
Outdated
| #include <list> | ||
| #include <memory> | ||
| /* | ||
| template< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments
include/vector/Vector.h
Outdated
| // constructor, and deconstruct, copy constructor, move constructor | ||
| //vector | ||
| explicit Vector(); | ||
| explicit Vector(size_t count, const T &value); // assign value into the "count" elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add default values to the constructor
include/vector/Vector.h
Outdated
| // what we want to achieve? | ||
| // constructor, and deconstruct, copy constructor, move constructor | ||
| //vector | ||
| explicit Vector(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this default constructor after adding default value to the other
include/vector/Vector.h
Outdated
| const Vector_iterator end() const noexcept{ | ||
| return Vector_iterator(this, _count); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add const iterators
include/vector/Vector.h
Outdated
| Vector_iterator(const Vector_iterator&); //Vector_iterator(p), use the Vector_iterator to initialize this iterator | ||
| Vector_iterator(const Vector<T>*, size_t index); //Vector_iterator(p, size_t index), p---> move 'index' position; | ||
|
|
||
| // iterator behavior, TDD, to think it thoroughly before writing the member functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these comments
include/vector/Vector.h
Outdated
| // constructor for iterator, fot tdd | ||
| Vector_iterator(); | ||
| Vector_iterator(const Vector_iterator&); //Vector_iterator(p), use the Vector_iterator to initialize this iterator | ||
| Vector_iterator(const Vector<T>*, size_t index); //Vector_iterator(p, size_t index), p---> move 'index' position; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add default value to the index
include/vector/Vector.h
Outdated
| // } | ||
| // }; | ||
| template<class T> | ||
| Vector<T>::Vector():_count(0),_capacity(0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove magic numbers from the code
include/vector/Vector.h
Outdated
| } | ||
|
|
||
|
|
||
| //Implementation: copy constructor and assignment operator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove code which is not useful
include/vector/Vector.h
Outdated
| reserve(other._capacity); | ||
| for (auto index = 0; index != other.size(); ++index) { | ||
| _elements[index] = other._elements[index]; | ||
| _count++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pre-increment operator
| @@ -0,0 +1,139 @@ | |||
| #include"vector/Vector.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move different kind of test cases in different files. Use setup and tear down from gtest https://github.com/google/googletest/blob/master/googletest/docs/primer.md
|
Merged vector |
Add the vector implemention