Skip to content

Conversation

@qizhangncs
Copy link
Collaborator

Add the vector implemention

@coveralls
Copy link

coveralls commented Nov 8, 2018

Pull Request Test Coverage Report for Build 30

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-2.8%) to 95.238%

Files with Coverage Reduction New Missed Lines %
cplusplus-containers/include/bst/Bst.h 3 97.92%
Totals Coverage Status
Change from base Build 28: -2.8%
Covered Lines: 240
Relevant Lines: 252

💛 - Coveralls

Copy link
Owner

@TusharChugh TusharChugh left a 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 <list>
#include <memory>
/*
template<
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

// constructor, and deconstruct, copy constructor, move constructor
//vector
explicit Vector();
explicit Vector(size_t count, const T &value); // assign value into the "count" elements
Copy link
Owner

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

// what we want to achieve?
// constructor, and deconstruct, copy constructor, move constructor
//vector
explicit Vector();
Copy link
Owner

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

const Vector_iterator end() const noexcept{
return Vector_iterator(this, _count);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add const iterators

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these comments

// 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;
Copy link
Owner

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

// }
// };
template<class T>
Vector<T>::Vector():_count(0),_capacity(0){
Copy link
Owner

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

}


//Implementation: copy constructor and assignment operator
Copy link
Owner

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

reserve(other._capacity);
for (auto index = 0; index != other.size(); ++index) {
_elements[index] = other._elements[index];
_count++;
Copy link
Owner

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"
Copy link
Owner

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

@TusharChugh
Copy link
Owner

Merged vector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants