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