1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_vector.c Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,137 @@
1.4 +/*
1.5 + *
1.6 + *
1.7 + * Copyright (c) 1994
1.8 + * Hewlett-Packard Company
1.9 + *
1.10 + * Copyright (c) 1996,1997
1.11 + * Silicon Graphics Computer Systems, Inc.
1.12 + *
1.13 + * Copyright (c) 1997
1.14 + * Moscow Center for SPARC Technology
1.15 + *
1.16 + * Copyright (c) 1999
1.17 + * Boris Fomitchev
1.18 + *
1.19 + * This material is provided "as is", with absolutely no warranty expressed
1.20 + * or implied. Any use is at your own risk.
1.21 + *
1.22 + * Permission to use or copy this software for any purpose is hereby granted
1.23 + * without fee, provided the above notices are retained on all copies.
1.24 + * Permission to modify the code and to distribute modified code is granted,
1.25 + * provided the above notices are retained, and a notice that the code was
1.26 + * modified is included with the above copyright notice.
1.27 + *
1.28 + */
1.29 +#ifndef _STLP_VECTOR_C
1.30 +#define _STLP_VECTOR_C
1.31 +
1.32 +# if !defined (_STLP_INTERNAL_VECTOR_H)
1.33 +# include <stl/_vector.h>
1.34 +# endif
1.35 +
1.36 +# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.37 +# define iterator _Tp*
1.38 +# define size_type size_t
1.39 +# endif
1.40 +
1.41 +# undef vector
1.42 +# define vector __WORKAROUND_DBG_RENAME(vector)
1.43 +
1.44 +_STLP_BEGIN_NAMESPACE
1.45 +
1.46 +template <class _Tp, class _Alloc>
1.47 +void
1.48 +__vector__<_Tp, _Alloc>::reserve(size_type __n) {
1.49 + if (capacity() < __n) {
1.50 + const size_type __old_size = size();
1.51 + pointer __tmp;
1.52 + if (this->_M_start) {
1.53 + __tmp = _M_allocate_and_copy(__n, this->_M_start, this->_M_finish);
1.54 + _M_clear();
1.55 + } else {
1.56 + __tmp = this->_M_end_of_storage.allocate(__n);
1.57 + }
1.58 + _M_set(__tmp, __tmp + __old_size, __tmp + __n);
1.59 + }
1.60 +}
1.61 +
1.62 +template <class _Tp, class _Alloc>
1.63 +void
1.64 +__vector__<_Tp, _Alloc>::_M_fill_insert(
1.65 + iterator __position,
1.66 + size_type __n, const _Tp& __x) {
1.67 + if (__n != 0) {
1.68 + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
1.69 + _Tp __x_copy = __x;
1.70 + const size_type __elems_after = this->_M_finish - __position;
1.71 + pointer __old_finish = this->_M_finish;
1.72 + if (__elems_after > __n) {
1.73 + __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType());
1.74 + this->_M_finish += __n;
1.75 + __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss());
1.76 + _STLP_STD::fill(__position, __position + __n, __x_copy);
1.77 + }
1.78 + else {
1.79 + uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x_copy);
1.80 + this->_M_finish += __n - __elems_after;
1.81 + __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType());
1.82 + this->_M_finish += __elems_after;
1.83 + _STLP_STD::fill(__position, __old_finish, __x_copy);
1.84 + }
1.85 + }
1.86 + else
1.87 + _M_insert_overflow(__position, __x, _IsPODType(), __n);
1.88 + }
1.89 +}
1.90 +
1.91 +template <class _Tp, class _Alloc>
1.92 +__vector__<_Tp,_Alloc>&
1.93 +__vector__<_Tp,_Alloc>::operator=(const __vector__<_Tp, _Alloc>& __x)
1.94 +{
1.95 + if (&__x != this) {
1.96 + const size_type __xlen = __x.size();
1.97 + if (__xlen > capacity()) {
1.98 + pointer __tmp = _M_allocate_and_copy(__xlen, (const_pointer)__x._M_start+0, (const_pointer)__x._M_finish+0);
1.99 + _M_clear();
1.100 + this->_M_start = __tmp;
1.101 + this->_M_end_of_storage._M_data = this->_M_start + __xlen;
1.102 + }
1.103 + else if (size() >= __xlen) {
1.104 + pointer __i = __copy_ptrs((const_pointer)__x._M_start+0, (const_pointer)__x._M_finish+0, (pointer)this->_M_start, _TrivialAss());
1.105 + _STLP_STD::_Destroy(__i, this->_M_finish);
1.106 + }
1.107 + else {
1.108 + __copy_ptrs((const_pointer)__x._M_start, (const_pointer)__x._M_start + size(), (pointer)this->_M_start, _TrivialAss());
1.109 + __uninitialized_copy((const_pointer)__x._M_start + size(), (const_pointer)__x._M_finish+0, this->_M_finish, _IsPODType());
1.110 + }
1.111 + this->_M_finish = this->_M_start + __xlen;
1.112 + }
1.113 + return *this;
1.114 +}
1.115 +
1.116 +template <class _Tp, class _Alloc>
1.117 +void __vector__<_Tp, _Alloc>::_M_fill_assign(size_t __n, const _Tp& __val) {
1.118 + if (__n > capacity()) {
1.119 + __vector__<_Tp, _Alloc> __tmp(__n, __val, get_allocator());
1.120 + __tmp.swap(*this);
1.121 + }
1.122 + else if (__n > size()) {
1.123 + fill(begin(), end(), __val);
1.124 + this->_M_finish = _STLP_STD::uninitialized_fill_n(this->_M_finish, __n - size(), __val);
1.125 + }
1.126 + else
1.127 + erase(_STLP_STD::fill_n(begin(), __n, __val), end());
1.128 +}
1.129 +
1.130 +_STLP_END_NAMESPACE
1.131 +
1.132 +# undef size_type
1.133 +# undef iterator
1.134 +# undef vector
1.135 +
1.136 +#endif /* _STLP_VECTOR_C */
1.137 +
1.138 + // Local Variables:
1.139 + // mode:C++
1.140 + // End: