Loading src/sphere/List.h +12 −13 Original line number Diff line number Diff line Loading @@ -41,19 +41,14 @@ template<class T> class List { * * b = List<int>(); */ List(int size = 1) { this->size = size; element* p_prev = NULL; T value = (T)0; current = new element; current->value = value; current->p_prev = p_prev; p_prev = current; first = current; List(int length = 1) { size = length; first = new element; first->p_prev = NULL; element *current = first; element *p_prev = first; for (int i = 1; i < size; i++) { T value; current = new element; current->value = value; current->p_prev = p_prev; p_prev = current; } Loading Loading @@ -107,6 +102,10 @@ template<class T> class List { return current->value; } int length() { return size; } /*! \fn set(int, T) * \brief Set an element by index and value. * Loading Loading @@ -141,8 +140,8 @@ template<class T> class List { T* to_array() { T *result = new T[size]; current = last; for (int i = size - 1; i > 0; i--) { result[i] = current->value; for (int i = size; i > 0; i--) { result[i - 1] = current->value; current = current->p_prev; } return result; Loading Loading
src/sphere/List.h +12 −13 Original line number Diff line number Diff line Loading @@ -41,19 +41,14 @@ template<class T> class List { * * b = List<int>(); */ List(int size = 1) { this->size = size; element* p_prev = NULL; T value = (T)0; current = new element; current->value = value; current->p_prev = p_prev; p_prev = current; first = current; List(int length = 1) { size = length; first = new element; first->p_prev = NULL; element *current = first; element *p_prev = first; for (int i = 1; i < size; i++) { T value; current = new element; current->value = value; current->p_prev = p_prev; p_prev = current; } Loading Loading @@ -107,6 +102,10 @@ template<class T> class List { return current->value; } int length() { return size; } /*! \fn set(int, T) * \brief Set an element by index and value. * Loading Loading @@ -141,8 +140,8 @@ template<class T> class List { T* to_array() { T *result = new T[size]; current = last; for (int i = size - 1; i > 0; i--) { result[i] = current->value; for (int i = size; i > 0; i--) { result[i - 1] = current->value; current = current->p_prev; } return result; Loading