00001
00002
00008 #if !defined(__Array1_h__)
00009 #error This file is an implementation detail of the class Array.
00010 #endif
00011
00012 #include "../defs.h"
00013
00014 BEGIN_NAMESPACE_ADS
00015
00017
00077 template<typename T, bool A>
00078 class Array<1,T,A> :
00079 public ArrayContainer<T,A>, public ArrayIndexing<1,T> {
00080 private:
00081
00082
00083
00084
00085
00086 typedef ArrayTypes<T> types;
00087 typedef ArrayContainer<T,A> container_base;
00088 typedef ArrayIndexing<1,T> indexing_base;
00089
00090 public:
00091
00092
00093
00094
00095
00097 typedef typename types::value_type value_type;
00099
00102 typedef typename types::parameter_type parameter_type;
00104
00107 typedef typename types::unqualified_value_type
00108 unqualified_value_type;
00109
00111 typedef typename types::pointer pointer;
00113 typedef typename types::const_pointer const_pointer;
00114
00116 typedef typename types::iterator iterator;
00118 typedef typename types::const_iterator const_iterator;
00119
00121 typedef typename types::reference reference;
00123 typedef typename types::const_reference const_reference;
00124
00126
00132 typedef typename types::size_type size_type;
00134 typedef typename types::difference_type difference_type;
00135
00137
00141 typedef typename Loki::Select< A || Loki::TypeTraits<value_type>::isConst,
00142 const void*, void* >::Result
00143 void_pointer;
00144
00146 typedef typename indexing_base::index_type index_type;
00148 typedef typename indexing_base::range_type range_type;
00149
00150 private:
00151
00153
00158 typedef typename Loki::Select<A || Loki::TypeTraits<value_type>::isConst,
00159 const_pointer, pointer>::Result
00160 pointer_parameter;
00161
00162 public:
00163
00164
00166
00167
00169 Array() :
00170 container_base(),
00171 indexing_base()
00172 {}
00173
00175
00179 Array(const Array& x) :
00180 container_base(x),
00181 indexing_base(x)
00182 {}
00183
00184
00189 template<typename T2, bool A2>
00190 Array(const Array<1,T2,A2>& x) :
00191 container_base(x),
00192 indexing_base(x.range(), data())
00193 {}
00194
00195
00200 template<int N2,typename T2, bool A2>
00201 Array(const Array<N2,T2,A2>& x) :
00202 container_base(x.data(), x.data() + x.size()),
00203 indexing_base(index_type(x.size()), container_base::data())
00204 {}
00205
00207
00211 Array&
00212 operator=(const Array& other) {
00213 container_base::operator=(other);
00214 indexing_base::rebuild(other.range(), data());
00215 return *this;
00216 }
00217
00219
00223 template<typename T2, bool A2>
00224 Array&
00225 operator=(const Array<1,T2,A2>& x) {
00226 container_base::operator=(x);
00227 indexing_base::rebuild(x.range(), data());
00228 return *this;
00229 }
00230
00232
00236 template<int N2, typename T2, bool A2>
00237 Array&
00238 operator=(const Array<N2,T2,A2>& x) {
00239 container_base::operator=(x);
00240 indexing_base::rebuild(x.size(), data());
00241 return *this;
00242 }
00243
00244
00245
00246
00247
00249 explicit
00250 Array(const size_type size) :
00251 container_base(size),
00252 indexing_base(index_type(size), container_base::data())
00253 {}
00254
00256 explicit
00257 Array(const size_type size, parameter_type value) :
00258 container_base(size),
00259 indexing_base(index_type(size), container_base::data()) {
00260 fill(value);
00261 }
00262
00264
00269 template<typename ForwardIterator>
00270 Array(ForwardIterator first, ForwardIterator last) :
00271 container_base(first, last),
00272 indexing_base(index_type(container_base::size()),
00273 container_base::data())
00274 {}
00275
00277
00282 template<typename ForwardIterator>
00283 void
00284 rebuild(ForwardIterator first, ForwardIterator last) {
00285 container_base::rebuild(first, last);
00286 indexing_base::rebuild(index_type(size()), data());
00287 }
00288
00290
00296 template<typename InputIterator>
00297 explicit
00298 Array(const size_type size, InputIterator first, InputIterator last) :
00299 container_base(first, last),
00300 indexing_base(index_type(size), container_base::data())
00301 {}
00302
00304 explicit
00305 Array(const index_type& extent) :
00306 container_base(extent[0]),
00307 indexing_base(extent, container_base::data())
00308 {}
00309
00311 explicit
00312 Array(const index_type& extent, parameter_type value) :
00313 container_base(extent[0]),
00314 indexing_base(extent, container_base::data()) {
00315 fill(value);
00316 }
00317
00319
00325 template<typename InputIterator>
00326 explicit
00327 Array(const index_type& extent, InputIterator first, InputIterator last) :
00328 container_base(first, last),
00329 indexing_base(extent, container_base::data())
00330 {}
00331
00333 explicit
00334 Array(const range_type& range) :
00335 container_base(range.extent()),
00336 indexing_base(range, container_base::data())
00337 {}
00338
00340 explicit
00341 Array(const range_type& range, parameter_type value) :
00342 container_base(range.extent()),
00343 indexing_base(range, container_base::data()) {
00344 fill(value);
00345 }
00346
00348
00354 template<typename InputIterator>
00355 explicit
00356 Array(const range_type& range, InputIterator first, InputIterator last) :
00357 container_base(first, last),
00358 indexing_base(range, container_base::data())
00359 {}
00360
00362
00366 Array(const size_type size, const void_pointer data) :
00367 container_base(reinterpret_cast<pointer_parameter>(data),
00368 reinterpret_cast<pointer_parameter>(data) + size),
00369 indexing_base(index_type(size), container_base::data())
00370 {}
00371
00373
00380 Array(const range_type& range, const void_pointer data) :
00381 container_base(reinterpret_cast<pointer_parameter>(data),
00382 reinterpret_cast<pointer_parameter>(data) +
00383 range.extent()),
00384 indexing_base(range, container_base::data())
00385 {}
00386
00388 ~Array()
00389 {}
00390
00391
00392
00393 public:
00394
00395
00399
00400
00402 using container_base::size;
00403
00405 using container_base::empty;
00406
00408 using container_base::max_size;
00409
00411 using container_base::begin;
00412
00414 using container_base::end;
00415
00417
00422 using container_base::data;
00423
00425
00430 using container_base::operator[];
00431
00432
00433
00435
00436
00438 using indexing_base::rank;
00439
00440
00441
00445
00446
00448 using indexing_base::extents;
00449
00451 using indexing_base::extent;
00452
00454 using indexing_base::ranges;
00455
00457 using indexing_base::lbounds;
00458
00460 using indexing_base::ubounds;
00461
00463 using indexing_base::lbound;
00464
00466 using indexing_base::ubound;
00467
00469 using indexing_base::strides;
00470
00472 using indexing_base::root;
00473
00474
00475
00477
00478
00480 using indexing_base::range;
00481
00483
00484
00486
00487
00488
00489
00493
00494
00496 using indexing_base::operator();
00497
00498
00499
00500
00501
00502
00503
00504
00506
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00525
00526
00528 using indexing_base::index;
00529
00530
00531
00532
00533
00534
00535
00536
00538
00539
00540
00541
00542
00543
00544
00545
00547 using indexing_base::index_to_indices;
00548
00549
00550
00551
00552
00553
00554
00555
00557
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00571
00572
00574
00577 size_type
00578 getMemoryUsage() const {
00579 return sizeof(Array) + sizeof(value_type) * size();
00580 }
00581
00582
00583
00587
00588
00590
00591
00593
00594
00596
00597
00599
00604
00605
00607 using container_base::negate;
00608
00610 using container_base::fill;
00611
00613
00614
00615
00616
00620
00621
00623
00624
00626
00627
00629
00635
00636
00637
00638
00640
00641
00643 void
00644 swap(Array& x)
00645 {
00646 container_base::swap(x);
00647 indexing_base::swap(x);
00648 }
00649
00651
00657 void
00658 resize(const size_type size);
00659
00661
00667 void
00668 resize(const index_type& extent) {
00669 resize(extent[0]);
00670 }
00671
00673
00680 void
00681 resize(const range_type& range);
00682
00683
00684
00686
00687
00689 Array&
00690 operator=(parameter_type x) {
00691 container_base::operator=(x);
00692 return *this;
00693 }
00694
00695
00696
00698
00699
00701 void
00702 put(std::ostream& out) const {
00703 indexing_base::put(out);
00704 container_base::put(out);
00705 }
00706
00708 void
00709 get(std::istream& in) {
00710 get(in, Loki::Int2Type<A>());
00711 }
00712
00714
00724 void
00725 write(std::ostream& out) const {
00726 indexing_base::write(out);
00727 container_base::write(out);
00728 }
00729
00731
00741 void
00742 read(std::istream& in) {
00743 read(in, Loki::Int2Type<A>());
00744 }
00745
00747 void
00748 write_elements_ascii(std::ostream& out) const {
00749 container_base::write_elements_ascii(out);
00750 }
00751
00753 void
00754 write_elements_binary(std::ostream& out) const {
00755 container_base::write_elements_binary(out);
00756 }
00757
00759 void
00760 read_elements_ascii(std::istream& in) {
00761 container_base::read_elements_ascii(in);
00762 }
00763
00765 void
00766 read_elements_binary(std::istream& in) {
00767 container_base::read_elements_binary(in);
00768 }
00769
00770
00771
00773
00774
00775
00776 template<typename T2, bool A2>
00777 bool
00778 operator==(const Array<1,T2,A2>& x) const {
00779 return indexing_base::operator==(x) && container_base::operator==(x);
00780 }
00781
00782
00783
00784
00785
00786
00787
00789
00792 void
00793 get(std::istream& in, Loki::Int2Type<true>);
00794
00796
00799 void
00800 get(std::istream& in, Loki::Int2Type<false>);
00801
00803
00806 void
00807 read(std::istream& in, Loki::Int2Type<true>);
00808
00810
00813 void
00814 read(std::istream& in, Loki::Int2Type<false>);
00815
00816 };
00817
00818 END_NAMESPACE_ADS
00819
00820 #define __Array1_ipp__
00821 #include "Array1.ipp"
00822 #undef __Array1_ipp__