Skip to content
Snippets Groups Projects
Commit 7b47bc2e authored by Nina Džugasová's avatar Nina Džugasová Committed by Tomáš Oberhuber
Browse files

Added VectorExample.

parent 2ed350c4
No related branches found
No related tags found
1 merge request!19Nina
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
using namespace TNL; using namespace TNL;
using namespace std; using namespace std;
int main() int main()
{ {
Containers::Array<int> array1; Containers::Array<int> array1;
...@@ -21,7 +21,7 @@ int main() ...@@ -21,7 +21,7 @@ int main()
cout << "Second array:" << array2.getData() << endl; cout << "Second array:" << array2.getData() << endl;
array2.reset(); array2.reset();
cout << "2.array after reset:" << array2.getData() << endl; cout << "Second array after reset:" << array2.getData() << endl;
// bind // bind
} }
#include <iostream>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Array.h>
using namespace TNL;
using namespace std;
int main()
{
Containers::Vector<int> vector1;
vector1.setSize(5);
vector1.setValue(0);
cout << "Does vector contain 1?" << vector1.containsValue(1); << endl;
cout << "Does vector contain only zeros?" << vector1.containsOnlyValue(0); << endl;
Containers::Vector<int> vector2(3);
vector2.setValue(1);
vector2.swap(vector1);
vector2.setElement(2,4);
cout << "First vector:" << vector1.getData() << endl;
cout << "Second vector:" << vector2.getData() << endl;
vector2.reset();
cout << "Second vector after reset:" << vector2.getData() << endl;
}
...@@ -17,6 +17,9 @@ namespace Containers { ...@@ -17,6 +17,9 @@ namespace Containers {
/** /**
* \brief Class for storing vector elements and handling vector operations. * \brief Class for storing vector elements and handling vector operations.
*
* \par Example
* \include VectorExample.cpp
*/ */
template< typename Real = double, template< typename Real = double,
typename Device = Devices::Host, typename Device = Devices::Host,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment