Add a constructor to Vector.h. Test class GraphMatrix, all tests passed. Dfs and Bfs remained to be done.
This commit is contained in:
@@ -34,6 +34,7 @@ public:
|
||||
//constructors
|
||||
Vector();
|
||||
Vector(int capacity);
|
||||
Vector(int size, T const &value);
|
||||
Vector(T* const A, int n) { copyfrom(A, 0, n); }
|
||||
Vector(T* const A, int lo, int hi) { copyfrom(A, lo, hi); }
|
||||
Vector(Vector<T> const &V) { copyfrom(V._elem, 0, V._size); }
|
||||
@@ -149,6 +150,15 @@ Vector<T>::Vector(int capacity) {
|
||||
_elem = new T[_capacity];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Vector<T>::Vector(int size, T const &value){
|
||||
_capacity = size << 1;
|
||||
_size = size;
|
||||
_elem = new T[_capacity];
|
||||
for (int ix = 0; ix != _size; ++ix)
|
||||
_elem[ix] = value;
|
||||
}
|
||||
|
||||
//read-only interfaces
|
||||
template<typename T>
|
||||
void Vector<T>::print() {
|
||||
|
||||
Reference in New Issue
Block a user