| 570 | |
| 571 | template<typename T> |
| 572 | const std::string Array<T>::toString() const |
| 573 | { |
| 574 | try |
| 575 | { |
| 576 | // Initial value |
| 577 | std::string string{"Array<T>::toString():\n"}; |
| 578 | // Add each element |
| 579 | for (auto i = 0u ; i < mVolume ; i++) |
| 580 | { |
| 581 | // Adding element separated by a space |
| 582 | string += std::to_string(pData[i]) + " "; |
| 583 | // Introduce an enter for each dimension change |
| 584 | // If comented, all values will be printed in the same line |
| 585 | auto multiplier = 1; |
| 586 | for (auto dimension = (int)(mSize.size() - 1u) ; dimension > 0 |
| 587 | && (int(i/multiplier) % getSize(dimension) == getSize(dimension)-1) ; dimension--) |
| 588 | { |
| 589 | string += "\n"; |
| 590 | multiplier *= getSize(dimension); |
| 591 | } |
| 592 | } |
| 593 | // Return string |
| 594 | return string; |
| 595 | } |
| 596 | catch (const std::exception& e) |
| 597 | { |
| 598 | error(e.what(), __LINE__, __FUNCTION__, __FILE__); |
| 599 | return ""; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | template<typename T> |
| 604 | int Array<T>::getIndex(const std::vector<int>& indexes) const |