SheafSystem  0.0.0.0
ragged_array.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class ragged_array
19 
20 #ifndef RAGGED_ARRAY_H
21 #define RAGGED_ARRAY_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef RC_ANY_H
28 #include "SheafSystem/rc_any.h"
29 #endif
30 
31 #ifndef RC_PTR_H
32 #include "SheafSystem/rc_ptr.h"
33 #endif
34 
35 #ifndef BLOCK_H
36 #include "SheafSystem/block.h"
37 #endif
38 
39 namespace sheaf
40 {
41 
42 template <typename T> class ragged_array;
43 
48 template<typename T>
49 size_t deep_size(const ragged_array<T>& xra, bool xinclude_shallow = true);
50 
54 template <typename T>
55 class SHEAF_DLL_SPEC ragged_array : public rc_any
56 {
57 
58  friend size_t deep_size<T>(const ragged_array<T>& xra, bool xinclude_shallow);
59 
60  // ===========================================================
62  // ===========================================================
64 
65 public:
66 
70  typedef unsigned long index_type;
71 
72 
77 
82  ragged_array(size_t xct = 0);
83 
87  ragged_array(const ragged_array& xother);
88 
93  ragged_array(const index_type* xcol_cts,
94  index_type xcol_cts_ub);
95 
100  ragged_array(const index_type xrow_ct, const index_type xvalue_ct);
101 
105  virtual ~ragged_array();
106 
110  ragged_array& operator=(const ragged_array& xother);
111 
115  virtual bool operator==(const ragged_array& xother) const;
116 
120  index_type row_ct() const;
121 
125  index_type col_ct(const index_type xrow_index) const;
126 
130  index_type* col_cts() const;
131 
135  T* values() const;
136 
140  index_type value_ct() const;
141 
145  T* row(const index_type xrow_index) const;
146 
150  T* operator[](const index_type xrow_index) const;
151 
155  void reset_rows();
156 
160  void reset_rows(const index_type* xcol_cts, const index_type xcol_cts_ub);
161 
165  index_type sum_col_cts() const;
166 
170  index_type sum_col_cts(const index_type* xcol_cts, const index_type xcol_cts_ub) const;
171 
176  void initialize_push_back(index_type xrow_ct, index_type xvalue_ct);
177 
181  index_type back_row() const;
182 
186  void new_back_row();
187 
191  void push_back(const T& xvalue);
192 
193 protected:
194 
199  void initialize(const index_type* xcol_cts,
200  index_type xcol_cts_ub);
201 
202 
207 
212 
217 
218 private:
219 
221 
222 
223  // ===========================================================
225  // ===========================================================
227 
228 public:
229 
235  virtual ragged_array* clone() const;
236 
240  virtual bool invariant() const;
241 
245  virtual bool is_ancestor_of(const any* xother) const;
246 
247 protected:
248 
249 private:
250 
252 };
253 
254 // ===========================================================
255 // NON-MEMBER FUNCTIONS
256 // ===========================================================
257 
261 template <typename T>
262 std::ostream& operator << (std::ostream& xos, const ragged_array<T>& xra);
263 
264 } // namespace sheaf
265 
266 #endif // ifndef RAGGED_ARRAY_H
267 
268 
269 
270 
271 
272 
Abstract base class with useful features for all objects.
Definition: any.h:39
block< index_type > _col_cts
The number of columns in each row.
Definition: ragged_array.h:211
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
block< T > _values
The values stored in the array.
Definition: ragged_array.h:206
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
block< index_type > _row_ptrs
Index of the first value in each row.
Definition: ragged_array.h:216
Namespace for the sheaves component of the sheaf system.
rc_ptr< ragged_array< T > > ptr
Reference counted pointer type.
Definition: ragged_array.h:76
A two index array with variable length rows.
unsigned long index_type
The integer type used to index this.
Definition: ragged_array.h:70
An auto_block with a no-initialization initialization policy.
Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any...
Definition: factory_2.h:47