ADC Home > Reference Library > Reference > Darwin > Miscellaneous User Space API Reference

 


stl_deque.h

Includes:

Introduction

This is an internal header file, included by other library headers. You should not attempt to use it directly.



Classes

_Deque_base


Functions

__deque_buf_size
_M_initialize_map
operator _Deque_iterator

__deque_buf_size


inline size_t __deque_buf_size(
    size_t __size) 
Parameters
size
The size of an element.
Return Value

The number (not byte size) of elements per node.

This function started off as a compiler kludge from SGI, but seems to be a useful wrapper around a repeated constant expression. The '512' is tuneable (and no other code needs to change), but no investigation has been done since inheriting the SGI code. @endif

Discussion

@if maint @brief This function controls the size of memory nodes.


_M_initialize_map


template<typename _Tp, typename _Alloc> void _Deque_base<_Tp, _Alloc>:: _M_initialize_map(
    size_t __num_elements) 
Parameters
num_elements
The count of T's for which to allocate space at first.
Return Value

Nothing.

The initial underlying memory layout is a bit complicated... @endif

Discussion

@if maint @brief Layout storage.


operator _Deque_iterator


template<typename _Tp, typename _Ref, typename _Ptr> struct _Deque_iterator { 
    typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; 
    typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;  
    static size_t _S_buffer_size() {
        return __deque_buf_size(
            sizeof(
                _Tp));
        }  typedef random_access_iterator_tag iterator_category; 
    typedef _Tp value_type; 
    typedef _Ptr pointer; 
    typedef _Ref reference; 
    typedef size_t size_type; 
    typedef ptrdiff_t difference_type; 
    typedef _Tp** _Map_pointer; 
    typedef _Deque_iterator _Self;  
    _Tp*_M_cur; 
    _Tp*_M_first; 
    _Tp*_M_last; 
    _Map_pointer _M_node;  
    _Deque_iterator(
        _Tp* __x,
        _Map_pointer __y) : _M_cur(
        __x), _M_first(
        *__y), _M_last(
        *__y + _S_buffer_size()), _M_node(__y) {
        }  _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {
        }  _Deque_iterator(
        const iterator& __x) : _M_cur(
        __x._M_cur), _M_first(
        __x._M_first), _M_last(
        __x._M_last), _M_node(__x._M_node) {
        }  reference operator*() const ;
Discussion

@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.

@if maint All the functions are op overloads except for _M_set_node. @endif

Last Updated: 2006-06-20