14 #ifndef __INCLUDED_SCOPIRA_TOOL_ARRAY_H__ 15 #define __INCLUDED_SCOPIRA_TOOL_ARRAY_H__ 46 typedef const T* const_iterator;
77 T *
array(
void) {
return dm_ary; }
82 const T *
array(
void)
const {
return dm_ary; }
92 const T *
c_array(
void)
const {
return dm_ary; }
97 iterator
begin(
void) {
return dm_ary; }
102 iterator
end(
void) {
return dm_end; }
107 const_iterator
begin(
void)
const {
return dm_ary; }
112 const_iterator
end(
void)
const {
return dm_end; }
126 size_t size(
void)
const {
return dm_end - dm_ary; }
131 bool empty(
void)
const {
return dm_ary == dm_end; }
137 void set(
size_t idx,
const T &v) {
138 assert(
"[array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
145 const T &
get(
size_t idx)
const {
146 assert(
"[array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
153 T &
get(
size_t idx) {
154 assert(
"[array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
162 assert(
"[array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
170 assert(
"[array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
183 typedef const T* const_iterator;
185 const T *dm_ary, *dm_end;
220 const T *
array(
void)
const {
return dm_ary; }
225 const T *
c_array(
void)
const {
return dm_ary; }
230 const_iterator
begin(
void)
const {
return dm_ary; }
235 const_iterator
end(
void)
const {
return dm_end; }
241 size_t size(
void)
const {
return dm_end - dm_ary; }
246 bool empty(
void)
const {
return dm_ary == dm_end; }
252 const T &
get(
size_t idx)
const {
253 assert(
"[const_array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
261 assert(
"[const_array_view element access was out of bounds]" && (dm_ary+idx)<dm_end);
280 typedef const T* const_iterator;
298 explicit basic_array(
size_t len) : dm_ary(0), dm_len(0) { resize(len); }
318 void resize(
size_t newlen);
332 dm_ary = other.dm_ary;
333 dm_len = other.dm_len;
346 const T *
array(
void)
const {
return dm_ary; }
356 const T *
c_array(
void)
const {
return dm_ary; }
361 iterator
begin(
void) {
return dm_ary; }
366 iterator
end(
void) {
return dm_ary+dm_len; }
371 const_iterator
begin(
void)
const {
return dm_ary; }
376 const_iterator
end(
void)
const {
return dm_ary+dm_len; }
394 void clear_zero(
void) { ::memset(dm_ary, 0,
sizeof(T)*dm_len); }
400 size_t size(
void)
const {
return dm_len; }
405 bool empty(
void)
const {
return dm_len == 0; }
411 void set(
size_t idx,
const T &v) {
412 assert(
"[basic_array element access was out of bounds]" && idx<dm_len);
419 const T &
get(
size_t idx)
const {
420 assert(
"[basic_array element access was out of bounds]" && idx<dm_len);
427 T &
get(
size_t idx) {
428 assert(
"[basic_array element access was out of bounds]" && idx<dm_len);
436 assert(
"[basic_array element access was out of bounds]" && idx<dm_len);
444 assert(
"[basic_array element access was out of bounds]" && idx<dm_len);
451 : dm_ary(0), dm_len(0)
455 iterator ii, endii = end();
458 for (ii=begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
466 if (dm_len == newlen)
474 dm_ary =
new T[dm_len];
482 iterator ii, endii = end();
485 for (ii=begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
535 size_t width(
void)
const {
return dm_w; }
540 size_t height(
void)
const {
return dm_h; }
546 void set(
size_t x,
size_t y,
const T &v) {
547 assert(
"[basic_matrix x axis out of bounds]" && x<dm_w);
548 assert(
"[basic_matrix y axis out of bounds]" && y<dm_h);
555 const T &
get(
size_t x,
size_t y)
const {
556 assert(
"[basic_matrix x axis out of bounds]" && x<dm_w);
557 assert(
"[basic_matrix y axis out of bounds]" && y<dm_h);
564 T &
get(
size_t x,
size_t y) {
565 assert(
"[basic_matrix x axis out of bounds]" && x<dm_w);
566 assert(
"[basic_matrix y axis out of bounds]" && y<dm_h);
574 assert(
"[basic_matrix x axis out of bounds]" && x<dm_w);
575 assert(
"[basic_matrix y axis out of bounds]" && y<dm_h);
583 assert(
"[basic_matrix x axis out of bounds]" && x<dm_w);
584 assert(
"[basic_matrix y axis out of bounds]" && y<dm_h);
590 void resize(
size_t newlen) {
591 parent_type::resize(newlen);
613 typedef const T* const_iterator;
627 const T *
array(
void)
const {
return dm_ary; }
637 const T *
c_array(
void)
const {
return dm_ary; }
642 iterator
begin(
void) {
return dm_ary; }
647 iterator
end(
void) {
return dm_ary+N; }
652 const_iterator
begin(
void)
const {
return dm_ary; }
657 const_iterator
end(
void)
const {
return dm_ary+N; }
669 size_t size(
void)
const {
return N; }
674 bool empty(
void)
const {
return false; }
680 void set(
size_t idx,
const T &v) {
681 assert(
"[fixed_array element access out of bounds]" && idx<N);
688 const T &
get(
size_t idx)
const {
689 assert(
"[fixed_array element access out of bounds]" && idx<N);
696 T &
get(
size_t idx) {
697 assert(
"[fixed_array element access out of bounds]" && idx<N);
705 assert(
"[fixed_array element access out of bounds]" && idx<N);
713 assert(
"[fixed_array element access out of bounds]" && idx<N);
738 typedef const T* const_iterator;
785 void resize(
size_t newlen);
795 const T *
array(
void)
const {
return dm_ary; }
805 const T *
c_array(
void)
const {
return dm_ary; }
810 iterator
begin(
void) {
return dm_ary; }
815 iterator
end(
void) {
return dm_ary+dm_len; }
820 const_iterator
begin(
void)
const {
return dm_ary; }
825 const_iterator
end(
void)
const {
return dm_ary+dm_len; }
848 void clear_zero(
void) { ::memset(dm_ary, 0,
sizeof(T)*dm_len); }
854 size_t size(
void)
const {
return dm_len; }
859 bool empty(
void)
const {
return dm_len == 0; }
865 void set(
size_t idx,
const T &v) {
866 assert(
"[hybrid_array element access was out of bounds]" && idx<dm_len);
873 const T &
get(
size_t idx)
const {
874 assert(
"[hybrid_array element access was out of bounds]" && idx<dm_len);
881 T &
get(
size_t idx) {
882 assert(
"[hybrid_array element access was out of bounds]" && idx<dm_len);
890 assert(
"[hybrid_array element access was out of bounds]" && idx<dm_len);
898 assert(
"[hybrid_array element access was out of bounds]" && idx<dm_len);
903 template <
class T,
size_t RES>
905 : dm_ary(0), dm_len(0)
909 template <
class T,
size_t RES>
911 : dm_ary(0), dm_len(0)
916 template <
class T,
size_t RES>
918 : dm_ary(0), dm_len(0)
922 iterator ii, endii =
end();
925 for (ii=
begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
930 template <
class T,
size_t RES>
932 : dm_ary(0), dm_len(0)
936 iterator ii, endii =
end();
939 for (ii=
begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
944 template <
class T,
size_t RES>
947 if (dm_len == newlen)
954 else if (dm_len <= RES)
957 dm_basic.resize(dm_len);
958 dm_ary = dm_basic.c_array();
962 template <
class T,
size_t RES>
967 iterator ii, endii =
end();
970 for (ii=
begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
976 template <
class T,
size_t RES>
981 iterator ii, endii =
end();
984 for (ii=
begin(), jj=rhs.
begin(); ii != endii; ++ii, ++jj)
Definition: archiveflow.h:20