Escript  Revision_4320
DataVector.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 
17 #if !defined escript_DataVector_20050324_H
18 #define escript_DataVector_20050324_H
19 #include "system_dep.h"
20 
21 #include "esysUtils/EsysAssert.h"
22 
23 #include <vector>
24 #include <iostream>
25 #include <fstream>
26 
27 namespace escript {
28 
29 class WrappedArray;
30 
44 
45  public:
46 
47  //
48  // The type of the elements stored in the vector.
49  typedef double ElementType;
50 
51  //
52  // The underlying type used to implement the vector.
54  typedef const ElementType * ConstValueType;
55 
56  //
57  // Various types exported to clients of this class.
59  typedef long size_type;
61  typedef const ElementType & const_reference;
62 
70  DataVector();
71 
80  DataVector(const DataVector& other);
81 
100  DataVector(const size_type size,
101  const value_type val=0.0,
102  const size_type blockSize=1);
103 
111  ~DataVector();
112 
123  void
124  resize(const size_type newSize,
125  const value_type newVal=0.0,
126  const size_type newBlockSize=1);
127 
134  void
135  copyFromArray(const escript::WrappedArray& value, size_type copies);
136 
137  void
138  copyFromArrayToOffset(const WrappedArray& value, size_type offset, size_type copies);
139 
140 
145  inline
146  size_type
147  size() const;
148 
154  DataVector&
155  operator=(const DataVector& other);
156 
162  bool
163  operator==(const DataVector& other) const;
164 
170  bool
171  operator!=(const DataVector& other) const;
172 
181  inline
182  reference
183  operator[](const size_type i);
184 
185  inline
187  operator[](const size_type i) const;
188 
189 
190  protected:
191 
192  private:
193 
197 
198  //
199  // The container for the elements contained in this DataVector.
201 };
202 
209 
210 
211 
212 inline
215 {
216  return m_size;
217 }
218 
219 inline
222 {
223  EsysAssert(i<size(),"DataVector: invalid index specified. " << i << " of " << size());
224  return m_array_data[i];
225 }
226 
227 inline
230 {
231  EsysAssert(i<size(),"DataVector: invalid index specified. " << i << " of " << size());
232  return m_array_data[i];
233 }
234 
235 } // end of namespace
236 
237 #endif