Commit f6592a9e by Paolo Carlini Committed by Paolo Carlini

deque.tcc: Wrap overlong lines...

2004-02-01  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/deque.tcc: Wrap overlong lines, constify
	a few variables, reformat according to the coding standards.
	* include/bits/list.tcc: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_function.h: Likewise.
	* include/bits/stl_iterator.h: Likewise.
	* include/bits/stl_iterator_base_funcs.h: Likewise.
	* include/bits/stl_iterator_base_types.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_relops.h: Likewise.
	* include/bits/stl_set.h: Likewise.

From-SVN: r77077
parent e0a24727
2004-02-01 Paolo Carlini <pcarlini@suse.de>
* include/bits/deque.tcc: Wrap overlong lines, constify
a few variables, reformat according to the coding standards.
* include/bits/list.tcc: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_function.h: Likewise.
* include/bits/stl_iterator.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.
* include/bits/stl_iterator_base_types.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/bits/stl_relops.h: Likewise.
* include/bits/stl_set.h: Likewise.
2004-02-01 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_bvector.h: Wrap overlong lines, constify
a few variables, reformat according to the coding standards.
* include/bits/stl_tree.h: Likewise.
......
// List implementation (out of line) -*- 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
......@@ -120,18 +120,18 @@ namespace __gnu_norm
operator=(const list& __x)
{
if (this != &__x)
{
iterator __first1 = begin();
iterator __last1 = end();
const_iterator __first2 = __x.begin();
const_iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
*__first1++ = *__first2++;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
}
{
iterator __first1 = begin();
iterator __last1 = end();
const_iterator __first2 = __x.begin();
const_iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
*__first1++ = *__first2++;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
}
return *this;
}
......@@ -191,7 +191,8 @@ namespace __gnu_norm
{
iterator __first = begin();
iterator __last = end();
if (__first == __last) return;
if (__first == __last)
return;
iterator __next = __first;
while (++__next != __last)
{
......@@ -245,19 +246,21 @@ namespace __gnu_norm
list * __counter;
do
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = &__tmp[0];
(__counter != __fill) && !__counter->empty();
++__counter)
{
__counter->merge(__carry);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill) ++__fill;
} while ( !empty() );
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = &__tmp[0];
(__counter != __fill) && !__counter->empty();
++__counter)
{
__counter->merge(__carry);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill)
++__fill;
}
while ( !empty() );
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
__counter->merge( *(__counter-1) );
......@@ -277,7 +280,8 @@ namespace __gnu_norm
{
iterator __next = __first;
++__next;
if (__pred(*__first)) _M_erase(__first);
if (__pred(*__first))
_M_erase(__first);
__first = __next;
}
}
......@@ -332,39 +336,41 @@ namespace __gnu_norm
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp,_Alloc>::
sort(_StrictWeakOrdering __comp)
{
// Do nothing if the list has length 0 or 1.
if (this->_M_node._M_next != &this->_M_node &&
this->_M_node._M_next->_M_next != &this->_M_node)
void
list<_Tp,_Alloc>::
sort(_StrictWeakOrdering __comp)
{
list __carry;
list __tmp[64];
list * __fill = &__tmp[0];
list * __counter;
do
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = &__tmp[0];
(__counter != __fill) && !__counter->empty();
++__counter)
{
__counter->merge(__carry, __comp);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill) ++__fill;
} while ( !empty() );
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
__counter->merge( *(__counter-1), __comp );
swap( *(__fill-1) );
// Do nothing if the list has length 0 or 1.
if (this->_M_node._M_next != &this->_M_node
&& this->_M_node._M_next->_M_next != &this->_M_node)
{
list __carry;
list __tmp[64];
list * __fill = &__tmp[0];
list * __counter;
do
{
__carry.splice(__carry.begin(), *this, begin());
for(__counter = &__tmp[0];
(__counter != __fill) && !__counter->empty();
++__counter)
{
__counter->merge(__carry, __comp);
__carry.swap(*__counter);
}
__carry.swap(*__counter);
if (__counter == __fill)
++__fill;
}
while ( !empty() );
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
__counter->merge( *(__counter-1), __comp );
swap( *(__fill-1) );
}
}
}
} // namespace __gnu_norm
#endif /* _LIST_TCC */
......
// Functions used by iterators -*- 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
......@@ -78,9 +78,11 @@ namespace std
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
typename iterator_traits<_InputIterator>::difference_type __n = 0;
while (__first != __last) {
++__first; ++__n;
}
while (__first != __last)
{
++__first;
++__n;
}
return __n;
}
......@@ -90,7 +92,8 @@ namespace std
random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
return __last - __first;
}
......@@ -111,7 +114,8 @@ namespace std
distance(_InputIterator __first, _InputIterator __last)
{
// concept requirements -- taken care of in __distance
return std::__distance(__first, __last, std::__iterator_category(__first));
return std::__distance(__first, __last,
std::__iterator_category(__first));
}
template<typename _InputIterator, typename _Distance>
......@@ -120,7 +124,8 @@ namespace std
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
while (__n--) ++__i;
while (__n--)
++__i;
}
template<typename _BidirectionalIterator, typename _Distance>
......@@ -129,8 +134,8 @@ namespace std
bidirectional_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
__glibcxx_function_requires(_BidirectionalIteratorConcept<
_BidirectionalIterator>)
if (__n > 0)
while (__n--) ++__i;
else
......@@ -143,7 +148,8 @@ namespace std
random_access_iterator_tag)
{
// concept requirements
__glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
__glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>)
__i += __n;
}
......
// Types used in iterator implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 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
......@@ -82,9 +82,11 @@ namespace std
struct output_iterator_tag {};
/// Forward iterators support a superset of input iterator operations.
struct forward_iterator_tag : public input_iterator_tag {};
/// Bidirectional iterators support a superset of forward iterator operations.
/// Bidirectional iterators support a superset of forward iterator
/// operations.
struct bidirectional_iterator_tag : public forward_iterator_tag {};
/// Random-access iterators support a superset of bidirectional iterator operations.
/// Random-access iterators support a superset of bidirectional iterator
/// operations.
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
//@}
......
......@@ -94,7 +94,6 @@ namespace __gnu_norm
_Tp _M_data; ///< User's data.
};
/**
* @brief A list::iterator.
*
......@@ -325,7 +324,6 @@ namespace __gnu_norm
}
};
/**
* @brief A standard container with linear time access to elements,
* and fixed time insertion/deletion at any point in the sequence.
......@@ -573,7 +571,8 @@ namespace __gnu_norm
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const { return _Base::get_allocator(); }
get_allocator() const
{ return _Base::get_allocator(); }
// iterators
/**
......@@ -581,7 +580,8 @@ namespace __gnu_norm
* %list. Iteration is done in ordinary element order.
*/
iterator
begin() { return this->_M_node._M_next; }
begin()
{ return this->_M_node._M_next; }
/**
* Returns a read-only (constant) iterator that points to the
......@@ -589,7 +589,8 @@ namespace __gnu_norm
* element order.
*/
const_iterator
begin() const { return this->_M_node._M_next; }
begin() const
{ return this->_M_node._M_next; }
/**
* Returns a read/write iterator that points one past the last
......@@ -605,7 +606,8 @@ namespace __gnu_norm
* element order.
*/
const_iterator
end() const { return &this->_M_node; }
end() const
{ return &this->_M_node; }
/**
* Returns a read/write reverse iterator that points to the last
......@@ -613,7 +615,8 @@ namespace __gnu_norm
* order.
*/
reverse_iterator
rbegin() { return reverse_iterator(end()); }
rbegin()
{ return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points to
......@@ -621,7 +624,8 @@ namespace __gnu_norm
* 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
......@@ -629,7 +633,8 @@ namespace __gnu_norm
* reverse element order.
*/
reverse_iterator
rend() { return reverse_iterator(begin()); }
rend()
{ return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points to one
......@@ -646,15 +651,18 @@ namespace __gnu_norm
* end().)
*/
bool
empty() const { return this->_M_node._M_next == &this->_M_node; }
empty() const
{ return this->_M_node._M_next == &this->_M_node; }
/** Returns the number of elements in the %list. */
size_type
size() const { return std::distance(begin(), end()); }
size() const
{ return std::distance(begin(), end()); }
/** Returns the size() of the largest possible %list. */
size_type
max_size() const { return size_type(-1); }
max_size() const
{ return size_type(-1); }
/**
* @brief Resizes the %list to the specified number of elements.
......@@ -679,7 +687,8 @@ namespace __gnu_norm
* and new elements are default-constructed.
*/
void
resize(size_type __new_size) { this->resize(__new_size, value_type()); }
resize(size_type __new_size)
{ this->resize(__new_size, value_type()); }
// element access
/**
......@@ -687,28 +696,32 @@ namespace __gnu_norm
* element of the %list.
*/
reference
front() { return *begin(); }
front()
{ return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %list.
*/
const_reference
front() const { return *begin(); }
front() const
{ return *begin(); }
/**
* Returns a read/write reference to the data at the last element
* of the %list.
*/
reference
back() { return *(--end()); }
back()
{ return *(--end()); }
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %list.
*/
const_reference
back() const { return *(--end()); }
back() const
{ return *(--end()); }
// [23.2.2.3] modifiers
/**
......@@ -722,7 +735,8 @@ namespace __gnu_norm
* references.
*/
void
push_front(const value_type& __x) { this->_M_insert(begin(), __x); }
push_front(const value_type& __x)
{ this->_M_insert(begin(), __x); }
/**
* @brief Removes first element.
......@@ -737,7 +751,8 @@ namespace __gnu_norm
* called.
*/
void
pop_front() { this->_M_erase(begin()); }
pop_front()
{ this->_M_erase(begin()); }
/**
* @brief Add data to the end of the %list.
......@@ -750,7 +765,8 @@ namespace __gnu_norm
* references.
*/
void
push_back(const value_type& __x) { this->_M_insert(end(), __x); }
push_back(const value_type& __x)
{ this->_M_insert(end(), __x); }
/**
* @brief Removes last element.
......@@ -764,7 +780,8 @@ namespace __gnu_norm
* is needed, it should be retrieved before pop_back() is called.
*/
void
pop_back() { this->_M_erase(this->_M_node._M_prev); }
pop_back()
{ this->_M_erase(this->_M_node._M_prev); }
/**
* @brief Inserts given value into %list before specified iterator.
......@@ -876,7 +893,8 @@ namespace __gnu_norm
* function.
*/
void
swap(list& __x) { _List_node_base::swap(this->_M_node,__x._M_node); }
swap(list& __x)
{ _List_node_base::swap(this->_M_node,__x._M_node); }
/**
* Erases all the elements. Note that this function only erases
......@@ -922,7 +940,8 @@ namespace __gnu_norm
{
iterator __j = __i;
++__j;
if (__position == __i || __position == __j) return;
if (__position == __i || __position == __j)
return;
this->_M_transfer(__position, __i, __j);
}
......@@ -1037,7 +1056,8 @@ namespace __gnu_norm
* Reverse the order of elements in the list in linear time.
*/
void
reverse() { this->_M_node.reverse(); }
reverse()
{ this->_M_node.reverse(); }
/**
* @brief Sort the elements.
......@@ -1118,16 +1138,13 @@ namespace __gnu_norm
// Moves the elements from [first,last) before position.
void
_M_transfer(iterator __position, iterator __first, iterator __last)
{
__position._M_node->transfer(__first._M_node,__last._M_node);
}
{ __position._M_node->transfer(__first._M_node,__last._M_node); }
// Inserts new element at position given and with value given.
void
_M_insert(iterator __position, const value_type& __x)
{
_Node* __tmp = _M_create_node(__x);
__tmp->hook(__position._M_node);
}
......@@ -1142,7 +1159,6 @@ namespace __gnu_norm
}
};
/**
* @brief List equality comparison.
* @param x A %list.
......@@ -1167,7 +1183,7 @@ namespace __gnu_norm
{
++__i1;
++__i2;
}
}
return __i1 == __end1 && __i2 == __end2;
}
......@@ -1185,10 +1201,8 @@ namespace __gnu_norm
template<typename _Tp, typename _Alloc>
inline bool
operator<(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
{
return std::lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end());
}
{ return std::lexicographical_compare(__x.begin(), __x.end(),
__y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
......
// std::rel_ops implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 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
......@@ -75,61 +75,61 @@ namespace std
{
namespace rel_ops
{
/** @namespace std::rel_ops
* @brief The generated relational operators are sequestered here.
*/
/** @namespace std::rel_ops
* @brief The generated relational operators are sequestered here.
*/
/**
* @brief Defines @c != for arbitrary types, in terms of @c ==.
* @param x A thing.
* @param y Another thing.
* @return x != y
*
* This function uses @c == to determine its result.
*/
template <class _Tp>
inline bool
operator!=(const _Tp& __x, const _Tp& __y)
{ return !(__x == __y); }
/**
* @brief Defines @c != for arbitrary types, in terms of @c ==.
* @param x A thing.
* @param y Another thing.
* @return x != y
*
* This function uses @c == to determine its result.
*/
template <class _Tp>
inline bool operator!=(const _Tp& __x, const _Tp& __y) {
return !(__x == __y);
}
/**
* @brief Defines @c > for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x > y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool
operator>(const _Tp& __x, const _Tp& __y)
{ return __y < __x; }
/**
* @brief Defines @c > for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x > y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool operator>(const _Tp& __x, const _Tp& __y) {
return __y < __x;
}
/**
* @brief Defines @c <= for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x <= y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool
operator<=(const _Tp& __x, const _Tp& __y)
{ return !(__y < __x); }
/**
* @brief Defines @c <= for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x <= y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool operator<=(const _Tp& __x, const _Tp& __y) {
return !(__y < __x);
}
/**
* @brief Defines @c >= for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x >= y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool operator>=(const _Tp& __x, const _Tp& __y) {
return !(__x < __y);
}
/**
* @brief Defines @c >= for arbitrary types, in terms of @c <.
* @param x A thing.
* @param y Another thing.
* @return x >= y
*
* This function uses @c < to determine its result.
*/
template <class _Tp>
inline bool
operator>=(const _Tp& __x, const _Tp& __y)
{ return !(__x < __y); }
} // namespace rel_ops
} // namespace std
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment