/**
* @brief A deque::iterator.
*
- * Quite a bit of intelligence here. Much of the functionality of deque is
- * actually passed off to this class. A deque holds two of these internally,
- * marking its valid range. Access to elements is done as offsets of either
- * of those two, relying on operator overloading in this class.
+ * Quite a bit of intelligence here. Much of the functionality of
+ * deque is actually passed off to this class. A deque holds two
+ * of these internally, marking its valid range. Access to
+ * elements is done as offsets of either of those two, relying on
+ * operator overloading in this class.
*
* @if maint
* All the functions are op overloads except for _M_set_node.
{ return *(*this + __n); }
/** @if maint
- * Prepares to traverse new_node. Sets everything except _M_cur, which
- * should therefore be set by the caller immediately afterwards, based on
- * _M_first and _M_last.
+ * Prepares to traverse new_node. Sets everything except
+ * _M_cur, which should therefore be set by the caller
+ * immediately afterwards, based on _M_first and _M_last.
* @endif
*/
void
_Deque_base<_Tp, _Alloc>::
_M_initialize_map(size_t __num_elements)
{
- const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp))
+ const size_t __num_nodes = (__num_elements/ __deque_buf_size(sizeof(_Tp))
+ 1);
this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size,
* - size_t _M_map_size
* - iterator _M_start, _M_finish
*
- * map_size is at least 8. %map is an array of map_size pointers-to-"nodes".
- * (The name %map has nothing to do with the std::map class, and "nodes"
- * should not be confused with std::list's usage of "node".)
+ * map_size is at least 8. %map is an array of map_size
+ * pointers-to-"nodes". (The name %map has nothing to do with the
+ * std::map class, and "nodes" should not be confused with
+ * std::list's usage of "node".)
*
- * A "node" has no specific type name as such, but it is referred to as
- * "node" in this file. It is a simple array-of-Tp. If Tp is very large,
- * there will be one Tp element per node (i.e., an "array" of one).
- * For non-huge Tp's, node size is inversely related to Tp size: the
- * larger the Tp, the fewer Tp's will fit in a node. The goal here is to
- * keep the total size of a node relatively small and constant over different
- * Tp's, to improve allocator efficiency.
+ * A "node" has no specific type name as such, but it is referred
+ * to as "node" in this file. It is a simple array-of-Tp. If Tp
+ * is very large, there will be one Tp element per node (i.e., an
+ * "array" of one). For non-huge Tp's, node size is inversely
+ * related to Tp size: the larger the Tp, the fewer Tp's will fit
+ * in a node. The goal here is to keep the total size of a node
+ * relatively small and constant over different Tp's, to improve
+ * allocator efficiency.
*
- * **** As I write this, the nodes are /not/ allocated using the high-speed
- * memory pool. There are 20 hours left in the year; perhaps I can fix
- * this before 2002.
- *
- * Not every pointer in the %map array will point to a node. If the initial
- * number of elements in the deque is small, the /middle/ %map pointers will
- * be valid, and the ones at the edges will be unused. This same situation
- * will arise as the %map grows: available %map pointers, if any, will be on
- * the ends. As new nodes are created, only a subset of the %map's pointers
- * need to be copied "outward".
+ * Not every pointer in the %map array will point to a node. If
+ * the initial number of elements in the deque is small, the
+ * /middle/ %map pointers will be valid, and the ones at the edges
+ * will be unused. This same situation will arise as the %map
+ * grows: available %map pointers, if any, will be on the ends. As
+ * new nodes are created, only a subset of the %map's pointers need
+ * to be copied "outward".
*
* Class invariants:
* - For any nonsingular iterator i:
* - i.cur is a pointer in the range [i.first, i.last). NOTE:
* the implication of this is that i.cur is always a dereferenceable
* pointer, even if i is a past-the-end iterator.
- * - Start and Finish are always nonsingular iterators. NOTE: this means that
- * an empty deque must have one node, a deque with <N elements (where N is
- * the node buffer size) must have one node, a deque with N through (2N-1)
- * elements must have two nodes, etc.
- * - For every node other than start.node and finish.node, every element in
- * the node is an initialized object. If start.node == finish.node, then
- * [start.cur, finish.cur) are initialized objects, and the elements outside
- * that range are uninitialized storage. Otherwise, [start.cur, start.last)
- * and [finish.first, finish.cur) are initialized objects, and [start.first,
- * start.cur) and [finish.cur, finish.last) are uninitialized storage.
+ * - Start and Finish are always nonsingular iterators. NOTE: this
+ * means that an empty deque must have one node, a deque with <N
+ * elements (where N is the node buffer size) must have one node, a
+ * deque with N through (2N-1) elements must have two nodes, etc.
+ * - For every node other than start.node and finish.node, every
+ * element in the node is an initialized object. If start.node ==
+ * finish.node, then [start.cur, finish.cur) are initialized
+ * objects, and the elements outside that range are uninitialized
+ * storage. Otherwise, [start.cur, start.last) and [finish.first,
+ * finish.cur) are initialized objects, and [start.first, start.cur)
+ * and [finish.cur, finish.last) are uninitialized storage.
* - [%map, %map + map_size) is a valid, non-empty range.
* - [start.node, finish.node] is a valid range contained within
* [%map, %map + map_size).
*/
deque(const deque& __x)
: _Base(__x.get_allocator(), __x.size())
- { std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start,
+ { std::__uninitialized_copy_a(__x.begin(), __x.end(),
+ this->_M_impl._M_start,
this->get_allocator()); }
/**
* @param n Number of elements to be assigned.
* @param val Value to be assigned.
*
- * This function fills a %deque with @a n copies of the given value.
- * Note that the assignment completely changes the %deque and that the
- * resulting %deque's size is the same as the number of elements assigned.
- * Old data may be lost.
+ * This function fills a %deque with @a n copies of the given
+ * value. Note that the assignment completely changes the
+ * %deque and that the resulting %deque's size is the same as
+ * the number of elements assigned. Old data may be lost.
*/
void
assign(size_type __n, const value_type& __val)
{ return this->_M_impl._M_start; }
/**
- * Returns a read/write iterator that points one past the last element in
- * the %deque. Iteration is done in ordinary element order.
+ * Returns a read/write iterator that points one past the last
+ * element in the %deque. Iteration is done in ordinary
+ * element order.
*/
iterator
end()
{ return this->_M_impl._M_finish; }
/**
- * Returns a read-only (constant) iterator that points one past the last
- * element in the %deque. Iteration is done in ordinary element order.
+ * Returns a read-only (constant) iterator that points one past
+ * the last element in the %deque. Iteration is done in
+ * ordinary element order.
*/
const_iterator
end() const
{ return this->_M_impl._M_finish; }
/**
- * Returns a read/write reverse iterator that points to the last element
- * in the %deque. Iteration is done in reverse element order.
+ * Returns a read/write reverse iterator that points to the
+ * last element in the %deque. Iteration is done in reverse
+ * element order.
*/
reverse_iterator
rbegin()
{ return reverse_iterator(this->_M_impl._M_finish); }
/**
- * Returns a read-only (constant) reverse iterator that points to the
- * last element in the %deque. Iteration is done in reverse element
- * order.
+ * Returns a read-only (constant) reverse iterator that points
+ * to the last element in the %deque. Iteration is done in
+ * reverse element order.
*/
const_reverse_iterator
rbegin() const
{ return const_reverse_iterator(this->_M_impl._M_finish); }
/**
- * Returns a read/write reverse iterator that points to one before the
- * first element in the %deque. Iteration is done in reverse element
- * order.
+ * Returns a read/write reverse iterator that points to one
+ * before the first element in the %deque. Iteration is done
+ * in reverse element order.
*/
reverse_iterator
rend() { return reverse_iterator(this->_M_impl._M_start); }
/**
- * Returns a read-only (constant) reverse iterator that points to one
- * before the first element in the %deque. Iteration is done in reverse
- * element order.
+ * Returns a read-only (constant) reverse iterator that points
+ * to one before the first element in the %deque. Iteration is
+ * done in reverse element order.
*/
const_reverse_iterator
rend() const
* @param new_size Number of elements the %deque should contain.
* @param x Data with which new elements should be populated.
*
- * This function will %resize the %deque to the specified number of
- * elements. If the number is smaller than the %deque's current size the
- * %deque is truncated, otherwise the %deque is extended and new elements
- * are populated with given data.
+ * This function will %resize the %deque to the specified
+ * number of elements. If the number is smaller than the
+ * %deque's current size the %deque is truncated, otherwise the
+ * %deque is extended and new elements are populated with given
+ * data.
*/
void
resize(size_type __new_size, const value_type& __x)
* @brief Resizes the %deque to the specified number of elements.
* @param new_size Number of elements the %deque should contain.
*
- * This function will resize the %deque to the specified number of
- * elements. If the number is smaller than the %deque's current size the
- * %deque is truncated, otherwise the %deque is extended and new elements
- * are default-constructed.
+ * This function will resize the %deque to the specified number
+ * of elements. If the number is smaller than the %deque's
+ * current size the %deque is truncated, otherwise the %deque
+ * is extended and new elements are default-constructed.
*/
void
resize(size_type new_size)
{ resize(new_size, value_type()); }
/**
- * Returns true if the %deque is empty. (Thus begin() would equal end().)
+ * Returns true if the %deque is empty. (Thus begin() would
+ * equal end().)
*/
bool
empty() const
// element access
/**
- * @brief Subscript access to the data contained in the %deque.
- * @param n The index of the element for which data should be accessed.
+ * @brief Subscript access to the data contained in the %deque.
+ * @param n The index of the element for which data should be
+ * accessed.
* @return Read/write reference to data.
*
* This operator allows for easy, array-style, data access.
- * Note that data access with this operator is unchecked and out_of_range
- * lookups are not defined. (For checked lookups see at().)
+ * Note that data access with this operator is unchecked and
+ * out_of_range lookups are not defined. (For checked lookups
+ * see at().)
*/
reference
operator[](size_type __n)
{ return this->_M_impl._M_start[difference_type(__n)]; }
/**
- * @brief Subscript access to the data contained in the %deque.
- * @param n The index of the element for which data should be accessed.
+ * @brief Subscript access to the data contained in the %deque.
+ * @param n The index of the element for which data should be
+ * accessed.
* @return Read-only (constant) reference to data.
*
* This operator allows for easy, array-style, data access.
- * Note that data access with this operator is unchecked and out_of_range
- * lookups are not defined. (For checked lookups see at().)
+ * Note that data access with this operator is unchecked and
+ * out_of_range lookups are not defined. (For checked lookups
+ * see at().)
*/
const_reference
operator[](size_type __n) const
public:
/**
* @brief Provides access to the data contained in the %deque.
- * @param n The index of the element for which data should be accessed.
+ * @param n The index of the element for which data should be
+ * accessed.
* @return Read/write reference to data.
* @throw std::out_of_range If @a n is an invalid index.
*
- * This function provides for safer data access. The parameter is first
- * checked that it is in the range of the deque. The function throws
- * out_of_range if the check fails.
+ * This function provides for safer data access. The parameter
+ * is first checked that it is in the range of the deque. The
+ * function throws out_of_range if the check fails.
*/
reference
at(size_type __n)
/**
* @brief Provides access to the data contained in the %deque.
- * @param n The index of the element for which data should be accessed.
+ * @param n The index of the element for which data should be
+ * accessed.
* @return Read-only (constant) reference to data.
* @throw std::out_of_range If @a n is an invalid index.
*
}
/**
- * Returns a read/write reference to the data at the first element of the
- * %deque.
+ * Returns a read/write reference to the data at the first
+ * element of the %deque.
*/
reference
front()
* @brief Add data to the front of the %deque.
* @param x Data to be added.
*
- * This is a typical stack operation. The function creates an element at
- * the front of the %deque and assigns the given data to it. Due to the
- * nature of a %deque this operation can be done in constant time.
+ * This is a typical stack operation. The function creates an
+ * element at the front of the %deque and assigns the given
+ * data to it. Due to the nature of a %deque this operation
+ * can be done in constant time.
*/
void
push_front(const value_type& __x)
* @brief Add data to the end of the %deque.
* @param x Data to be added.
*
- * This is a typical stack operation. The function creates an element at
- * the end of the %deque and assigns the given data to it. Due to the
- * nature of a %deque this operation can be done in constant time.
+ * This is a typical stack operation. The function creates an
+ * element at the end of the %deque and assigns the given data
+ * to it. Due to the nature of a %deque this operation can be
+ * done in constant time.
*/
void
push_back(const value_type& __x)
* @param first An input iterator.
* @param last An input iterator.
*
- * This function will insert copies of the data in the range [first,last)
- * into the %deque before the location specified by @a pos. This is
- * known as "range insert."
+ * This function will insert copies of the data in the range
+ * [first,last) into the %deque before the location specified
+ * by @a pos. This is known as "range insert."
*/
template<typename _InputIterator>
void
* @brief Fills the %deque with copies of value.
* @param value Initial value.
* @return Nothing.
- * @pre _M_start and _M_finish have already been initialized, but none of
- * the %deque's elements have yet been constructed.
+ * @pre _M_start and _M_finish have already been initialized,
+ * but none of the %deque's elements have yet been constructed.
*
* This function is called only when the user provides an explicit size
* (with or without an explicit exemplar value).
erase(std::copy(__first, __last, begin()), end());
}
- // Called by assign(n,t), and the range assign when it turns out to be the
- // same thing.
+ // Called by assign(n,t), and the range assign when it turns out
+ // to be the same thing.
void
_M_fill_assign(size_type __n, const value_type& __val)
{
* @if maint
* @brief Memory-handling helpers for the major %map.
*
- * Makes sure the _M_map has space for new nodes. Does not actually add
- * the nodes. Can invalidate _M_map pointers. (And consequently, %deque
- * iterators.)
+ * Makes sure the _M_map has space for new nodes. Does not
+ * actually add the nodes. Can invalidate _M_map pointers.
+ * (And consequently, %deque iterators.)
* @endif
*/
void