00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #ifndef STLSOFT_INCL_H_STLSOFT
00074 # include "stlsoft.h"
00075 #endif
00076
00077 #if defined(__STLSOFT_COMPILER_IS_MSVC) && \
00078 _MSC_VER < 1200
00079 # error stlsoft_pod_vector.h is not compatible with Visual C++ 5.0 or earlier
00080 #endif
00081 #if defined(__STLSOFT_COMPILER_IS_MSVC) && \
00082 _MSC_VER == 1310
00083 # error stlsoft_pod_vector.h is not compatible with Visual C++ 7.1
00084 #endif
00085
00086 #ifndef STLSOFT_INCL_H_STLSOFT_AUTO_BUFFER
00087 # include "stlsoft_auto_buffer.h"
00088 #endif
00089 #ifndef STLSOFT_INCL_H_STLSOFT_MALLOC_ALLOCATOR
00090 # include "stlsoft_malloc_allocator.h"
00091 #endif
00092 #ifndef STLSOFT_INCL_H_STLSOFT_SIMPLE_ALGORITHMS
00093 # include "stlsoft_simple_algorithms.h"
00094 #endif
00095 #include <stdexcept>
00096
00097
00098
00099
00100
00101 #ifndef _STLSOFT_NO_NAMESPACE
00102 namespace stlsoft
00103 {
00104 #endif
00105
00106
00107
00108
00109
00111 template< ss_typename_param_k T
00112 #if defined(__STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT) && \
00113 defined(__STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT)
00114 , ss_typename_param_k A = malloc_allocator<T>
00115 , ss_size_t SPACE = 64
00116 #else
00117 , ss_typename_param_k A
00118 , ss_size_t SPACE
00119 #endif
00120 >
00121 class pod_vector
00122 {
00125 private:
00126 typedef auto_buffer<T, A, SPACE> buffer_type;
00127 public:
00129 typedef ss_typename_type_k buffer_type::value_type value_type;
00131 typedef ss_typename_type_k buffer_type::allocator_type allocator_type;
00133 typedef pod_vector<T, A, SPACE> class_type;
00135 typedef ss_typename_type_k buffer_type::reference reference;
00137 typedef ss_typename_type_k buffer_type::const_reference const_reference;
00139 typedef ss_typename_type_k buffer_type::pointer pointer;
00141 typedef ss_typename_type_k buffer_type::const_pointer const_pointer;
00143 typedef ss_typename_type_k buffer_type::iterator iterator;
00145 typedef ss_typename_type_k buffer_type::const_iterator const_iterator;
00146 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00147
00148 typedef ss_typename_type_k buffer_type::reverse_iterator reverse_iterator;
00150 typedef ss_typename_type_k buffer_type::const_reverse_iterator const_reverse_iterator;
00151 #endif
00152
00153 typedef ss_typename_type_k buffer_type::size_type size_type;
00155 typedef ss_typename_type_k buffer_type::difference_type difference_type;
00156
00158
00161 public:
00162 ss_explicit_k pod_vector(size_type cItems = 0);
00163 pod_vector(size_type cItems, value_type const &value);
00164 pod_vector(class_type const &rhs);
00165 pod_vector(const_iterator first, const_iterator last);
00166
00167 pod_vector &operator =(class_type const &rhs);
00169
00172 public:
00173 iterator begin();
00174 const_iterator begin() const;
00175 iterator end();
00176 const_iterator end() const;
00177 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00178 reverse_iterator rbegin();
00179 const_reverse_iterator rbegin() const;
00180 reverse_iterator rend();
00181 const_reverse_iterator rend() const;
00182 #endif
00183
00184
00187 public:
00188 size_type size() const;
00189 size_type capacity() const;
00190 size_type max_size() const;
00191 ss_bool_t empty() const;
00192 allocator_type get_allocator() const;
00194
00197 public:
00198 reference at(size_type index);
00199 const_reference at(size_type index) const;
00200 reference operator[](size_type index);
00201 const_reference operator[](size_type index) const;
00202 reference front();
00203 const_reference front() const;
00204 reference back();
00205 const_reference back() const;
00207
00210 public:
00211 void clear();
00212 void swap(class_type &rhs);
00213 void reserve(size_type cItems) ;
00214
00215 void resize(size_type cItems) ;
00216 void resize(size_type cItems, value_type const &value) ;
00217 void push_back(value_type const &value);
00218 void pop_back();
00219
00220 void assign(const_iterator first, const_iterator last);
00221 void assign(size_type cItems, value_type const &value = value_type());
00222 iterator insert(iterator it, value_type const &value = value_type());
00223 void insert(iterator it, size_type cItems, value_type const &value);
00224 void insert(iterator it, const_iterator first, const_iterator last);
00225 iterator erase(iterator it);
00226 iterator erase(iterator first, iterator last);
00228
00231 private:
00232 void range_check_(size_type index) const ;
00233
00234 ss_bool_t resize_(size_type cItems) ;
00235
00236 ss_bool_t is_valid_() const;
00238
00241 private:
00242 size_type m_cItems;
00243
00244
00245 buffer_type m_buffer;
00247
00248
00249
00250
00251
00252
00253 template< ss_typename_param_k T
00254 , ss_typename_param_k A
00255 , ss_size_t SPACE
00256 >
00257 inline ss_bool_t operator ==(pod_vector<T, A, SPACE> const &lhs, pod_vector<T, A, SPACE> const &rhs)
00258 {
00259 if(lhs.size() != rhs.size())
00260 {
00261 return false;
00262 }
00263 else
00264 {
00265 #if 0
00266 for(ss_typename_type_k pod_vector<T, A, SPACE>::size_type i = 0, size = lhs.size(); i < size; ++i)
00267 {
00268 if(lhs[i] != rhs[i])
00269 {
00270 return false;
00271 }
00272 }
00273
00274 return true;
00275 #else
00276 return 0 == memcmp(&lhs[0], &rhs[0], sizeof(ss_typename_type_k pod_vector<T, A, SPACE>::size_type) * lhs.size());
00277 #endif
00278 }
00279 }
00280
00281 template< ss_typename_param_k T
00282 , ss_typename_param_k A
00283 , ss_size_t SPACE
00284 >
00285 inline ss_bool_t operator !=(pod_vector<T, A, SPACE> const &lhs, pod_vector<T, A, SPACE> const &rhs)
00286 {
00287 return !operator ==(lhs, rhs);
00288 }
00289
00290
00291
00292
00293
00294 #ifdef STLSOFT_UNITTEST
00295
00296 namespace unittest
00297 {
00298 ss_bool_t test_stlsoft_pod_vector(unittest_reporter *r)
00299 {
00300 ss_bool_t bSuccess = true;
00301
00302 unittest_initialiser init(r, "STLSoft", "pod_vector", __FILE__);
00303
00304 typedef pod_vector< int
00305 , malloc_allocator<int>
00306 , 64
00307 > iv_t;
00308
00309
00310 iv_t v1(10);
00311 iv_t v2(32, 1);
00312 iv_t const v3(100, -1);
00313 ss_size_t i;
00314
00315 for(i = 0; i < v1.size(); ++i)
00316 {
00317 v1[i] = static_cast<int>(i);
00318 }
00319 for(i = 0; i < v2.size(); ++i)
00320 {
00321 v2[i] = static_cast<int>(i * 100);
00322 }
00323
00324
00325 iv_t v4(v1);
00326
00327 if(v4 != v1)
00328 {
00329 r->report("copy construction failed", __LINE__);
00330 bSuccess = false;
00331 }
00332
00333
00334 iv_t v5(const_cast<iv_t const&>(v2).begin(), const_cast<iv_t const&>(v2).end());
00335
00336 if(v5 != v2)
00337 {
00338 r->report("iterator construction failed", __LINE__);
00339 bSuccess = false;
00340 }
00341
00342 v1.begin();
00343 v2.begin();
00344 v1.end();
00345 v2.end();
00346 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00347 v1.rbegin();
00348 v2.rbegin();
00349 v1.rend();
00350 v2.rend();
00351 #endif
00352
00353 v1.size();
00354 v2.capacity();
00355 v3.max_size();
00356 v4.empty();
00357 v1.get_allocator();
00358
00359 STLSOFT_SUPPRESS_UNUSED(v1.at(0));
00360 STLSOFT_SUPPRESS_UNUSED(v2.at(0));
00361 STLSOFT_SUPPRESS_UNUSED(v1[0]);
00362 STLSOFT_SUPPRESS_UNUSED(v2[0]);
00363 STLSOFT_SUPPRESS_UNUSED(v1.front());
00364 STLSOFT_SUPPRESS_UNUSED(v2.front());
00365 STLSOFT_SUPPRESS_UNUSED(v1.back());
00366 STLSOFT_SUPPRESS_UNUSED(v2.back());
00367
00368 v1.clear();
00369 v1.swap(v4);
00370 v1.reserve(v1.size() * 2);
00371 v1.resize(v1.capacity());
00372 v4.resize(1000, 127);
00373 v1.push_back(101);
00374 v1.pop_back();
00375
00376 v1.assign(const_cast<iv_t const&>(v4).begin(), const_cast<iv_t const&>(v4).end());
00377 #if 0
00378 v3.assign(100, 65535);
00379 #endif
00380
00381 #if 0
00382 iterator insert(iterator it, value_type const &value = value_type());
00383 void insert(iterator it, size_type cItems, value_type const &value);
00384 void insert(iterator it, const_iterator first, const_iterator last);
00385 iterator erase(iterator it);
00386 iterator erase(iterator first, iterator last);
00387 #endif
00388
00389 #if 0
00390 if(<<TODO>>)
00391 {
00392 r->report("<<TODO>> failed ", __LINE__);
00393 bSuccess = false;
00394 }
00395 #endif
00396
00397 return bSuccess;
00398 }
00399
00400 unittest_registrar unittest_stlsoft_pod_vector(test_stlsoft_pod_vector);
00401
00402 }
00403
00404 #endif
00405
00406
00407
00408
00409
00410 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00411
00412 template< ss_typename_param_k T
00413 , ss_typename_param_k A
00414 , ss_size_t SPACE
00415 >
00416 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00417 inline void pod_vector<T, A, SPACE>::range_check_(ss_typename_type_k pod_vector<T, A, SPACE>::size_type index) const
00418 #else
00419 inline void pod_vector<T, A, SPACE>::range_check_(size_type index) const
00420 #endif
00421 {
00422 #ifdef __STLSOFT_CF_EXCEPTION_SUPPORT
00423 if(!(index < size()))
00424 {
00425 stlsoft_ns_qual_std(out_of_range) x("pod vector index out of range");
00426
00427 #ifdef __STLSOFT_COMPILER_IS_MSVC
00428 if(1)
00429 #endif
00430 {
00431 throw x;
00432 }
00433 }
00434 #else
00435 stlsoft_message_assert("w index out of range", index < size());
00436 #endif
00437 }
00438
00439 template< ss_typename_param_k T
00440 , ss_typename_param_k A
00441 , ss_size_t SPACE
00442 >
00443 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00444 inline ss_bool_t pod_vector<T, A, SPACE>::resize_(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems)
00445 #else
00446 inline ss_bool_t pod_vector<T, A, SPACE>::resize_(size_type cItems)
00447 #endif
00448 {
00449
00450
00451 size_type curr_capacity = capacity();
00452
00453
00454 if(cItems > curr_capacity)
00455 {
00456 size_type capacity = m_buffer.internal_size() + cItems;
00457
00458 capacity -= capacity % m_buffer.internal_size();
00459
00460 if(!m_buffer.resize(capacity))
00461 {
00462 return false;
00463 }
00464 }
00465
00466 m_cItems = cItems;
00467
00468 return true;
00469 }
00470
00471
00472 template< ss_typename_param_k T
00473 , ss_typename_param_k A
00474 , ss_size_t SPACE
00475 >
00476 inline ss_bool_t pod_vector<T, A, SPACE>::is_valid_() const
00477 {
00478 if(m_buffer.size() < m_cItems)
00479 {
00480 return false;
00481 }
00482
00483 return true;
00484 }
00485
00486
00487
00488
00489 template< ss_typename_param_k T
00490 , ss_typename_param_k A
00491 , ss_size_t SPACE
00492 >
00493 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00494 inline pod_vector<T, A, SPACE>::pod_vector(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems )
00495 #else
00496 inline pod_vector<T, A, SPACE>::pod_vector(size_type cItems )
00497 #endif
00498 : m_buffer(cItems)
00499 {
00500 m_cItems = m_buffer.size();
00501
00502
00503 stlsoft_assert(is_valid_());
00504 }
00505
00506 template< ss_typename_param_k T
00507 , ss_typename_param_k A
00508 , ss_size_t SPACE
00509 >
00510 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00511 inline pod_vector<T, A, SPACE>::pod_vector(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
00512 #else
00513 inline pod_vector<T, A, SPACE>::pod_vector(size_type cItems, value_type const &value)
00514 #endif
00515 : m_buffer(cItems)
00516 {
00517 m_cItems = m_buffer.size();
00518
00519
00520 pod_fill_n(begin(), size(), value);
00521
00522 stlsoft_assert(is_valid_());
00523 }
00524
00525 template< ss_typename_param_k T
00526 , ss_typename_param_k A
00527 , ss_size_t SPACE
00528 >
00529 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00530 inline pod_vector<T, A, SPACE>::pod_vector(ss_typename_type_k pod_vector<T, A, SPACE>::class_type const &rhs)
00531 #else
00532 inline pod_vector<T, A, SPACE>::pod_vector(class_type const &rhs)
00533 #endif
00534 : m_buffer(rhs.size())
00535 {
00536 m_cItems = m_buffer.size();
00537
00538
00539 pod_copy_n(begin(), &rhs[0], size());
00540
00541 stlsoft_assert(is_valid_());
00542 }
00543
00544 template< ss_typename_param_k T
00545 , ss_typename_param_k A
00546 , ss_size_t SPACE
00547 >
00548 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00549 inline pod_vector<T, A, SPACE>::pod_vector(ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator first, ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator last)
00550 #else
00551 inline pod_vector<T, A, SPACE>::pod_vector(const_iterator first, const_iterator last)
00552 #endif
00553 : m_buffer(last - first)
00554 {
00555 m_cItems = m_buffer.size();
00556
00557
00558 if(0 != size())
00559 {
00560 pod_copy(first, last, begin());
00561 }
00562
00563 stlsoft_assert(is_valid_());
00564 }
00565
00566 template< ss_typename_param_k T
00567 , ss_typename_param_k A
00568 , ss_size_t SPACE
00569 >
00570 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00571 inline pod_vector<T, A, SPACE> &pod_vector<T, A, SPACE>::operator =(ss_typename_type_k pod_vector<T, A, SPACE>::class_type const &rhs)
00572 #else
00573 inline pod_vector<T, A, SPACE> &pod_vector<T, A, SPACE>::operator =(class_type const &rhs)
00574 #endif
00575 {
00576
00577
00578 stlsoft_assert(is_valid_());
00579
00580 class_type temp(rhs);
00581
00582 temp.swap(*this);
00583
00584 stlsoft_assert(is_valid_());
00585
00586 return *this;
00587 }
00588
00589
00590
00591
00592 template< ss_typename_param_k T
00593 , ss_typename_param_k A
00594 , ss_size_t SPACE
00595 >
00596 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00597 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::begin()
00598 #else
00599 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::begin()
00600 #endif
00601 {
00602 stlsoft_assert(is_valid_());
00603
00604 return m_buffer.begin();
00605 }
00606
00607 template< ss_typename_param_k T
00608 , ss_typename_param_k A
00609 , ss_size_t SPACE
00610 >
00611 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00612 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator pod_vector<T, A, SPACE>::begin() const
00613 #else
00614 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator pod_vector<T, A, SPACE>::begin() const
00615 #endif
00616 {
00617 stlsoft_assert(is_valid_());
00618
00619 return m_buffer.begin();
00620 }
00621
00622 template< ss_typename_param_k T
00623 , ss_typename_param_k A
00624 , ss_size_t SPACE
00625 >
00626 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00627 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::end()
00628 #else
00629 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::end()
00630 #endif
00631 {
00632 stlsoft_assert(is_valid_());
00633
00634 return &m_buffer.data()[size()];
00635 }
00636
00637 template< ss_typename_param_k T
00638 , ss_typename_param_k A
00639 , ss_size_t SPACE
00640 >
00641 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00642 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator pod_vector<T, A, SPACE>::end() const
00643 #else
00644 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator pod_vector<T, A, SPACE>::end() const
00645 #endif
00646 {
00647 stlsoft_assert(is_valid_());
00648
00649 return &m_buffer.data()[size()];
00650 }
00651
00652 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00653 template< ss_typename_param_k T
00654 , ss_typename_param_k A
00655 , ss_size_t SPACE
00656 >
00657 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00658 inline ss_typename_type_k pod_vector<T, A, SPACE>::reverse_iterator pod_vector<T, A, SPACE>::rbegin()
00659 #else
00660 inline ss_typename_type_k pod_vector<T, A, SPACE>::reverse_iterator pod_vector<T, A, SPACE>::rbegin()
00661 #endif
00662 {
00663 stlsoft_assert(is_valid_());
00664
00665 return reverse_iterator(end());
00666 }
00667
00668 template< ss_typename_param_k T
00669 , ss_typename_param_k A
00670 , ss_size_t SPACE
00671 >
00672 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00673 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reverse_iterator pod_vector<T, A, SPACE>::rbegin() const
00674 #else
00675 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reverse_iterator pod_vector<T, A, SPACE>::rbegin() const
00676 #endif
00677 {
00678 stlsoft_assert(is_valid_());
00679
00680 return const_reverse_iterator(end());
00681 }
00682
00683 template< ss_typename_param_k T
00684 , ss_typename_param_k A
00685 , ss_size_t SPACE
00686 >
00687 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00688 inline ss_typename_type_k pod_vector<T, A, SPACE>::reverse_iterator pod_vector<T, A, SPACE>::rend()
00689 #else
00690 inline ss_typename_type_k pod_vector<T, A, SPACE>::reverse_iterator pod_vector<T, A, SPACE>::rend()
00691 #endif
00692 {
00693 stlsoft_assert(is_valid_());
00694
00695 return reverse_iterator(begin());
00696 }
00697
00698 template< ss_typename_param_k T
00699 , ss_typename_param_k A
00700 , ss_size_t SPACE
00701 >
00702 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00703 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reverse_iterator pod_vector<T, A, SPACE>::rend() const
00704 #else
00705 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reverse_iterator pod_vector<T, A, SPACE>::rend() const
00706 #endif
00707 {
00708 stlsoft_assert(is_valid_());
00709
00710 return const_reverse_iterator(begin());
00711 }
00712 #endif
00713
00714
00715
00716 template< ss_typename_param_k T
00717 , ss_typename_param_k A
00718 , ss_size_t SPACE
00719 >
00720 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00721 inline ss_typename_type_k pod_vector<T, A, SPACE>::size_type pod_vector<T, A, SPACE>::size() const
00722 #else
00723 inline ss_size_t pod_vector<T, A, SPACE>::size() const
00724 #endif
00725 {
00726 stlsoft_assert(is_valid_());
00727
00728 return m_cItems;
00729 }
00730
00731 template< ss_typename_param_k T
00732 , ss_typename_param_k A
00733 , ss_size_t SPACE
00734 >
00735 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00736 inline ss_typename_type_k pod_vector<T, A, SPACE>::size_type pod_vector<T, A, SPACE>::capacity() const
00737 #else
00738 inline ss_size_t pod_vector<T, A, SPACE>::capacity() const
00739 #endif
00740 {
00741 stlsoft_assert(is_valid_());
00742
00743 return m_buffer.size();
00744 }
00745
00746 template< ss_typename_param_k T
00747 , ss_typename_param_k A
00748 , ss_size_t SPACE
00749 >
00750 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00751 inline ss_typename_type_k pod_vector<T, A, SPACE>::size_type pod_vector<T, A, SPACE>::max_size() const
00752 #else
00753 inline ss_size_t pod_vector<T, A, SPACE>::max_size() const
00754 #endif
00755 {
00756 stlsoft_assert(is_valid_());
00757
00758 return static_cast<size_type>(-1) / sizeof(value_type);
00759 }
00760
00761 template< ss_typename_param_k T
00762 , ss_typename_param_k A
00763 , ss_size_t SPACE
00764 >
00765 inline ss_bool_t pod_vector<T, A, SPACE>::empty() const
00766 {
00767 stlsoft_assert(is_valid_());
00768
00769 return 0 == size();
00770 }
00771
00772 template< ss_typename_param_k T
00773 , ss_typename_param_k A
00774 , ss_size_t SPACE
00775 >
00776 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00777 inline ss_typename_type_k pod_vector<T, A, SPACE>::allocator_type pod_vector<T, A, SPACE>::get_allocator() const
00778 #else
00779 inline ss_typename_type_k pod_vector<T, A, SPACE>::allocator_type pod_vector<T, A, SPACE>::get_allocator() const
00780 #endif
00781 {
00782 stlsoft_assert(is_valid_());
00783
00784 return m_buffer.get_allocator();
00785 }
00786
00787
00788 template< ss_typename_param_k T
00789 , ss_typename_param_k A
00790 , ss_size_t SPACE
00791 >
00792 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00793 inline ss_typename_type_k pod_vector<T, A, SPACE>::reference pod_vector<T, A, SPACE>::at(ss_typename_type_k pod_vector<T, A, SPACE>::size_type index)
00794 #else
00795 inline T &pod_vector<T, A, SPACE>::at(size_type index)
00796 #endif
00797 {
00798 stlsoft_assert(is_valid_());
00799
00800 range_check_(index);
00801
00802 stlsoft_assert(is_valid_());
00803
00804 return m_buffer.data()[index];
00805 }
00806
00807 template< ss_typename_param_k T
00808 , ss_typename_param_k A
00809 , ss_size_t SPACE
00810 >
00811 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00812 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reference pod_vector<T, A, SPACE>::at(ss_typename_type_k pod_vector<T, A, SPACE>::size_type index) const
00813 #else
00814 inline T const &pod_vector<T, A, SPACE>::at(size_type index) const
00815 #endif
00816 {
00817 stlsoft_assert(is_valid_());
00818
00819 range_check_(index);
00820
00821 stlsoft_assert(is_valid_());
00822
00823 return m_buffer.data()[index];
00824 }
00825
00826 template< ss_typename_param_k T
00827 , ss_typename_param_k A
00828 , ss_size_t SPACE
00829 >
00830 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00831 inline ss_typename_type_k pod_vector<T, A, SPACE>::reference pod_vector<T, A, SPACE>::operator [](ss_typename_type_k pod_vector<T, A, SPACE>::size_type index)
00832 #else
00833 inline T &pod_vector<T, A, SPACE>::operator [](size_type index)
00834 #endif
00835 {
00836 stlsoft_assert(is_valid_());
00837
00838
00839
00840 stlsoft_message_assert("Requested index is out of range", !(size() < index));
00841
00842 return m_buffer.data()[index];
00843 }
00844
00845 template< ss_typename_param_k T
00846 , ss_typename_param_k A
00847 , ss_size_t SPACE
00848 >
00849 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00850 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reference pod_vector<T, A, SPACE>::operator [](ss_typename_type_k pod_vector<T, A, SPACE>::size_type index) const
00851 #else
00852 inline T const &pod_vector<T, A, SPACE>::operator [](size_type index) const
00853 #endif
00854 {
00855 stlsoft_assert(is_valid_());
00856
00857
00858
00859 stlsoft_message_assert("Requested index is out of range", !(size() < index));
00860
00861 return m_buffer.data()[index];
00862 }
00863
00864 template< ss_typename_param_k T
00865 , ss_typename_param_k A
00866 , ss_size_t SPACE
00867 >
00868 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00869 inline ss_typename_type_k pod_vector<T, A, SPACE>::reference pod_vector<T, A, SPACE>::front()
00870 #else
00871 inline T &pod_vector<T, A, SPACE>::front()
00872 #endif
00873 {
00874 stlsoft_assert(is_valid_());
00875
00876 stlsoft_message_assert("Range is empty!", 0 != size());
00877
00878 return m_buffer.data()[0];
00879 }
00880
00881 template< ss_typename_param_k T
00882 , ss_typename_param_k A
00883 , ss_size_t SPACE
00884 >
00885 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00886 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reference pod_vector<T, A, SPACE>::front() const
00887 #else
00888 inline T const &pod_vector<T, A, SPACE>::front() const
00889 #endif
00890 {
00891 stlsoft_assert(is_valid_());
00892
00893 stlsoft_message_assert("Range is empty!", 0 != size());
00894
00895 return m_buffer.data()[0];
00896 }
00897
00898 template< ss_typename_param_k T
00899 , ss_typename_param_k A
00900 , ss_size_t SPACE
00901 >
00902 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00903 inline ss_typename_type_k pod_vector<T, A, SPACE>::reference pod_vector<T, A, SPACE>::back()
00904 #else
00905 inline T &pod_vector<T, A, SPACE>::back()
00906 #endif
00907 {
00908 stlsoft_assert(is_valid_());
00909
00910 stlsoft_message_assert("Range is empty!", 0 != size());
00911
00912 return m_buffer.data()[size() - 1];
00913 }
00914
00915
00916 template< ss_typename_param_k T
00917 , ss_typename_param_k A
00918 , ss_size_t SPACE
00919 >
00920 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00921 inline ss_typename_type_k pod_vector<T, A, SPACE>::const_reference pod_vector<T, A, SPACE>::back() const
00922 #else
00923 inline T const &pod_vector<T, A, SPACE>::back() const
00924 #endif
00925 {
00926 stlsoft_assert(is_valid_());
00927
00928 stlsoft_message_assert("Range is empty!", 0 != size());
00929
00930 return m_buffer.data()[size() - 1];
00931 }
00932
00933
00934
00935 template< ss_typename_param_k T
00936 , ss_typename_param_k A
00937 , ss_size_t SPACE
00938 >
00939 inline void pod_vector<T, A, SPACE>::clear()
00940 {
00941 stlsoft_assert(is_valid_());
00942
00943 if(m_buffer.resize(0))
00944 {
00945 m_cItems = 0;
00946 }
00947
00948 stlsoft_assert(is_valid_());
00949 }
00950
00951 template< ss_typename_param_k T
00952 , ss_typename_param_k A
00953 , ss_size_t SPACE
00954 >
00955 inline void pod_vector<T, A, SPACE>::swap(pod_vector<T, A, SPACE> &rhs)
00956 {
00957 stlsoft_assert(is_valid_());
00958
00959 m_buffer.swap(rhs.m_buffer);
00960 swap_(m_cItems, rhs.m_cItems);
00961
00962 stlsoft_assert(is_valid_());
00963 }
00964
00965 template< ss_typename_param_k T
00966 , ss_typename_param_k A
00967 , ss_size_t SPACE
00968 >
00969 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00970 inline void pod_vector<T, A, SPACE>::reserve(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems)
00971 #else
00972 inline void pod_vector<T, A, SPACE>::reserve(size_type cItems)
00973 #endif
00974 {
00975 stlsoft_assert(is_valid_());
00976
00977
00978
00979 if( 0 == cItems ||
00980 cItems > size())
00981 {
00982 m_buffer.resize(cItems);
00983 }
00984
00985 stlsoft_assert(is_valid_());
00986 }
00987
00988 template< ss_typename_param_k T
00989 , ss_typename_param_k A
00990 , ss_size_t SPACE
00991 >
00992 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
00993 inline void pod_vector<T, A, SPACE>::resize(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems)
00994 #else
00995 inline void pod_vector<T, A, SPACE>::resize(size_type cItems)
00996 #endif
00997 {
00998 stlsoft_assert(is_valid_());
00999
01000
01001 if( (0 != cItems &&
01002 cItems < size()) ||
01003 m_buffer.resize(cItems))
01004 {
01005 m_cItems = cItems;
01006 }
01007
01008 stlsoft_assert(is_valid_());
01009 }
01010
01011 template< ss_typename_param_k T
01012 , ss_typename_param_k A
01013 , ss_size_t SPACE
01014 >
01015 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01016 inline void pod_vector<T, A, SPACE>::resize(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
01017 #else
01018 inline void pod_vector<T, A, SPACE>::resize(size_type cItems, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
01019 #endif
01020 {
01021 stlsoft_assert(is_valid_());
01022
01023
01024 if( 0 != cItems &&
01025 cItems < m_cItems)
01026 {
01027 m_cItems = cItems;
01028 }
01029 else if(m_cItems < cItems)
01030 {
01031 if(m_buffer.resize(cItems))
01032 {
01033 pod_fill_n(end(), cItems - m_cItems, value);
01034 m_cItems = cItems;
01035 }
01036 }
01037
01038 stlsoft_assert(is_valid_());
01039 }
01040
01041 template< ss_typename_param_k T
01042 , ss_typename_param_k A
01043 , ss_size_t SPACE
01044 >
01045 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01046 inline void pod_vector<T, A, SPACE>::push_back(ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
01047 #else
01048 inline void pod_vector<T, A, SPACE>::push_back(ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
01049 #endif
01050 {
01051 stlsoft_assert(is_valid_());
01052
01053 insert(end(), value);
01054
01055 stlsoft_assert(is_valid_());
01056 }
01057
01058 template< ss_typename_param_k T
01059 , ss_typename_param_k A
01060 , ss_size_t SPACE
01061 >
01062 inline void pod_vector<T, A, SPACE>::pop_back()
01063 {
01064 stlsoft_assert(is_valid_());
01065
01066 stlsoft_message_assert("No elements to pop", size() > 0);
01067
01068 if(0 == --m_cItems)
01069 {
01070 m_buffer.resize(0);
01071 }
01072
01073 stlsoft_assert(is_valid_());
01074 }
01075
01076 template< ss_typename_param_k T
01077 , ss_typename_param_k A
01078 , ss_size_t SPACE
01079 >
01080 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01081 inline void pod_vector<T, A, SPACE>::assign(ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator first, ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator last)
01082 #else
01083 inline void pod_vector<T, A, SPACE>::assign(const_iterator first, const_iterator last)
01084 #endif
01085 {
01086 stlsoft_assert(is_valid_());
01087
01088
01089
01090 class_type temp(first, last);
01091
01092 temp.swap(*this);
01093
01094 stlsoft_assert(is_valid_());
01095 }
01096
01097 template< ss_typename_param_k T
01098 , ss_typename_param_k A
01099 , ss_size_t SPACE
01100 >
01101 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01102 inline void pod_vector<T, A, SPACE>::assign(ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value )
01103 #else
01104 inline void pod_vector<T, A, SPACE>::assign(size_type cItems, value_type const &value )
01105 #endif
01106 {
01107 stlsoft_assert(is_valid_());
01108
01109
01110
01111 class_type temp(cItems, value);
01112
01113 temp.swap(*this);
01114
01115 stlsoft_assert(is_valid_());
01116 }
01117
01118 template< ss_typename_param_k T
01119 , ss_typename_param_k A
01120 , ss_size_t SPACE
01121 >
01122 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01123 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::insert(ss_typename_type_k pod_vector<T, A, SPACE>::iterator it, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value )
01124 #else
01125 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::insert(iterator it, value_type const &value )
01126 #endif
01127 {
01128 stlsoft_assert(is_valid_());
01129
01130 stlsoft_assert(!(end() < it));
01131 stlsoft_assert(!(it < begin()));
01132
01133 size_type index = it - begin();
01134
01135 insert(it, 1, value);
01136
01137 stlsoft_assert(is_valid_());
01138
01139 return begin() + index;
01140 }
01141
01142 template< ss_typename_param_k T
01143 , ss_typename_param_k A
01144 , ss_size_t SPACE
01145 >
01146 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01147 inline void pod_vector<T, A, SPACE>::insert(ss_typename_type_k pod_vector<T, A, SPACE>::iterator it, ss_typename_type_k pod_vector<T, A, SPACE>::size_type cItems, ss_typename_type_k pod_vector<T, A, SPACE>::value_type const &value)
01148 #else
01149 inline void pod_vector<T, A, SPACE>::insert(iterator it, size_type cItems, value_type const &value)
01150 #endif
01151 {
01152 stlsoft_assert(is_valid_());
01153
01154 stlsoft_assert(!(end() < it));
01155 stlsoft_assert(!(it < begin()));
01156
01157 size_type curr_size = size();
01158 size_type index = it - begin();
01159
01160 if(resize_(size() + cItems))
01161 {
01162 size_type cMove = curr_size - index;
01163
01164
01165 it = begin() + index;
01166
01167
01168 pod_move_n(&it[cItems], &it[0], cMove);
01169
01170
01171 pod_fill_n(m_buffer.data() + index, cItems, value);
01172 }
01173
01174 stlsoft_assert(is_valid_());
01175 }
01176
01177 template< ss_typename_param_k T
01178 , ss_typename_param_k A
01179 , ss_size_t SPACE
01180 >
01181 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01182 inline void pod_vector<T, A, SPACE>::insert(ss_typename_type_k pod_vector<T, A, SPACE>::iterator it, ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator first, ss_typename_type_k pod_vector<T, A, SPACE>::const_iterator last)
01183 #else
01184 inline void pod_vector<T, A, SPACE>::insert(iterator it, const_iterator first, const_iterator last)
01185 #endif
01186 {
01187 stlsoft_assert(is_valid_());
01188
01189 stlsoft_assert(!(end() < it));
01190 stlsoft_assert(!(it < begin()));
01191
01192 size_type curr_size = size();
01193 size_type index = it - begin();
01194 size_type cItems = last - first;
01195
01196 if(resize_(size() + cItems))
01197 {
01198 size_type cMove = curr_size - index;
01199
01200
01201 it = begin() + index;
01202
01203
01204 pod_move_n(&it[cItems], &it[0], cMove);
01205
01206
01207 pod_copy_n(m_buffer.data(), first, cItems);
01208 }
01209
01210 stlsoft_assert(is_valid_());
01211 }
01212
01213 template< ss_typename_param_k T
01214 , ss_typename_param_k A
01215 , ss_size_t SPACE
01216 >
01217 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01218 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::erase(ss_typename_type_k pod_vector<T, A, SPACE>::iterator it)
01219 #else
01220 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::erase(iterator it)
01221 #endif
01222 {
01223 stlsoft_assert(is_valid_());
01224
01225 stlsoft_assert(it < end());
01226 stlsoft_assert(!(it < begin()));
01227
01228 if(it != end() - 1)
01229 {
01230 pod_move_n(&it[0], &it[1], 1);
01231 }
01232
01233 if(0 == --m_cItems)
01234 {
01235 m_buffer.resize(0);
01236 }
01237
01238 stlsoft_assert(is_valid_());
01239
01240 return it;
01241 }
01242
01243 template< ss_typename_param_k T
01244 , ss_typename_param_k A
01245 , ss_size_t SPACE
01246 >
01247 #ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED
01248 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::erase(ss_typename_type_k pod_vector<T, A, SPACE>::iterator first, ss_typename_type_k pod_vector<T, A, SPACE>::iterator last)
01249 #else
01250 inline ss_typename_type_k pod_vector<T, A, SPACE>::iterator pod_vector<T, A, SPACE>::erase(iterator first, iterator last)
01251 #endif
01252 {
01253 stlsoft_assert(is_valid_());
01254
01255 stlsoft_assert(first < end());
01256 stlsoft_assert(!(first < begin()));
01257 stlsoft_assert(!(end() < last));
01258 stlsoft_assert(!(last < begin()));
01259
01260 size_type curr_size = size();
01261 size_type index_first = first - begin();
01262 size_type index_last = last - begin();
01263 size_type cItems = last - first;
01264 size_type cMove = curr_size - index_last;
01265
01266
01267 pod_move_n(&first[0], &last[0], cMove);
01268
01269 resize(curr_size - cItems);
01270
01271 stlsoft_assert(is_valid_());
01272
01273 return begin() + index_first;
01274 }
01275
01276 #endif
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288