summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/stl_vector.h
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-26 09:02:43 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-26 09:02:43 +0000
commit92ae97d4fcf5c04d33858c2878c169a2b968a61d (patch)
treeebab6244dec5b697c539e625b618fcfeecaf69b8 /libstdc++-v3/include/bits/stl_vector.h
parenta1ebe36a460aa5c6dafd1b24b745db0c29f05d31 (diff)
downloadgcc-92ae97d4fcf5c04d33858c2878c169a2b968a61d.tar.gz
2004-04-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_vector.h: Trivial formatting fixes. * include/bits/vector.tcc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81178 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/stl_vector.h')
-rw-r--r--libstdc++-v3/include/bits/stl_vector.h160
1 files changed, 100 insertions, 60 deletions
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index b025393a741..8a741b4d9dc 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -1,6 +1,6 @@
// Vector implementation -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -76,12 +76,13 @@ namespace _GLIBCXX_STD
struct _Vector_base
{
struct _Vector_impl
- : public _Alloc {
+ : public _Alloc
+ {
_Tp* _M_start;
_Tp* _M_finish;
_Tp* _M_end_of_storage;
_Vector_impl (_Alloc const& __a)
- : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
+ : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ }
};
@@ -89,13 +90,15 @@ namespace _GLIBCXX_STD
typedef _Alloc allocator_type;
allocator_type
- get_allocator() const { return *static_cast<const _Alloc*>(&this->_M_impl); }
+ get_allocator() const
+ { return *static_cast<const _Alloc*>(&this->_M_impl); }
- _Vector_base(const allocator_type& __a) : _M_impl(__a)
+ _Vector_base(const allocator_type& __a)
+ : _M_impl(__a)
{ }
_Vector_base(size_t __n, const allocator_type& __a)
- : _M_impl(__a)
+ : _M_impl(__a)
{
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_finish = this->_M_impl._M_start;
@@ -103,18 +106,21 @@ namespace _GLIBCXX_STD
}
~_Vector_base()
- { _M_deallocate(this->_M_impl._M_start,
- this->_M_impl._M_end_of_storage - this->_M_impl._M_start); }
+ { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
+ - this->_M_impl._M_start); }
public:
_Vector_impl _M_impl;
_Tp*
- _M_allocate(size_t __n) { return _M_impl.allocate(__n); }
+ _M_allocate(size_t __n)
+ { return _M_impl.allocate(__n); }
void
_M_deallocate(_Tp* __p, size_t __n)
- { if (__p) _M_impl.deallocate(__p, __n); }
+ { if (__p)
+ _M_impl.deallocate(__p, __n);
+ }
};
@@ -179,7 +185,8 @@ namespace _GLIBCXX_STD
*/
explicit
vector(const allocator_type& __a = allocator_type())
- : _Base(__a) { }
+ : _Base(__a)
+ { }
/**
* @brief Create a %vector with copies of an exemplar element.
@@ -191,8 +198,9 @@ namespace _GLIBCXX_STD
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
- { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
- __n, __value); }
+ { this->_M_impl._M_finish = std::uninitialized_fill_n(this->
+ _M_impl._M_start,
+ __n, __value); }
/**
* @brief Create a %vector with default elements.
@@ -204,8 +212,10 @@ namespace _GLIBCXX_STD
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
- { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
- __n, value_type()); }
+ { this->_M_impl._M_finish = std::uninitialized_fill_n(this->
+ _M_impl._M_start,
+ __n,
+ value_type()); }
/**
* @brief %Vector copy constructor.
@@ -218,8 +228,10 @@ namespace _GLIBCXX_STD
*/
vector(const vector& __x)
: _Base(__x.size(), __x.get_allocator())
- { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(), __x.end(),
- this->_M_impl._M_start);
+ { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(),
+ __x.end(),
+ this->
+ _M_impl._M_start);
}
/**
@@ -253,7 +265,8 @@ namespace _GLIBCXX_STD
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
- ~vector() { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
+ ~vector()
+ { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
/**
* @brief %Vector assignment operator.
@@ -311,7 +324,8 @@ namespace _GLIBCXX_STD
* element order.
*/
iterator
- begin() { return iterator (this->_M_impl._M_start); }
+ begin()
+ { return iterator (this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points to the
@@ -319,7 +333,8 @@ namespace _GLIBCXX_STD
* element order.
*/
const_iterator
- begin() const { return const_iterator (this->_M_impl._M_start); }
+ begin() const
+ { return const_iterator (this->_M_impl._M_start); }
/**
* Returns a read/write iterator that points one past the last
@@ -327,7 +342,8 @@ namespace _GLIBCXX_STD
* element order.
*/
iterator
- end() { return iterator (this->_M_impl._M_finish); }
+ end()
+ { return iterator (this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
@@ -335,7 +351,8 @@ namespace _GLIBCXX_STD
* ordinary element order.
*/
const_iterator
- end() const { return const_iterator (this->_M_impl._M_finish); }
+ end() const
+ { return const_iterator (this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to the
@@ -343,7 +360,8 @@ namespace _GLIBCXX_STD
* element order.
*/
reverse_iterator
- rbegin() { return reverse_iterator(end()); }
+ rbegin()
+ { return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points
@@ -351,7 +369,8 @@ namespace _GLIBCXX_STD
* reverse element order.
*/
const_reverse_iterator
- rbegin() const { return const_reverse_iterator(end()); }
+ rbegin() const
+ { return const_reverse_iterator(end()); }
/**
* Returns a read/write reverse iterator that points to one
@@ -359,7 +378,8 @@ namespace _GLIBCXX_STD
* in reverse element order.
*/
reverse_iterator
- rend() { return reverse_iterator(begin()); }
+ rend()
+ { return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points
@@ -367,16 +387,19 @@ namespace _GLIBCXX_STD
* is done in reverse element order.
*/
const_reverse_iterator
- rend() const { return const_reverse_iterator(begin()); }
+ rend() const
+ { return const_reverse_iterator(begin()); }
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
size_type
- size() const { return size_type(end() - begin()); }
+ size() const
+ { return size_type(end() - begin()); }
/** Returns the size() of the largest possible %vector. */
size_type
- max_size() const { return size_type(-1) / sizeof(value_type); }
+ max_size() const
+ { return size_type(-1) / sizeof(value_type); }
/**
* @brief Resizes the %vector to the specified number of elements.
@@ -409,7 +432,8 @@ namespace _GLIBCXX_STD
* default-constructed.
*/
void
- resize(size_type __new_size) { resize(__new_size, value_type()); }
+ resize(size_type __new_size)
+ { resize(__new_size, value_type()); }
/**
* Returns the total number of elements that the %vector can
@@ -417,14 +441,16 @@ namespace _GLIBCXX_STD
*/
size_type
capacity() const
- { return size_type(const_iterator(this->_M_impl._M_end_of_storage) - begin()); }
+ { return size_type(const_iterator(this->_M_impl._M_end_of_storage)
+ - begin()); }
/**
* Returns true if the %vector is empty. (Thus begin() would
* equal end().)
*/
bool
- empty() const { return begin() == end(); }
+ empty() const
+ { return begin() == end(); }
/**
* @brief Attempt to preallocate enough memory for specified number of
@@ -459,7 +485,8 @@ namespace _GLIBCXX_STD
* see at().)
*/
reference
- operator[](size_type __n) { return *(begin() + __n); }
+ operator[](size_type __n)
+ { return *(begin() + __n); }
/**
* @brief Subscript access to the data contained in the %vector.
@@ -473,7 +500,8 @@ namespace _GLIBCXX_STD
* see at().)
*/
const_reference
- operator[](size_type __n) const { return *(begin() + __n); }
+ operator[](size_type __n) const
+ { return *(begin() + __n); }
protected:
/// @if maint Safety check used only from at(). @endif
@@ -497,7 +525,11 @@ namespace _GLIBCXX_STD
* function throws out_of_range if the check fails.
*/
reference
- at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
+ at(size_type __n)
+ {
+ _M_range_check(__n);
+ return (*this)[__n];
+ }
/**
* @brief Provides access to the data contained in the %vector.
@@ -511,35 +543,43 @@ namespace _GLIBCXX_STD
* function throws out_of_range if the check fails.
*/
const_reference
- at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
+ at(size_type __n) const
+ {
+ _M_range_check(__n);
+ return (*this)[__n];
+ }
/**
* Returns a read/write reference to the data at the first
* element of the %vector.
*/
reference
- front() { return *begin(); }
+ front()
+ { return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %vector.
*/
const_reference
- front() const { return *begin(); }
+ front() const
+ { return *begin(); }
/**
* Returns a read/write reference to the data at the last
* element of the %vector.
*/
reference
- back() { return *(end() - 1); }
-
+ back()
+ { return *(end() - 1); }
+
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
*/
const_reference
- back() const { return *(end() - 1); }
+ back() const
+ { return *(end() - 1); }
// [23.2.4.3] modifiers
/**
@@ -688,7 +728,8 @@ namespace _GLIBCXX_STD
{
std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
- std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage);
+ std::swap(this->_M_impl._M_end_of_storage,
+ __x._M_impl._M_end_of_storage);
}
/**
@@ -698,7 +739,8 @@ namespace _GLIBCXX_STD
* the user's responsibilty.
*/
void
- clear() { erase(begin(), end()); }
+ clear()
+ { erase(begin(), end()); }
protected:
/**
@@ -735,8 +777,9 @@ namespace _GLIBCXX_STD
{
this->_M_impl._M_start = _M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
- this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
- __n, __value);
+ this->_M_impl._M_finish = std::uninitialized_fill_n(this->
+ _M_impl._M_start,
+ __n, __value);
}
// Called by the range constructor to implement [23.1.1]/9
@@ -770,7 +813,8 @@ namespace _GLIBCXX_STD
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
- this->_M_impl._M_start);
+ this->
+ _M_impl._M_start);
}
@@ -873,11 +917,9 @@ namespace _GLIBCXX_STD
*/
template<typename _Tp, typename _Alloc>
inline bool
- operator==(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
- {
- return __x.size() == __y.size() &&
- std::equal(__x.begin(), __x.end(), __y.begin());
- }
+ operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
+ { return (__x.size() == __y.size()
+ && std::equal(__x.begin(), __x.end(), __y.begin())); }
/**
* @brief Vector ordering relation.
@@ -892,40 +934,38 @@ namespace _GLIBCXX_STD
*/
template<typename _Tp, typename _Alloc>
inline bool
- operator<(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
- {
- return std::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end());
- }
+ operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
+ { return std::lexicographical_compare(__x.begin(), __x.end(),
+ __y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
- operator!=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
- operator>(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
- operator<=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
- operator>=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
+ operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::vector::swap().
template<typename _Tp, typename _Alloc>
inline void
- swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y)
+ swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace std