SheafSystem  0.0.0.0
binary_index_block.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 binary_index_block
19 
20 #ifndef BINARY_INDEX_BLOCK_H
21 #define BINARY_INDEX_BLOCK_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef BLOCK_H
28 #include "SheafSystem/block.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
38 template <typename T>
39 class binary_index_block : public block<T>
40 {
41 
42 public:
43 
44  // ===========================================================
45  // ANY FACET
46  // ===========================================================
47 
52 
56  bool invariant() const;
57 
58  // ===========================================================
59  // BLOCK FACET
60  // ===========================================================
61 
62  using block<T>::push_back;
63 
67  void push_back(const binary_index_block& xother);
68 
69  // ===========================================================
70  // BINARY_INDEX_BLOCK FACET
71  // ===========================================================
72 
77  binary_index_block(int xi_ub = 0, int xj_ub = 0);
78 
84 
85 
90  binary_index_block(int xi_ub, int xi_ct, int xj_ub, int xj_ct, const T *xitems);
91 
96 
100  int i_ub() const;
101 
105  int j_ub() const;
106 
110  int i_ct() const;
111 
115  int j_ct() const;
116 
117  using block<T>::item;
118 
122  T& item(int xi, int xj);
123 
127  const T& item(int xi, int xj) const;
128 
137  T* operator [] (int xi) const;
138 
139  using block<T>::force_item;
140 
145  void force_item(int xi, int xj, const T& xitem);
146 
147  using block<T>::reserve;
148 
152  void reserve(int xi_ub, int xj_ub);
153 
154  using block<T>::set_ct;
155 
159  void set_ct(int xi_ct, int xj_ct);
160 
165  void put_item(int xi, int xj, const T& xitem);
166 
170  void assign(const T& xitem);
171 
172 protected:
173 
177  int _i_ub;
178 
182  int _j_ub;
183 
187  int _i_ct;
188 
192  int _j_ct;
193 
194 
195 };
196 
197 // ===========================================================
198 // NON-MEMBER FUNCTIONS
199 // ===========================================================
200 
204 template <class T>
205 std::ostream&
206 operator << (std::ostream& xos, const binary_index_block<T>& xblk);
207 
208 } // namespace sheaf
209 
210 
211 #endif // ifndef BINARY_INDEX_BLOCK_H
void put_item(int xi, int xj, const T &xitem)
Sets the item xitem at index xi, xj to xitem, but will not resize.
int i_ct() const
The number of i index values currently in use.
void push_back(const binary_index_block &xother)
Appends xother to the back of this.
T * operator[](int xi) const
The address of the first item in row xi. /.
void reserve(int xi_ub, int xj_ub)
Makes i_ub() at least xi_ub and j_ub() at least xj_ub.
int j_ub() const
The upper bound for the second index.
void assign(const T &xitem)
Sets the values of all items to xitem.
int j_ct() const
The number of j index values currently in use.
int _j_ub
The upper bound for the second index.
int _i_ub
The upper bound for the first index.
void set_ct(int xi_ct, int xj_ct)
Sets i_ct() == xi_ct and j_ct() == xj_ct.
A block which can be accessed using two indices, similarly to a two index array.
void force_item(int xi, int xj, const T &xitem)
Puts the item xitem at index xi,xj, resizing if necessary.
int _i_ct
The number of i index values currently in use.
int i_ub() const
The upper bound for the first index.
Namespace for the sheaves component of the sheaf system.
binary_index_block & operator=(const binary_index_block &xother)
Sets the contents of this to the contents of xother.
T & item(int xi, int xj)
The item at index xi, xj (mutable version).
An auto_block with a no-initialization initialization policy.
int _j_ct
The number of j index values currently in use.
binary_index_block(int xi_ub=0, int xj_ub=0)
Default constructor.