Michele De Stefano's C++ Utilities
indexing_example.cpp
1 // indexing_example.cpp
2 //
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
4 //
5 // Distributed under the MIT License (See accompanying file LICENSE)
6 
18 #include "indexing_example.hpp"
19 
20 using namespace std;
21 
22 namespace mdspy = mds_utils::python;
23 
24 
25 Dummy_Container::Dummy_Container() : m_v(9) {
26  m_v[0] = 1.1;
27  m_v[1] = 2.1;
28  m_v[2] = 3.1;
29  m_v[3] = 4.1;
30  m_v[4] = 5.1;
31  m_v[5] = 6.1;
32  m_v[6] = 7.1;
33  m_v[7] = 8.1;
34  m_v[8] = 9.1;
35 }
36 
37 size_t Dummy_Container::get_nel() const {
38  return m_v.size();
39 }
40 
41 double Dummy_Container::get_el_at(size_t i) const {
42  if (i >= m_v.size()) throw out_of_range("Index out of range");
43  return m_v[i];
44 }
45 
46 void Dummy_Container::set_el_at(size_t i,double val) {
47  if (i >= m_v.size()) throw out_of_range("Index out of range");
48  m_v[i] = val;
49 }
Namespace of all Michele De Stefano's C++ Python utilities.