Commit 4d54539c by Benjamin Kosnik Committed by Benjamin Kosnik

stl_list.h: Formatting tweaks.


2003-12-18  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/stl_list.h: Formatting tweaks.
	* include/bits/list.tcc: Same.

From-SVN: r74795
parent 91d39d71
2003-12-18 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_list.h: Formatting tweaks.
* include/bits/list.tcc: Same.
2003-12-18 Matt Austern <austern@apple.com>
* include/bits/demangle.h: Fix allocator type correctness,
......
......@@ -66,7 +66,7 @@ namespace __gnu_norm
template<typename _Tp, typename _Alloc>
void
_List_base<_Tp,_Alloc>::
__clear()
_M_clear()
{
typedef _List_node<_Tp> _Node;
_Node* __cur = static_cast<_Node*>(this->_M_node._M_next);
......@@ -92,7 +92,8 @@ namespace __gnu_norm
this->_M_node._M_next = __x._M_node._M_next;
this->_M_node._M_prev = __x._M_node._M_prev;
this->_M_node._M_next->_M_prev = this->_M_node._M_prev->_M_next = &this->_M_node;
this->_M_node._M_prev->_M_next = &this->_M_node;
this->_M_node._M_next->_M_prev = this->_M_node._M_prev->_M_next;
__x._M_node._M_next = __x._M_node._M_prev = &__x._M_node;
}
}
......@@ -101,7 +102,8 @@ namespace __gnu_norm
__x._M_node._M_next = this->_M_node._M_next;
__x._M_node._M_prev = this->_M_node._M_prev;
__x._M_node._M_next->_M_prev = __x._M_node._M_prev->_M_next = &__x._M_node;
__x._M_node._M_prev->_M_next = &__x._M_node;
__x._M_node._M_next->_M_prev = __x._M_node._M_prev->_M_next;
this->_M_node._M_next = this->_M_node._M_prev = &this->_M_node;
}
else
......@@ -109,8 +111,10 @@ namespace __gnu_norm
std::swap(this->_M_node._M_next,__x._M_node._M_next);
std::swap(this->_M_node._M_prev,__x._M_node._M_prev);
this->_M_node._M_next->_M_prev = this->_M_node._M_prev->_M_next = &this->_M_node;
__x._M_node._M_next->_M_prev = __x._M_node._M_prev->_M_next = &__x._M_node;
this->_M_node._M_prev->_M_next = &this->_M_node;
this->_M_node._M_next->_M_prev = this->_M_node._M_prev->_M_next;
__x._M_node._M_prev->_M_next = &__x._M_node;
__x._M_node._M_next->_M_prev = __x._M_node._M_prev->_M_next;
}
}
......@@ -196,11 +200,13 @@ namespace __gnu_norm
template <typename _InputIterator>
void
list<_Tp,_Alloc>::
_M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, __false_type)
_M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
__false_type)
{
iterator __first1 = begin();
iterator __last1 = end();
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
for (; __first1 != __last1 && __first2 != __last2;
++__first1, ++__first2)
*__first1 = *__first2;
if (__first2 == __last2)
erase(__first1, __last1);
......@@ -276,10 +282,12 @@ namespace __gnu_norm
__List_base_reverse(_List_node_base* __p)
{
_List_node_base* __tmp = __p;
do {
do
{
std::swap(__tmp->_M_next, __tmp->_M_prev);
__tmp = __tmp->_M_prev; // Old next node is now prev.
} while (__tmp != __p);
}
while (__tmp != __p);
}
template<typename _Tp, typename _Alloc>
......
......@@ -104,11 +104,9 @@ namespace __gnu_norm
_List_node_base* _M_node;
_List_iterator_base(_List_node_base* __x)
: _M_node(__x)
{ }
: _M_node(__x) { }
_List_iterator_base()
{ }
_List_iterator_base() { }
/// Walk the %list forward.
void
......@@ -152,20 +150,17 @@ namespace __gnu_norm
typedef _List_node<_Tp> _Node;
_List_iterator(_Node* __x)
: _List_iterator_base(__x)
{ }
: _List_iterator_base(__x) { }
_List_iterator()
{ }
_List_iterator() { }
_List_iterator(const iterator& __x)
: _List_iterator_base(__x._M_node)
{ }
: _List_iterator_base(__x._M_node) { }
// Must downcast from List_node_base to _List_node to get to _M_data.
reference
operator*() const
{ return static_cast<_Node*>(_M_node)->_M_data; }
// Must downcast from List_node_base to _List_node to get to _M_data.
pointer
operator->() const
......@@ -207,25 +202,29 @@ namespace __gnu_norm
* See bits/stl_deque.h's _Deque_base for an explanation.
* @endif
*/
template <typename _Tp, typename _Alloc>
template<typename _Tp, typename _Alloc>
class _List_base
: public _Alloc::template rebind<_List_node<_Tp> >::other
{
protected:
// NOTA BENE
// The stored instance is not actually of "allocator_type"'s type.
// Instead we rebind the type to Allocator<List_node<Tp>>, which
// according to [20.1.5]/4 should probably be the same.
// List_node<Tp> is not the same size as Tp (it's two pointers
// larger), and specializations on Tp may go unused because
// List_node<Tp> is being bound instead.
// The stored instance is not actually of "allocator_type"'s
// type. Instead we rebind the type to
// Allocator<List_node<Tp>>, which according to [20.1.5]/4
// should probably be the same. List_node<Tp> is not the same
// size as Tp (it's two pointers larger), and specializations on
// Tp may go unused because List_node<Tp> is being bound
// instead.
//
// We put this to the test in the constructors and in get_allocator,
// where we use conversions between allocator_type and
// _Node_Alloc_type. The conversion is required by table 32 in [20.1.5].
// We put this to the test in the constructors and in
// get_allocator, where we use conversions between
// allocator_type and _Node_Alloc_type. The conversion is
// required by table 32 in [20.1.5].
typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
_Node_Alloc_type;
_List_node_base _M_node;
_List_node<_Tp>*
_M_get_node()
{ return _Node_Alloc_type::allocate(1); }
......@@ -234,11 +233,11 @@ namespace __gnu_norm
_M_put_node(_List_node<_Tp>* __p)
{ _Node_Alloc_type::deallocate(__p, 1); }
_List_node_base _M_node;
public:
typedef _Alloc allocator_type;
allocator_type get_allocator() const
allocator_type
get_allocator() const
{ return allocator_type(*static_cast<const _Node_Alloc_type*>(this)); }
_List_base(const allocator_type& __a)
......@@ -250,18 +249,16 @@ namespace __gnu_norm
// This is what actually destroys the list.
~_List_base()
{
__clear();
}
{ _M_clear(); }
void
__clear();
_M_clear();
};
/**
* @brief A standard container with linear time access to elements, and
* fixed time insertion/deletion at any point in the sequence.
* @brief A standard container with linear time access to elements,
* and fixed time insertion/deletion at any point in the sequence.
*
* @ingroup Containers
* @ingroup Sequences
......@@ -327,13 +324,14 @@ namespace __gnu_norm
typedef typename _Base::allocator_type allocator_type;
protected:
// Note that pointers-to-_Node's can be ctor-converted to iterator types.
// Note that pointers-to-_Node's can be ctor-converted to
// iterator types.
typedef _List_node<_Tp> _Node;
/** @if maint
* One data member plus two memory-handling functions. If the _Alloc
* type requires separate instances, then one of those will also be
* included, accumulated from the topmost parent.
* One data member plus two memory-handling functions. If the
* _Alloc type requires separate instances, then one of those
* will also be included, accumulated from the topmost parent.
* @endif
*/
using _Base::_M_node;
......@@ -351,7 +349,8 @@ namespace __gnu_norm
_M_create_node(const value_type& __x)
{
_Node* __p = this->_M_get_node();
try {
try
{
std::_Construct(&__p->_M_data, __x);
}
catch(...)
......@@ -364,15 +363,16 @@ namespace __gnu_norm
/**
* @if maint
* Allocates space for a new node and default-constructs a new instance
* of @c value_type in it.
* Allocates space for a new node and default-constructs a new
* instance of @c value_type in it.
* @endif
*/
_Node*
_M_create_node()
{
_Node* __p = this->_M_get_node();
try {
try
{
std::_Construct(&__p->_M_data);
}
catch(...)
......@@ -452,8 +452,8 @@ namespace __gnu_norm
* No explicit dtor needed as the _Base dtor takes care of
* things. The _Base dtor only erases the elements, and note
* that if the elements themselves are pointers, the pointed-to
* memory is not touched in any way. Managing the pointer is the
* user's responsibilty.
* memory is not touched in any way. Managing the pointer is
* the user's responsibilty.
*/
/**
......@@ -488,9 +488,9 @@ namespace __gnu_norm
* This function fills a %list with copies of the elements in the
* range [@a first,@a last).
*
* Note that the assignment completely changes the %list and that the
* resulting %list's size is the same as the number of elements assigned.
* Old data may be lost.
* Note that the assignment completely changes the %list and
* that the resulting %list's size is the same as the number of
* elements assigned. Old data may be lost.
*/
template<typename _InputIterator>
void
......@@ -536,7 +536,7 @@ namespace __gnu_norm
*/
const_iterator
end() const
{ return const_cast<_Node *>(static_cast<const _Node*>(&this->_M_node)); }
{ return const_cast<_Node*>(static_cast<const _Node*>(&this->_M_node)); }
/**
* Returns a read/write reverse iterator that points to the last
......@@ -614,8 +614,8 @@ namespace __gnu_norm
// element access
/**
* Returns a read/write reference to the data at the first element of the
* %list.
* Returns a read/write reference to the data at the first
* element of the %list.
*/
reference
front() { return *begin(); }
......@@ -707,8 +707,8 @@ namespace __gnu_norm
* @param x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before the
* specified location. Due to the nature of a %list this
* This function will insert a copy of the given value before
* the specified location. Due to the nature of a %list this
* operation can be done in constant time, and does not
* invalidate iterators and references.
*/
......@@ -742,8 +742,9 @@ namespace __gnu_norm
* first,@a last) into the %list before the location specified by
* @a position.
*
* Due to the nature of a %list this operation can be done in constant
* time, and does not invalidate iterators and references.
* Due to the nature of a %list this operation can be done in
* constant time, and does not invalidate iterators and
* references.
*/
template<typename _InputIterator>
void
......@@ -819,7 +820,7 @@ namespace __gnu_norm
* Managing the pointer is the user's responsibilty.
*/
void
clear() { _Base::__clear(); }
clear() { _Base::_M_clear(); }
// [23.2.2.4] list operations
/**
......@@ -882,8 +883,9 @@ namespace __gnu_norm
* Removes every element in the list equal to @a value.
* Remaining elements stay in list order. Note that this
* function only erases the elements, and that if the elements
* themselves are pointers, the pointed-to memory is not touched
* in any way. Managing the pointer is the user's responsibilty.
* themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* responsibilty.
*/
void
remove(const _Tp& __value);
......@@ -895,8 +897,8 @@ namespace __gnu_norm
* Removes every element in the list for which the predicate
* returns true. Remaining elements stay in list order. Note
* that this function only erases the elements, and that if the
* elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's
* elements themselves are pointers, the pointed-to memory is
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
template<typename _Predicate>
......@@ -907,11 +909,11 @@ namespace __gnu_norm
* @brief Remove consecutive duplicate elements.
*
* For each consecutive set of elements with the same value,
* remove all but the first one. Remaining elements stay in list
* order. Note that this function only erases the elements, and
* that if the elements themselves are pointers, the pointed-to
* memory is not touched in any way. Managing the pointer is the
* user's responsibilty.
* remove all but the first one. Remaining elements stay in
* list order. Note that this function only erases the
* elements, and that if the elements themselves are pointers,
* the pointed-to memory is not touched in any way. Managing
* the pointer is the user's responsibilty.
*/
void
unique();
......@@ -920,13 +922,13 @@ namespace __gnu_norm
* @brief Remove consecutive elements satisfying a predicate.
* @param BinaryPredicate Binary predicate function or object.
*
* For each consecutive set of elements [first,last) that satisfy
* predicate(first,i) where i is an iterator in [first,last),
* remove all but the first one. Remaining elements stay in list
* order. Note that this function only erases the elements, and
* that if the elements themselves are pointers, the pointed-to
* memory is not touched in any way. Managing the pointer is the
* user's responsibilty.
* For each consecutive set of elements [first,last) that
* satisfy predicate(first,i) where i is an iterator in
* [first,last), remove all but the first one. Remaining
* elements stay in list order. Note that this function only
* erases the elements, and that if the elements themselves are
* pointers, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibilty.
*/
template<typename _BinaryPredicate>
void
......@@ -937,9 +939,9 @@ namespace __gnu_norm
* @param x Sorted list to merge.
*
* Assumes that both @a x and this list are sorted according to
* operator<(). Merges elements of @a x into this list in sorted
* order, leaving @a x empty when complete. Elements in this
* list precede elements in @a x that are equal.
* operator<(). Merges elements of @a x into this list in
* sorted order, leaving @a x empty when complete. Elements in
* this list precede elements in @a x that are equal.
*/
void
merge(list& __x);
......@@ -947,12 +949,13 @@ namespace __gnu_norm
/**
* @brief Merge sorted lists according to comparison function.
* @param x Sorted list to merge.
* @param StrictWeakOrdering Comparison function definining sort order.
* @param StrictWeakOrdering Comparison function definining
* sort order.
*
* Assumes that both @a x and this list are sorted according to
* StrictWeakOrdering. Merges elements of @a x into this list in
* sorted order, leaving @a x empty when complete. Elements in
* this list precede elements in @a x that are equivalent
* StrictWeakOrdering. Merges elements of @a x into this list
* in sorted order, leaving @a x empty when complete. Elements
* in this list precede elements in @a x that are equivalent
* according to StrictWeakOrdering().
*/
template<typename _StrictWeakOrdering>
......@@ -1047,7 +1050,8 @@ namespace __gnu_norm
void
_M_transfer(iterator __position, iterator __first, iterator __last)
{
if (__position != __last) {
if (__position != __last)
{
// Remove [first, last) from its old position.
__last._M_node->_M_prev->_M_next = __position._M_node;
__first._M_node->_M_prev->_M_next = __last._M_node;
......@@ -1083,7 +1087,8 @@ namespace __gnu_norm
const_iterator __i1 = __x.begin();
const_iterator __i2 = __y.begin();
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
{
++__i1;
++__i2;
}
......
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