Page 4 of 4 FirstFirst 1234
Results 76 to 99 of 99
  1. #76
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;
    typedef __default_alloc_template<false, 0> single_client_alloc;

    template <bool __threads, int __inst>
    inline bool operator==(const __default_alloc_template<__threads, __inst>&,
    const __default_alloc_template<__threads, __inst>&)
    {
    return true;
    }

    # ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    template <bool __threads, int __inst>
    inline bool operator!=(const __default_alloc_template<__threads, __inst>&,
    const __default_alloc_template<__threads, __inst>&)
    {
    return false;
    }
    # endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */



    /* We allocate memory in large chunks in order to avoid fragmenting */
    /* the malloc heap too much. */
    /* We assume that size is properly aligned. */
    /* We hold the allocation lock. */
    template <bool __threads, int __inst>
    char*
    __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
    int& __nobjs)
    {
    char* __result;
    size_t __total_bytes = __size * __nobjs;
    size_t __bytes_left = _S_end_free - _S_start_free;

    if (__bytes_left >= __total_bytes) {
    __result = _S_start_free;
    _S_start_free += __total_bytes;
    return(__result);
    } else if (__bytes_left >= __size) {
    __nobjs = (int)(__bytes_left/__size);
    __total_bytes = __size * __nobjs;
    __result = _S_start_free;
    _S_start_free += __total_bytes;
    return(__result);
    } else {
    size_t __bytes_to_get =
    2 * __total_bytes + _S_round_up(_S_heap_size >> 4);
    // Try to make use of the left-over piece.
    if (__bytes_left > 0) {
    _Obj* __STL_VOLATILE* __my_free_list =
    _S_free_list + _S_freelist_index(__bytes_left);

    ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
    *__my_free_list = (_Obj*)_S_start_free;
    }
    _S_start_free = (char*)malloc(__bytes_to_get);
    if (0 == _S_start_free) {
    size_t __i;
    _Obj* __STL_VOLATILE* __my_free_list;
    _Obj* __p;
    // Try to make do with what we have. That can't
    // hurt. We do not try smaller requests, since that tends
    // to result in disaster on multi-process machines.
    for (__i = __size;
    __i <= (size_t) _MAX_BYTES;
    __i += (size_t) _ALIGN) {
    __my_free_list = _S_free_list + _S_freelist_index(__i);
    __p = *__my_free_list;
    if (0 != __p) {
    *__my_free_list = __p -> _M_free_list_link;
    _S_start_free = (char*)__p;
    _S_end_free = _S_start_free + __i;
    return(_S_chunk_alloc(__size, __nobjs));
    // Any leftover piece will eventually make it to the
    // right free list.
    }
    }
    _S_end_free = 0; // In case of exception.
    _S_start_free = (char*)malloc_alloc::allocate(__bytes_to_get);
    // This should either throw an
    // exception or remedy the situation. Thus we assume it
    // succeeded.
    }
    _S_heap_size += __bytes_to_get;
    _S_end_free = _S_start_free + __bytes_to_get;
    return(_S_chunk_alloc(__size, __nobjs));
    }
    }


    /* Returns an object of size __n, and optionally adds to size __n free list.*/
    /* We assume that __n is properly aligned. */
    /* We hold the allocation lock. */
    template <bool __threads, int __inst>
    void*
    __default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
    {
    int __nobjs = 20;
    char* __chunk = _S_chunk_alloc(__n, __nobjs);
    _Obj* __STL_VOLATILE* __my_free_list;
    _Obj* __result;
    _Obj* __current_obj;
    _Obj* __next_obj;
    int __i;

    if (1 == __nobjs) return(__chunk);
    __my_free_list = _S_free_list + _S_freelist_index(__n);

    /* Build free list in chunk */
    __result = (_Obj*)__chunk;
    *__my_free_list = __next_obj = (_Obj*)(__chunk + __n);
    for (__i = 1; ; __i++) {
    __current_obj = __next_obj;
    __next_obj = (_Obj*)((char*)__next_obj + __n);
    if (__nobjs - 1 == __i) {
    __current_obj -> _M_free_list_link = 0;
    break;
    } else {
    __current_obj -> _M_free_list_link = __next_obj;
    }
    }
    return(__result);
    }

    template <bool threads, int inst>
    void*
    __default_alloc_template<threads, inst>::reallocate(void* __p,
    size_t __old_sz,
    size_t __new_sz)
    {
    void* __result;
    size_t __copy_sz;

    if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) {
    return(realloc(__p, __new_sz));
    }
    if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);
    __result = allocate(__new_sz);
    __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;
    memcpy(__result, __p, __copy_sz);
    deallocate(__p, __old_sz);
    return(__result);
    }

    #ifdef __STL_THREADS
    template <bool __threads, int __inst>
    _STL_mutex_lock
    __default_alloc_template<__threads, __inst>::_S_node_allocator_lock
    __STL_MUTEX_INITIALIZER;
    #endif


    template <bool __threads, int __inst>
    char* __default_alloc_template<__threads, __inst>::_S_start_free = 0;

    template <bool __threads, int __inst>
    char* __default_alloc_template<__threads, __inst>::_S_end_free = 0;

    template <bool __threads, int __inst>
    size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;

    template <bool __threads, int __inst>
    typename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE
    __default_alloc_template<__threads, __inst> ::_S_free_list[
    # if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC)
    _NFREELISTS
    # else
    __default_alloc_template<__threads, __inst>::_NFREELISTS
    # endif
    ] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
    // The 16 zeros are necessary to make version 4.1 of the SunPro
    // compiler happy. Otherwise it appears to allocate too little
    // space for the array.

    #endif /* ! __USE_MALLOC */

    // This implements allocators as specified in the C++ standard.
    //
    // Note that standard-conforming allocators use many language features
    // that are not yet widely implemented. In particular, they rely on
    // member templates, partial specialization, partial ordering of function
    // templates, the typename keyword, and the use of the template keyword
    // to refer to a template member of a dependent type.

    #ifdef __STL_USE_STD_ALLOCATORS

    template <class _Tp>
    class allocator {
    typedef alloc _Alloc; // The underlying allocator.
    public:
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef _Tp* pointer;
    typedef const _Tp* const_pointer;
    typedef _Tp& reference;
    typedef const _Tp& const_reference;
    typedef _Tp value_type;

    template <class _Tp1> struct rebind {
    typedef allocator<_Tp1> other;
    };

    allocator() __STL_NOTHROW {}
    allocator(const allocator&) __STL_NOTHROW {}
    template <class _Tp1> allocator(const allocator<_Tp1>&) __STL_NOTHROW {}
    ~allocator() __STL_NOTHROW {}

    pointer address(reference __x) const { return &__x; }
    const_pointer address(const_reference __x) const { return &__x; }

    // __n is permitted to be 0. The C++ standard says nothing about what
    // the return value is when __n == 0.
    _Tp* allocate(size_type __n, const void* = 0) {
    return __n != 0 ? static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)))
    : 0;
    }

    // __p is not permitted to be a null pointer.
    void deallocate(pointer __p, size_type __n)
    { _Alloc::deallocate(__p, __n * sizeof(_Tp)); }

    size_type max_size() const __STL_NOTHROW
    { return size_t(-1) / sizeof(_Tp); }

    void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
    void destroy(pointer __p) { __p->~_Tp(); }
    };

    template<>
    class allocator<void> {
    public:
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef void* pointer;
    typedef const void* const_pointer;
    typedef void value_type;

    template <class _Tp1> struct rebind {
    typedef allocator<_Tp1> other;
    };
    };


    template <class _T1, class _T2>
    inline bool operator==(const allocator<_T1>&, const allocator<_T2>&)
    {
    return true;
    }

    template <class _T1, class _T2>
    inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&)
    {
    return false;
    }

    // Allocator adaptor to turn an SGI-style allocator (e.g. alloc, malloc_alloc)
    // into a standard-conforming allocator. Note that this adaptor does
    // *not* assume that all objects of the underlying alloc class are
    // identical, nor does it assume that all of the underlying alloc's
    // member functions are static member functions. Note, also, that
    // __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>.

    template <class _Tp, class _Alloc>
    struct __allocator {
    _Alloc __underlying_alloc;

    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef _Tp* pointer;
    typedef const _Tp* const_pointer;
    typedef _Tp& reference;
    typedef const _Tp& const_reference;
    typedef _Tp value_type;

    template <class _Tp1> struct rebind {
    typedef __allocator<_Tp1, _Alloc> other;
    };

    __allocator() __STL_NOTHROW {}
    __allocator(const __allocator& __a) __STL_NOTHROW
    : __underlying_alloc(__a.__underlying_alloc) {}
    template <class _Tp1>
    __allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW
    : __underlying_alloc(__a.__underlying_alloc) {}
    ~__allocator() __STL_NOTHROW {}

    pointer address(reference __x) const { return &__x; }
    const_pointer address(const_reference __x) const { return &__x; }

    // __n is permitted to be 0.
    _Tp* allocate(size_type __n, const void* = 0) {
    return __n != 0
    ? static_cast<_Tp*>(__underlying_alloc.allocate(__n * sizeof(_Tp)))
    : 0;
    }

    // __p is not permitted to be a null pointer.
    void deallocate(pointer __p, size_type __n)
    { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }

    size_type max_size() const __STL_NOTHROW
    { return size_t(-1) / sizeof(_Tp); }

    void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
    void destroy(pointer __p) { __p->~_Tp(); }
    };

    template <class _Alloc>
    class __allocator<void, _Alloc> {
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef void* pointer;
    typedef const void* const_pointer;
    typedef void value_type;

    template <class _Tp1> struct rebind {
    typedef __allocator<_Tp1, _Alloc> other;
    };
    };

    template <class _Tp, class _Alloc>
    inline bool operator==(const __allocator<_Tp, _Alloc>& __a1,
    const __allocator<_Tp, _Alloc>& __a2)
    {
    return __a1.__underlying_alloc == __a2.__underlying_alloc;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    template <class _Tp, class _Alloc>
    inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1,
    const __allocator<_Tp, _Alloc>& __a2)
    {
    return __a1.__underlying_alloc != __a2.__underlying_alloc;
    }
    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    // Comparison operators for all of the predifined SGI-style allocators.
    // This ensures that __allocator<malloc_alloc> (for example) will
    // work correctly.

    template <int inst>
    inline bool operator==(const __malloc_alloc_template<inst>&,
    const __malloc_alloc_template<inst>&)
    {
    return true;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    template <int __inst>
    inline bool operator!=(const __malloc_alloc_template<__inst>&,
    const __malloc_alloc_template<__inst>&)
    {
    return false;
    }
    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */


    template <class _Alloc>
    inline bool operator==(const debug_alloc<_Alloc>&,
    const debug_alloc<_Alloc>&) {
    return true;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    template <class _Alloc>
    inline bool operator!=(const debug_alloc<_Alloc>&,
    const debug_alloc<_Alloc>&) {
    return false;
    }
    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    // Another allocator adaptor: _Alloc_traits. This serves two
    // purposes. First, make it possible to write containers that can use
    // either SGI-style allocators or standard-conforming allocator.
    // Second, provide a mechanism so that containers can query whether or
    // not the allocator has distinct instances. If not, the container
    // can avoid wasting a word of memory to store an empty object.

    // This adaptor uses partial specialization. The general case of
    // _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a
    // standard-conforming allocator, possibly with non-equal instances
    // and non-static members. (It still behaves correctly even if _Alloc
    // has static member and if all instances are equal. Refinements
    // affect performance, not correctness.)

    // There are always two members: allocator_type, which is a standard-
    // conforming allocator type for allocating objects of type _Tp, and
    // _S_instanceless, a static const member of type bool. If
    // _S_instanceless is true, this means that there is no difference
    // between any two instances of type allocator_type. Furthermore, if
    // _S_instanceless is true, then _Alloc_traits has one additional
    // member: _Alloc_type. This type encapsulates allocation and
    // deallocation of objects of type _Tp through a static interface; it
    // has two member functions, whose signatures are
    // static _Tp* allocate(size_t)
    // static void deallocate(_Tp*, size_t)

    // The fully general version.

    template <class _Tp, class _Allocator>
    struct _Alloc_traits
    {
    static const bool _S_instanceless = false;
    typedef typename _Allocator::__STL_TEMPLATE rebind<_Tp>::other
    allocator_type;
    };

    template <class _Tp, class _Allocator>
    const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless;

    // The version for the default allocator.

    template <class _Tp, class _Tp1>
    struct _Alloc_traits<_Tp, allocator<_Tp1> >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, alloc> _Alloc_type;
    typedef allocator<_Tp> allocator_type;
    };

    // Versions for the predefined SGI-style allocators.

    template <class _Tp, int __inst>
    struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
    typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;
    };

    template <class _Tp, bool __threads, int __inst>
    struct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, __default_alloc_template<__threads, __inst> >
    _Alloc_type;
    typedef __allocator<_Tp, __default_alloc_template<__threads, __inst> >
    allocator_type;
    };

    template <class _Tp, class _Alloc>
    struct _Alloc_traits<_Tp, debug_alloc<_Alloc> >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;
    typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;
    };

    // Versions for the __allocator adaptor used with the predefined
    // SGI-style allocators.

    template <class _Tp, class _Tp1, int __inst>
    struct _Alloc_traits<_Tp,
    __allocator<_Tp1, __malloc_alloc_template<__inst> > >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
    typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;
    };

    template <class _Tp, class _Tp1, bool __thr, int __inst>
    struct _Alloc_traits<_Tp,
    __allocator<_Tp1,
    __default_alloc_template<__thr, __inst> > >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, __default_alloc_template<__thr,__inst> >
    _Alloc_type;
    typedef __allocator<_Tp, __default_alloc_template<__thr,__inst> >
    allocator_type;
    };

    template <class _Tp, class _Tp1, class _Alloc>
    struct _Alloc_traits<_Tp, __allocator<_Tp1, debug_alloc<_Alloc> > >
    {
    static const bool _S_instanceless = true;
    typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;
    typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;
    };


    #endif /* __STL_USE_STD_ALLOCATORS */

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma reset woff 1174
    #endif

    __STL_END_NAMESPACE

    #undef __PRIVATE

    #endif /* __SGI_STL_INTERNAL_ALLOC_H */

    // Local Variables:
    // mode:C++
    // End:

  2. #77
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1996-1999
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_BVECTOR_H
    #define __SGI_STL_INTERNAL_BVECTOR_H

    __STL_BEGIN_NAMESPACE

    static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma set woff 1174
    #pragma set woff 1375
    #endif

    struct _Bit_reference {
    unsigned int* _M_p;
    unsigned int _M_mask;
    _Bit_reference(unsigned int* __x, unsigned int __y)
    : _M_p(__x), _M_mask(__y) {}

    public:
    _Bit_reference() : _M_p(0), _M_mask(0) {}
    operator bool() const { return !(!(*_M_p & _M_mask)); }
    _Bit_reference& operator=(bool __x)
    {
    if (__x) *_M_p |= _M_mask;
    else *_M_p &= ~_M_mask;
    return *this;
    }
    _Bit_reference& operator=(const _Bit_reference& __x)
    { return *this = bool(__x); }
    bool operator==(const _Bit_reference& __x) const
    { return bool(*this) == bool(__x); }
    bool operator<(const _Bit_reference& __x) const {
    return !bool(*this) && bool(__x);
    }
    void flip() { *_M_p ^= _M_mask; }
    };

    inline void swap(_Bit_reference __x, _Bit_reference __y)
    {
    bool __tmp = __x;
    __x = __y;
    __y = __tmp;
    }

    struct _Bit_iterator_base : public random_access_iterator<bool, ptrdiff_t>
    {
    unsigned int* _M_p;
    unsigned int _M_offset;

    _Bit_iterator_base(unsigned int* __x, unsigned int __y)
    : _M_p(__x), _M_offset(__y) {}

    void _M_bump_up() {
    if (_M_offset++ == __WORD_BIT - 1) {
    _M_offset = 0;
    ++_M_p;
    }
    }
    void _M_bump_down() {
    if (_M_offset-- == 0) {
    _M_offset = __WORD_BIT - 1;
    --_M_p;
    }
    }

    void _M_incr(ptrdiff_t __i) {
    difference_type __n = __i + _M_offset;
    _M_p += __n / __WORD_BIT;
    __n = __n % __WORD_BIT;
    if (__n < 0) {
    _M_offset = (unsigned int) __n + __WORD_BIT;
    --_M_p;
    } else
    _M_offset = (unsigned int) __n;
    }

    bool operator==(const _Bit_iterator_base& __i) const {
    return _M_p == __i._M_p && _M_offset == __i._M_offset;
    }
    bool operator<(const _Bit_iterator_base& __i) const {
    return _M_p < __i._M_p || (_M_p == __i._M_p && _M_offset < __i._M_offset);
    }
    bool operator!=(const _Bit_iterator_base& __i) const {
    return !(*this == __i);
    }
    bool operator>(const _Bit_iterator_base& __i) const {
    return __i < *this;
    }
    bool operator<=(const _Bit_iterator_base& __i) const {
    return !(__i < *this);
    }
    bool operator>=(const _Bit_iterator_base& __i) const {
    return !(*this < __i);
    }
    };

    inline ptrdiff_t
    operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
    return __WORD_BIT * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
    }


    struct _Bit_iterator : public _Bit_iterator_base
    {
    typedef _Bit_reference reference;
    typedef _Bit_reference* pointer;
    typedef _Bit_iterator iterator;

    _Bit_iterator() : _Bit_iterator_base(0, 0) {}
    _Bit_iterator(unsigned int* __x, unsigned int __y)
    : _Bit_iterator_base(__x, __y) {}

    reference operator*() const { return reference(_M_p, 1U << _M_offset); }
    iterator& operator++() {
    _M_bump_up();
    return *this;
    }
    iterator operator++(int) {
    iterator __tmp = *this;
    _M_bump_up();
    return __tmp;
    }
    iterator& operator--() {
    _M_bump_down();
    return *this;
    }
    iterator operator--(int) {
    iterator __tmp = *this;
    _M_bump_down();
    return __tmp;
    }
    iterator& operator+=(difference_type __i) {
    _M_incr(__i);
    return *this;
    }
    iterator& operator-=(difference_type __i) {
    *this += -__i;
    return *this;
    }
    iterator operator+(difference_type __i) const {
    iterator __tmp = *this;
    return __tmp += __i;
    }
    iterator operator-(difference_type __i) const {
    iterator __tmp = *this;
    return __tmp -= __i;
    }

    reference operator[](difference_type __i) { return *(*this + __i); }
    };

    inline _Bit_iterator
    operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; }


    struct _Bit_const_iterator : public _Bit_iterator_base
    {
    typedef bool reference;
    typedef bool const_reference;
    typedef const bool* pointer;
    typedef _Bit_const_iterator const_iterator;

    _Bit_const_iterator() : _Bit_iterator_base(0, 0) {}
    _Bit_const_iterator(unsigned int* __x, unsigned int __y)
    : _Bit_iterator_base(__x, __y) {}
    _Bit_const_iterator(const _Bit_iterator& __x)
    : _Bit_iterator_base(__x._M_p, __x._M_offset) {}

    const_reference operator*() const {
    return _Bit_reference(_M_p, 1U << _M_offset);
    }
    const_iterator& operator++() {
    _M_bump_up();
    return *this;
    }
    const_iterator operator++(int) {
    const_iterator __tmp = *this;
    _M_bump_up();
    return __tmp;
    }
    const_iterator& operator--() {
    _M_bump_down();
    return *this;
    }
    const_iterator operator--(int) {
    const_iterator __tmp = *this;
    _M_bump_down();
    return __tmp;
    }
    const_iterator& operator+=(difference_type __i) {
    _M_incr(__i);
    return *this;
    }
    const_iterator& operator-=(difference_type __i) {
    *this += -__i;
    return *this;
    }
    const_iterator operator+(difference_type __i) const {
    const_iterator __tmp = *this;
    return __tmp += __i;
    }
    const_iterator operator-(difference_type __i) const {
    const_iterator __tmp = *this;
    return __tmp -= __i;
    }
    const_reference operator[](difference_type __i) {
    return *(*this + __i);
    }
    };

    inline _Bit_const_iterator
    operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; }


    // Bit-vector base class, which encapsulates the difference between
    // old SGI-style allocators and standard-conforming allocators.

    #ifdef __STL_USE_STD_ALLOCATORS

    // Base class for ordinary allocators.
    template <class _Allocator, bool __is_static>
    class _Bvector_alloc_base {
    public:
    typedef typename _Alloc_traits<bool, _Allocator>::allocator_type
    allocator_type;
    allocator_type get_allocator() const { return _M_data_allocator; }

    _Bvector_alloc_base(const allocator_type& __a)
    : _M_data_allocator(__a), _M_start(), _M_finish(), _M_end_of_storage(0) {}

    protected:
    unsigned int* _M_bit_alloc(size_t __n)
    { return _M_data_allocator.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
    void _M_deallocate() {
    if (_M_start._M_p)
    _M_data_allocator.deallocate(_M_start._M_p,
    _M_end_of_storage - _M_start._M_p);
    }

    typename _Alloc_traits<unsigned int, _Allocator>::allocator_type
    _M_data_allocator;
    _Bit_iterator _M_start;
    _Bit_iterator _M_finish;
    unsigned int* _M_end_of_storage;
    };

    // Specialization for instanceless allocators.
    template <class _Allocator>
    class _Bvector_alloc_base<_Allocator, true> {
    public:
    typedef typename _Alloc_traits<bool, _Allocator>::allocator_type
    allocator_type;
    allocator_type get_allocator() const { return allocator_type(); }

    _Bvector_alloc_base(const allocator_type&)
    : _M_start(), _M_finish(), _M_end_of_storage(0) {}

    protected:
    typedef typename _Alloc_traits<unsigned int, _Allocator>::_Alloc_type
    _Alloc_type;

    unsigned int* _M_bit_alloc(size_t __n)
    { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
    void _M_deallocate() {
    if (_M_start._M_p)
    _Alloc_type::deallocate(_M_start._M_p,
    _M_end_of_storage - _M_start._M_p);
    }

    _Bit_iterator _M_start;
    _Bit_iterator _M_finish;
    unsigned int* _M_end_of_storage;
    };

    template <class _Alloc>
    class _Bvector_base
    : public _Bvector_alloc_base<_Alloc,
    _Alloc_traits<bool, _Alloc>::_S_instanceless>
    {
    typedef _Bvector_alloc_base<_Alloc,
    _Alloc_traits<bool, _Alloc>::_S_instanceless>
    _Base;
    public:
    typedef typename _Base::allocator_type allocator_type;

    _Bvector_base(const allocator_type& __a) : _Base(__a) {}
    ~_Bvector_base() { _Base::_M_deallocate(); }
    };

    #else /* __STL_USE_STD_ALLOCATORS */

    template <class _Alloc>
    class _Bvector_base
    {
    public:
    typedef _Alloc allocator_type;
    allocator_type get_allocator() const { return allocator_type(); }

    _Bvector_base(const allocator_type&)
    : _M_start(), _M_finish(), _M_end_of_storage(0) {}
    ~_Bvector_base() { _M_deallocate(); }

    protected:
    typedef simple_alloc<unsigned int, _Alloc> _Alloc_type;

    unsigned int* _M_bit_alloc(size_t __n)
    { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
    void _M_deallocate() {
    if (_M_start._M_p)
    _Alloc_type::deallocate(_M_start._M_p,
    _M_end_of_storage - _M_start._M_p);
    }

    _Bit_iterator _M_start;
    _Bit_iterator _M_finish;
    unsigned int* _M_end_of_storage;
    };

    #endif /* __STL_USE_STD_ALLOCATORS */

    // The next few lines are confusing. What we're doing is declaring a
    // partial specialization of vector<T, Alloc> if we have the necessary
    // compiler support. Otherwise, we define a class bit_vector which uses
    // the default allocator.

    #if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NO_BOOL)
    # define __SGI_STL_VECBOOL_TEMPLATE
    # define __BVECTOR vector<bool, _Alloc>
    # define __VECTOR vector
    # define __BVECTOR_BASE _Bvector_base<_Alloc>
    # define __BVECTOR_TMPL_LIST template <class _Alloc>
    __STL_END_NAMESPACE
    # include <stl_vector.h>
    __STL_BEGIN_NAMESPACE
    #else /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */
    # undef __SGI_STL_VECBOOL_TEMPLATE
    # define __BVECTOR bit_vector
    # define __VECTOR bit_vector
    # define __BVECTOR_BASE _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) >
    # define __BVECTOR_TMPL_LIST
    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION && !__STL_NO_BOOL */


    __BVECTOR_TMPL_LIST
    class __BVECTOR : public __BVECTOR_BASE
    {
    public:
    typedef bool value_type;
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef _Bit_reference reference;
    typedef bool const_reference;
    typedef _Bit_reference* pointer;
    typedef const bool* const_pointer;

    typedef _Bit_iterator iterator;
    typedef _Bit_const_iterator const_iterator;

    #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
    typedef reverse_iterator<const_iterator> const_reverse_iterator;
    typedef reverse_iterator<iterator> reverse_iterator;
    #else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
    typedef reverse_iterator<const_iterator, value_type, const_reference,
    difference_type> const_reverse_iterator;
    typedef reverse_iterator<iterator, value_type, reference, difference_type>
    reverse_iterator;
    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    typedef typename __BVECTOR_BASE::allocator_type allocator_type;
    allocator_type get_allocator() const {
    return __BVECTOR_BASE::get_allocator();
    }

    protected:
    #ifdef __STL_USE_NAMESPACES
    using __BVECTOR_BASE::_M_bit_alloc;
    using __BVECTOR_BASE::_M_deallocate;
    using __BVECTOR_BASE::_M_start;
    using __BVECTOR_BASE::_M_finish;
    using __BVECTOR_BASE::_M_end_of_storage;
    #endif /* __STL_USE_NAMESPACES */

    protected:
    void _M_initialize(size_type __n) {
    unsigned int* __q = _M_bit_alloc(__n);
    _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    _M_finish = _M_start + difference_type(__n);
    }
    void _M_insert_aux(iterator __position, bool __x) {
    if (_M_finish._M_p != _M_end_of_storage) {
    copy_backward(__position, _M_finish, _M_finish + 1);
    *__position = __x;
    ++_M_finish;
    }
    else {
    size_type __len = size() ? 2 * size() : __WORD_BIT;
    unsigned int* __q = _M_bit_alloc(__len);
    iterator __i = copy(begin(), __position, iterator(__q, 0));
    *__i++ = __x;
    _M_finish = copy(__position, end(), __i);
    _M_deallocate();
    _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    }
    }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void _M_initialize_range(_Inpu erator __first, _Inpu erator __last,
    input_iterator_tag) {
    _M_start = iterator();
    _M_finish = iterator();
    _M_end_of_storage = 0;
    for ( ; __first != __last; ++__first)
    push_back(*__first);
    }

    template <class _ForwardIterator>
    void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag) {
    size_type __n = 0;
    distance(__first, __last, __n);
    _M_initialize(__n);
    copy(__first, __last, _M_start);
    }

    template <class _Inpu erator>
    void _M_insert_range(iterator __pos,
    _Inpu erator __first, _Inpu erator __last,
    input_iterator_tag) {
    for ( ; __first != __last; ++__first) {
    __pos = insert(__pos, *__first);
    ++__pos;
    }
    }

    template <class _ForwardIterator>
    void _M_insert_range(iterator __position,
    _ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag) {
    if (__first != __last) {
    size_type __n = 0;
    distance(__first, __last, __n);
    if (capacity() - size() >= __n) {
    copy_backward(__position, end(), _M_finish + difference_type(__n));
    copy(__first, __last, __position);
    _M_finish += difference_type(__n);
    }
    else {
    size_type __len = size() + max(size(), __n);
    unsigned int* __q = _M_bit_alloc(__len);
    iterator __i = copy(begin(), __position, iterator(__q, 0));
    __i = copy(__first, __last, __i);
    _M_finish = copy(__position, end(), __i);
    _M_deallocate();
    _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    }
    }
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    public:
    iterator begin() { return _M_start; }
    const_iterator begin() const { return _M_start; }
    iterator end() { return _M_finish; }
    const_iterator end() const { return _M_finish; }

    reverse_iterator rbegin() { return reverse_iterator(end()); }
    const_reverse_iterator rbegin() const {
    return const_reverse_iterator(end());
    }
    reverse_iterator rend() { return reverse_iterator(begin()); }
    const_reverse_iterator rend() const {
    return const_reverse_iterator(begin());
    }

    size_type size() const { return size_type(end() - begin()); }
    size_type max_size() const { return size_type(-1); }
    size_type capacity() const {
    return size_type(const_iterator(_M_end_of_storage, 0) - begin());
    }
    bool empty() const { return begin() == end(); }

    reference operator[](size_type __n)
    { return *(begin() + difference_type(__n)); }
    const_reference operator[](size_type __n) const
    { return *(begin() + difference_type(__n)); }

    #ifdef __STL_THROW_RANGE_ERRORS
    void _M_range_check(size_type __n) const {
    if (__n >= this->size())
    __stl_throw_range_error("vector<bool>");
    }

    reference at(size_type __n)
    { _M_range_check(__n); return (*this)[__n]; }
    const_reference at(size_type __n) const
    { _M_range_check(__n); return (*this)[__n]; }
    #endif /* __STL_THROW_RANGE_ERRORS */

    explicit __VECTOR(const allocator_type& __a = allocator_type())
    : __BVECTOR_BASE(__a) {}

    __VECTOR(size_type __n, bool __value,
    const allocator_type& __a = allocator_type())
    : __BVECTOR_BASE(__a)
    {
    _M_initialize(__n);
    fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0);
    }

    explicit __VECTOR(size_type __n)
    : __BVECTOR_BASE(allocator_type())
    {
    _M_initialize(__n);
    fill(_M_start._M_p, _M_end_of_storage, 0);
    }

    __VECTOR(const __VECTOR& __x) : __BVECTOR_BASE(__x.get_allocator()) {
    _M_initialize(__x.size());
    copy(__x.begin(), __x.end(), _M_start);
    }

    #ifdef __STL_MEMBER_TEMPLATES

    // Check whether it's an integral type. If so, it's not an iterator.

    template <class _Integer>
    void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
    _M_initialize(__n);
    fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
    }

  3. #78
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    template <class _Inpu erator>
    void _M_initialize_dispatch(_Inpu erator __first, _Inpu erator __last,
    __false_type) {
    _M_initialize_range(__first, __last, __ITERATOR_CATEGORY(__first));
    }

    template <class _Inpu erator>
    __VECTOR(_Inpu erator __first, _Inpu erator __last,
    const allocator_type& __a = allocator_type())
    : __BVECTOR_BASE(__a)
    {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_initialize_dispatch(__first, __last, _Integral());
    }

    #else /* __STL_MEMBER_TEMPLATES */

    __VECTOR(const_iterator __first, const_iterator __last,
    const allocator_type& __a = allocator_type())
    : __BVECTOR_BASE(__a)
    {
    size_type __n = 0;
    distance(__first, __last, __n);
    _M_initialize(__n);
    copy(__first, __last, _M_start);
    }
    __VECTOR(const bool* __first, const bool* __last,
    const allocator_type& __a = allocator_type())
    : __BVECTOR_BASE(__a)
    {
    size_type __n = 0;
    distance(__first, __last, __n);
    _M_initialize(__n);
    copy(__first, __last, _M_start);
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    ~__VECTOR() { }

    __VECTOR& operator=(const __VECTOR& __x) {
    if (&__x == this) return *this;
    if (__x.size() > capacity()) {
    _M_deallocate();
    _M_initialize(__x.size());
    }
    copy(__x.begin(), __x.end(), begin());
    _M_finish = begin() + difference_type(__x.size());
    return *this;
    }

    // assign(), a generalized assignment member function. Two
    // versions: one that takes a count, and one that takes a range.
    // The range version is a member template, so we dispatch on whether
    // or not the type is an integer.

    void _M_fill_assign(size_t __n, bool __x) {
    if (__n > size()) {
    fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
    insert(end(), __n - size(), __x);
    }
    else {
    erase(begin() + __n, end());
    fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
    }
    }

    void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); }

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Inpu erator>
    void assign(_Inpu erator __first, _Inpu erator __last) {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_assign_dispatch(__first, __last, _Integral());
    }

    template <class _Integer>
    void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
    { _M_fill_assign((size_t) __n, (bool) __val); }

    template <class _Inpu er>
    void _M_assign_dispatch(_Inpu er __first, _Inpu er __last, __false_type)
    { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); }

    template <class _Inpu erator>
    void _M_assign_aux(_Inpu erator __first, _Inpu erator __last,
    input_iterator_tag) {
    iterator __cur = begin();
    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
    *__cur = *__first;
    if (__first == __last)
    erase(__cur, end());
    else
    insert(end(), __first, __last);
    }

    template <class _ForwardIterator>
    void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag) {
    size_type __len = 0;
    distance(__first, __last, __len);
    if (__len < size())
    erase(copy(__first, __last, begin()), end());
    else {
    _ForwardIterator __mid = __first;
    advance(__mid, size());
    copy(__first, __mid, begin());
    insert(end(), __mid, __last);
    }
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    void reserve(size_type __n) {
    if (capacity() < __n) {
    unsigned int* __q = _M_bit_alloc(__n);
    _M_finish = copy(begin(), end(), iterator(__q, 0));
    _M_deallocate();
    _M_start = iterator(__q, 0);
    _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
    }
    }

    reference front() { return *begin(); }
    const_reference front() const { return *begin(); }
    reference back() { return *(end() - 1); }
    const_reference back() const { return *(end() - 1); }
    void push_back(bool __x) {
    if (_M_finish._M_p != _M_end_of_storage)
    *_M_finish++ = __x;
    else
    _M_insert_aux(end(), __x);
    }
    void swap(__BVECTOR& __x) {
    __STD::swap(_M_start, __x._M_start);
    __STD::swap(_M_finish, __x._M_finish);
    __STD::swap(_M_end_of_storage, __x._M_end_of_storage);
    }
    iterator insert(iterator __position, bool __x = bool()) {
    difference_type __n = __position - begin();
    if (_M_finish._M_p != _M_end_of_storage && __position == end())
    *_M_finish++ = __x;
    else
    _M_insert_aux(__position, __x);
    return begin() + __n;
    }

    #ifdef __STL_MEMBER_TEMPLATES
    // Check whether it's an integral type. If so, it's not an iterator.

    template <class _Integer>
    void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
    __true_type) {
    _M_fill_insert(__pos, __n, __x);
    }

    template <class _Inpu erator>
    void _M_insert_dispatch(iterator __pos,
    _Inpu erator __first, _Inpu erator __last,
    __false_type) {
    _M_insert_range(__pos, __first, __last, __ITERATOR_CATEGORY(__first));
    }

    template <class _Inpu erator>
    void insert(iterator __position,
    _Inpu erator __first, _Inpu erator __last) {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_insert_dispatch(__position, __first, __last, _Integral());
    }

    #else /* __STL_MEMBER_TEMPLATES */
    void insert(iterator __position,
    const_iterator __first, const_iterator __last) {
    if (__first == __last) return;
    size_type __n = 0;
    distance(__first, __last, __n);
    if (capacity() - size() >= __n) {
    copy_backward(__position, end(), _M_finish + __n);
    copy(__first, __last, __position);
    _M_finish += __n;
    }
    else {
    size_type __len = size() + max(size(), __n);
    unsigned int* __q = _M_bit_alloc(__len);
    iterator __i = copy(begin(), __position, iterator(__q, 0));
    __i = copy(__first, __last, __i);
    _M_finish = copy(__position, end(), __i);
    _M_deallocate();
    _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    }
    }

    void insert(iterator __position, const bool* __first, const bool* __last) {
    if (__first == __last) return;
    size_type __n = 0;
    distance(__first, __last, __n);
    if (capacity() - size() >= __n) {
    copy_backward(__position, end(), _M_finish + __n);
    copy(__first, __last, __position);
    _M_finish += __n;
    }
    else {
    size_type __len = size() + max(size(), __n);
    unsigned int* __q = _M_bit_alloc(__len);
    iterator __i = copy(begin(), __position, iterator(__q, 0));
    __i = copy(__first, __last, __i);
    _M_finish = copy(__position, end(), __i);
    _M_deallocate();
    _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    }
    }
    #endif /* __STL_MEMBER_TEMPLATES */

    void _M_fill_insert(iterator __position, size_type __n, bool __x) {
    if (__n == 0) return;
    if (capacity() - size() >= __n) {
    copy_backward(__position, end(), _M_finish + difference_type(__n));
    fill(__position, __position + difference_type(__n), __x);
    _M_finish += difference_type(__n);
    }
    else {
    size_type __len = size() + max(size(), __n);
    unsigned int* __q = _M_bit_alloc(__len);
    iterator __i = copy(begin(), __position, iterator(__q, 0));
    fill_n(__i, __n, __x);
    _M_finish = copy(__position, end(), __i + difference_type(__n));
    _M_deallocate();
    _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
    _M_start = iterator(__q, 0);
    }
    }

    void insert(iterator __position, size_type __n, bool __x) {
    _M_fill_insert(__position, __n, __x);
    }

    void pop_back() { --_M_finish; }
    iterator erase(iterator __position) {
    if (__position + 1 != end())
    copy(__position + 1, end(), __position);
    --_M_finish;
    return __position;
    }
    iterator erase(iterator __first, iterator __last) {
    _M_finish = copy(__last, end(), __first);
    return __first;
    }
    void resize(size_type __new_size, bool __x = bool()) {
    if (__new_size < size())
    erase(begin() + difference_type(__new_size), end());
    else
    insert(end(), __new_size - size(), __x);
    }
    void flip() {
    for (unsigned int* __p = _M_start._M_p; __p != _M_end_of_storage; ++__p)
    *__p = ~*__p;
    }

    void clear() { erase(begin(), end()); }
    };

    #ifdef __SGI_STL_VECBOOL_TEMPLATE

    // This typedef is non-standard. It is provided for backward compatibility.
    typedef vector<bool, alloc> bit_vector;

    #else /* __SGI_STL_VECBOOL_TEMPLATE */

    inline void swap(bit_vector& __x, bit_vector& __y) {
    __x.swap(__y);
    }

    inline bool
    operator==(const bit_vector& __x, const bit_vector& __y)
    {
    return (__x.size() == __y.size() &&
    equal(__x.begin(), __x.end(), __y.begin()));
    }

    inline bool
    operator!=(const bit_vector& __x, const bit_vector& __y)
    {
    return !(__x == __y);
    }

    inline bool
    operator<(const bit_vector& __x, const bit_vector& __y)
    {
    return lexicographical_compare(__x.begin(), __x.end(),
    __y.begin(), __y.end());
    }

    inline bool operator>(const bit_vector& __x, const bit_vector& __y)
    {
    return __y < __x;
    }

    inline bool operator<=(const bit_vector& __x, const bit_vector& __y)
    {
    return !(__y < __x);
    }

    inline bool operator>=(const bit_vector& __x, const bit_vector& __y)
    {
    return !(__x < __y);
    }

    #endif /* __SGI_STL_VECBOOL_TEMPLATE */

    #undef __SGI_STL_VECBOOL_TEMPLATE
    #undef __BVECTOR
    #undef __VECTOR
    #undef __BVECTOR_BASE
    #undef __BVECTOR_TMPL_LIST

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma reset woff 1174
    #pragma reset woff 1375
    #endif

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_BVECTOR_H */

    // Local Variables:
    // mode:C++
    // End:

  4. #79
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    * Copyright (c) 1997
    * Silicon Graphics
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    */

    #ifndef __STL_CONFIG_H
    # define __STL_CONFIG_H

    // Flags:
    // * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin
    // type.
    // * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type.
    // * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48
    // function.
    // * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle
    // static members of template classes.
    // * __STL_STATIC_CONST_INIT_BUG: defined if the compiler can't handle a
    // constant-initializer in the declaration of a static const data member
    // of integer type. (See section 9.4.2, paragraph 4, of the C++ standard.)
    // * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports
    // partial specialization of template classes.
    // * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler
    // supports partial specialization syntax for full specialization of
    // class templates. (Even if it doesn't actually support partial
    // specialization itself.)
    // * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports
    // partial ordering of function templates. (a.k.a partial specialization
    // of function templates.)
    // * __STL_MEMBER_TEMPLATES: defined if the compiler supports template
    // member functions of classes.
    // * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports
    // nested classes that are member templates of other classes.
    // * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized
    // friend declarations.
    // * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler
    // supports calling a function template by providing its template
    // arguments explicitly.
    // * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable
    // to handle default template parameters that depend on previous template
    // parameters.
    // * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with
    // function template argument deduction for non-type template parameters.
    // * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable
    // to support the -> operator for iterators.
    // * __STL_DEFAULT_CONSTRUCTOR_BUG: defined if T() does not work properly
    // when T is a builtin type.
    // * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation
    // mode) supports exceptions.
    // * __STL_USE_NAMESPACES: defined if the compiler has the necessary
    // support for namespaces.
    // * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a
    // standard-conforming header <exception>.
    // * __STL_NO_BAD_ALLOC: defined if the compiler does not have a <new>
    // header, or if <new> does not contain a bad_alloc class. If a bad_alloc
    // class exists, it is assumed to be in namespace std.
    // * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX
    // system in mul hreaded mode, using native SGI threads instead of
    // pthreads.
    // * __STL_WIN32THREADS: defined if this is being compiled on a WIN32
    // compiler in mul hreaded mode.
    // * __STL_PTHREADS: defined if we should use portable pthreads
    // synchronization.
    // * __STL_UITHREADS: defined if we should use UI / solaris / UnixWare threads
    // synchronization. UIthreads are similar to pthreads, but are based
    // on an earlier version of the Posix threads standard.
    // * __STL_LONG_LONG if the compiler has long long and unsigned long long
    // types. (They're not in the C++ standard, but they are expected to be
    // included in the forthcoming C9X standard.)
    // * __STL_THREADS is defined if thread safety is needed.
    // * __STL_VOLATILE is defined to be "volatile" if threads are being
    // used, and the empty string otherwise.
    // * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error
    // checking to make sure that user-defined template arguments satisfy
    // all of the appropriate requirements. This may result in more
    // comprehensible error messages. It incurs no runtime overhead. This
    // feature requires member templates and partial specialization.
    // * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle "using"
    // clauses inside of class definitions.
    // * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend
    // declaractions where the friend is a template class.
    // * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not
    // support the use of a function pointer type as the argument
    // for a template.
    // * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template
    // keyword in a few new places (14.2.4). This flag is set for
    // compilers that support (and require) this usage.


    // User-settable macros that control compilation:
    // * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older
    // SGI-style allocators, instead of standard-conforming allocators,
    // even if the compiler supports all of the language features needed
    // for standard-conforming allocators.
    // * __STL_NO_NAMESPACES: if defined, don't put the library in namespace
    // std, even if the compiler supports namespaces.
    // * __STL_NO_RELOPS_NAMESPACE: if defined, don't put the relational
    // operator templates (>, <=. >=, !=) in namespace std::rel_ops, even
    // if the compiler supports namespaces and partial ordering of
    // function templates.
    // * __STL_ASSERTIONS: if defined, then enable runtime checking through the
    // __stl_assert macro.
    // * _PTHREADS: if defined, use Posix threads for mul hreading support.
    // * _UITHREADS:if defined, use SCO/Solaris/UI threads for mul hreading
    // support
    // * _NOTHREADS: if defined, don't use any mul hreading support.
    // * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that
    // we get from __STL_USE_CONCEPT_CHECKS.
    // * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new,
    // standard-conforming iostreams (e.g. the <iosfwd> header). If not
    // defined, the STL will use old cfront-style iostreams (e.g. the
    // <iostream.h> header).

    // Other macros defined by this file:

    // * bool, true, and false, if __STL_NO_BOOL is defined.
    // * typename, as a null macro if it's not already a keyword.
    // * explicit, as a null macro if it's not already a keyword.
    // * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.)
    // * exception-related macros (__STL_TRY, __STL_UNWIND, etc.)
    // * __stl_assert, either as a test or as a null macro, depending on
    // whether or not __STL_ASSERTIONS is defined.

    # if defined(_PTHREADS) && !defined(_NOTHREADS)
    # define __STL_PTHREADS
    # endif

    # if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)
    # define __STL_UITHREADS
    # endif

    # if defined(__sgi) && !defined(__GNUC__)
    # include <standards.h>
    # if !defined(_BOOL)
    # define __STL_NO_BOOL
    # endif
    # if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32
    # define __STL_STATIC_CONST_INIT_BUG
    # endif
    # if defined(_WCHAR_T_IS_KEYWORD)
    # define __STL_HAS_WCHAR_T
    # endif
    # if !defined(_TYPENAME_IS_KEYWORD)
    # define __STL_NEED_TYPENAME
    # endif
    # ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # endif
    # if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
    # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
    # endif
    # ifdef _MEMBER_TEMPLATES
    # define __STL_MEMBER_TEMPLATES
    # define __STL_TEMPLATE_FRIENDS
    # define __STL_MEMBER_TEMPLATE_CLASSES
    # endif
    # if defined(_MEMBER_TEMPLATE_KEYWORD)
    # define __STL_MEMBER_TEMPLATE_KEYWORD
    # endif
    # if defined(_STANDARD_C_PLUS_PLUS)
    # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
    # endif
    # if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
    # define __STL_MEMBER_TEMPLATE_KEYWORD
    # endif
    # if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32)
    # define __STL_DEFAULT_CONSTRUCTOR_BUG
    # endif
    # if !defined(_EXPLICIT_IS_KEYWORD)
    # define __STL_NEED_EXPLICIT
    # endif
    # ifdef __EXCEPTIONS
    # define __STL_USE_EXCEPTIONS
    # endif
    # if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)
    # define __STL_HAS_NAMESPACES
    # endif
    # if (_COMPILER_VERSION < 721) || \
    !defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES)
    # define __STL_NO_EXCEPTION_HEADER
    # endif
    # if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \
    !defined(_NAMESPACES)
    # define __STL_NO_BAD_ALLOC
    # endif
    # if !defined(_NOTHREADS) && !defined(__STL_PTHREADS)
    # define __STL_SGI_THREADS
    # endif
    # if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI
    # define __STL_LONG_LONG
    # endif
    # if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)
    # define __STL_USE_NEW_IOSTREAMS
    # endif
    # if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)
    # define __STL_CAN_THROW_RANGE_ERRORS
    # endif
    # if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS)
    # define __SGI_STL_USE_AUTO_PTR_CONVERSIONS
    # endif
    # endif


    /*
    * Jochen Schlick '1999 - added new #defines (__STL)_UITHREADS (for
    * providing SCO / Solaris / UI thread support)
    * - added the necessary defines for the SCO UDK 7
    * compiler (and its template friend behavior)
    * - all UDK7 specific STL changes are based on the
    * macro __USLC__ being defined
    */
    // SCO UDK 7 compiler (UnixWare 7x, OSR 5, UnixWare 2x)
    # if defined(__USLC__)
    # define __STL_HAS_WCHAR_T
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # define __STL_PARTIAL_SPECIALIZATION_SYNTAX
    # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
    # define __STL_MEMBER_TEMPLATES
    # define __STL_MEMBER_TEMPLATE_CLASSES
    # define __STL_USE_EXCEPTIONS
    # define __STL_HAS_NAMESPACES
    # define __STL_USE_NAMESPACES
    # define __STL_LONG_LONG
    # if defined(_REENTRANT)
    # define _UITHREADS /* if UnixWare < 7.0.1 */
    # define __STL_UITHREADS
    // use the following defines instead of the UI threads defines when
    // you want to use POSIX threads
    //# define _PTHREADS /* only if UnixWare >=7.0.1 */
    //# define __STL_PTHREADS
    # endif
    # endif



    # ifdef __GNUC__
    # if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
    # define __STL_STATIC_TEMPLATE_MEMBER_BUG
    # endif
    # if __GNUC__ < 2
    # define __STL_NEED_TYPENAME
    # define __STL_NEED_EXPLICIT
    # endif
    # if __GNUC__ == 2 && __GNUC_MINOR__ <= 8
    # define __STL_NO_EXCEPTION_HEADER
    # define __STL_NO_BAD_ALLOC
    # endif
    # if __GNUC__ == 2 && __GNUC_MINOR__ >= 8
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
    # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
    # define __STL_MEMBER_TEMPLATES
    # define __STL_CAN_THROW_RANGE_ERRORS
    // g++ 2.8.1 supports member template functions, but not member
    // template nested classes.
    # if __GNUC_MINOR__ >= 9
    # define __STL_MEMBER_TEMPLATE_CLASSES
    # define __STL_TEMPLATE_FRIENDS
    # define __SGI_STL_USE_AUTO_PTR_CONVERSIONS
    # define __STL_HAS_NAMESPACES
    //# define __STL_USE_NEW_IOSTREAMS
    # endif
    # endif
    # define __STL_DEFAULT_CONSTRUCTOR_BUG
    # ifdef __EXCEPTIONS
    # define __STL_USE_EXCEPTIONS
    # endif
    # ifdef _REENTRANT
    # define __STL_PTHREADS
    # endif
    # if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)
    # define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
    # endif
    # endif

    # if defined(__SUNPRO_CC)
    # define __STL_NO_BOOL
    # define __STL_NEED_TYPENAME
    # define __STL_NEED_EXPLICIT
    # define __STL_USE_EXCEPTIONS
    # ifdef _REENTRANT
    # define __STL_PTHREADS
    # endif
    # define __SGI_STL_NO_ARROW_OPERATOR
    # define __STL_PARTIAL_SPECIALIZATION_SYNTAX
    # define __STL_NO_EXCEPTION_HEADER
    # define __STL_NO_BAD_ALLOC
    # endif

    # if defined(__COMO__)
    # define __STL_MEMBER_TEMPLATES
    # define __STL_MEMBER_TEMPLATE_CLASSES
    # define __STL_TEMPLATE_FRIENDS
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # define __STL_USE_EXCEPTIONS
    # define __STL_HAS_NAMESPACES
    # endif

    // Intel compiler, which uses the EDG front end.
    # if defined(__ICL)
    # define __STL_LONG_LONG
    # define __STL_MEMBER_TEMPLATES
    # define __STL_MEMBER_TEMPLATE_CLASSES
    # define __STL_TEMPLATE_FRIENDS
    # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # define __STL_NO_DRAND48
    # define __STL_HAS_NAMESPACES
    # define __STL_USE_EXCEPTIONS
    # define __STL_MEMBER_TEMPLATE_KEYWORD
    # ifdef _CPPUNWIND
    # define __STL_USE_EXCEPTIONS
    # endif
    # ifdef _MT
    # define __STL_WIN32THREADS
    # endif
    # endif

    // Mingw32, egcs compiler using the Microsoft C runtime
    # if defined(__MINGW32__)
    # define __STL_NO_DRAND48
    # ifdef _MT
    # define __STL_WIN32THREADS
    # endif
    # endif

    // Cygwin32, egcs compiler on MS Windows
    # if defined(__CYGWIN__)
    # define __STL_NO_DRAND48
    # endif



    // Microsoft compiler.
    # if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__)
    # define __STL_NO_DRAND48
    # define __STL_STATIC_CONST_INIT_BUG
    # define __STL_NEED_TYPENAME
    # define __STL_NO_USING_CLAUSE_IN_CLASS
    # define __STL_NO_FRIEND_TEMPLATE_CLASS
    # if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */
    # define __STL_NEED_EXPLICIT
    # define __STL_NO_BOOL
    # define __STL_NO_BAD_ALLOC
    # endif
    # if _MSC_VER > 1000
    # include <yvals.h>
    # define __STL_DONT_USE_BOOL_TYPEDEF
    # endif
    # define __STL_NON_TYPE_TMPL_PARAM_BUG
    # define __SGI_STL_NO_ARROW_OPERATOR
    # define __STL_DEFAULT_CONSTRUCTOR_BUG
    # ifdef _CPPUNWIND
    # define __STL_USE_EXCEPTIONS
    # endif
    # ifdef _MT
    # define __STL_WIN32THREADS
    # endif
    # if _MSC_VER >= 1200
    # define __STL_PARTIAL_SPECIALIZATION_SYNTAX
    # define __STL_HAS_NAMESPACES
    # define __STL_CAN_THROW_RANGE_ERRORS
    # define NOMINMAX
    # undef min
    # undef max
    // disable warning 'initializers put in unrecognized initialization area'
    # pragma warning ( disable : 4075 )
    // disable warning 'empty controlled statement found'
    # pragma warning ( disable : 4390 )
    // disable warning 'debug symbol greater than 255 chars'
    # pragma warning ( disable : 4786 )
    # endif
    # if _MSC_VER < 1100
    # define __STL_NO_EXCEPTION_HEADER
    # define __STL_NO_BAD_ALLOC
    # endif
    // Because of a Microsoft front end bug, we must not provide a
    // namespace qualifier when declaring a friend function.
    # define __STD_QUALIFIER
    # endif

    # if defined(__BORLANDC__)
    # define __STL_NO_BAD_ALLOC
    # define __STL_NO_DRAND48
    # define __STL_DEFAULT_CONSTRUCTOR_BUG
    # if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */
    # define __STL_CLASS_PARTIAL_SPECIALIZATION
    # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
    # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
    # define __STL_MEMBER_TEMPLATES
    # define __STL_TEMPLATE_FRIENDS
    # else
    # define __STL_NEED_TYPENAME
    # define __STL_LIMITED_DEFAULT_TEMPLATES
    # define __SGI_STL_NO_ARROW_OPERATOR
    # define __STL_NON_TYPE_TMPL_PARAM_BUG
    # endif
    # ifdef _CPPUNWIND
    # define __STL_USE_EXCEPTIONS
    # endif
    # ifdef __MT__
    # define __STL_WIN32THREADS
    # endif
    # endif

    # if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF)
    typedef int bool;
    # define true 1
    # define false 0
    # endif

    # ifdef __STL_NEED_TYPENAME
    # define typename
    # endif

    # ifdef __STL_LIMITED_DEFAULT_TEMPLATES
    # define __STL_DEPENDENT_DEFAULT_TMPL(_Tp)
    # else
    # define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp
    # endif

    # ifdef __STL_MEMBER_TEMPLATE_KEYWORD
    # define __STL_TEMPLATE template
    # else
    # define __STL_TEMPLATE
    # endif

    # ifdef __STL_NEED_EXPLICIT
    # define explicit
    # endif

    # ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS
    # define __STL_NULL_TMPL_ARGS <>
    # else
    # define __STL_NULL_TMPL_ARGS
    # endif

    # if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \
    || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX)
    # define __STL_TEMPLATE_NULL template<>
    # else
    # define __STL_TEMPLATE_NULL
    # endif

    // Use standard-conforming allocators if we have the necessary language
    // features. __STL_USE_SGI_ALLOCATORS is a hook so that users can
    // disable new-style allocators, and continue to use the same kind of
    // allocators as before, without having to edit library headers.
    # if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \
    defined(__STL_MEMBER_TEMPLATES) && \
    defined(__STL_MEMBER_TEMPLATE_CLASSES) && \
    !defined(__STL_NO_BOOL) && \
    !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \
    !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \
    !defined(__STL_USE_SGI_ALLOCATORS)
    # define __STL_USE_STD_ALLOCATORS
    # endif

    # ifndef __STL_DEFAULT_ALLOCATOR
    # ifdef __STL_USE_STD_ALLOCATORS
    # define __STL_DEFAULT_ALLOCATOR(T) allocator< T >
    # else
    # define __STL_DEFAULT_ALLOCATOR(T) alloc
    # endif
    # endif

    // __STL_NO_NAMESPACES is a hook so that users can disable namespaces
    // without having to edit library headers. __STL_NO_RELOPS_NAMESPACE is
    // a hook so that users can disable the std::rel_ops namespace, keeping
    // the relational operator template in namespace std, without having to
    // edit library headers.
    # if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES)
    # define __STL_USE_NAMESPACES
    # define __STD std
    # define __STL_BEGIN_NAMESPACE namespace std {
    # define __STL_END_NAMESPACE }
    # if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \
    !defined(__STL_NO_RELOPS_NAMESPACE)
    # define __STL_USE_NAMESPACE_FOR_RELOPS
    # define __STL_BEGIN_RELOPS_NAMESPACE namespace std { namespace rel_ops {
    # define __STL_END_RELOPS_NAMESPACE } }
    # define __STD_RELOPS std::rel_ops
    # else /* Use std::rel_ops namespace */
    # define __STL_USE_NAMESPACE_FOR_RELOPS
    # define __STL_BEGIN_RELOPS_NAMESPACE namespace std {
    # define __STL_END_RELOPS_NAMESPACE }
    # define __STD_RELOPS std
    # endif /* Use std::rel_ops namespace */
    # else
    # define __STD
    # define __STL_BEGIN_NAMESPACE
    # define __STL_END_NAMESPACE
    # undef __STL_USE_NAMESPACE_FOR_RELOPS
    # define __STL_BEGIN_RELOPS_NAMESPACE
    # define __STL_END_RELOPS_NAMESPACE
    # define __STD_RELOPS
    # undef __STL_USE_NAMESPACES
    # endif

    // Some versions of the EDG front end sometimes require an explicit
    // namespace spec where they shouldn't. This macro facilitates that.
    // If the bug becomes irrelevant, then all uses of __STD_QUALIFIER
    // should be removed. The 7.3 beta SGI compiler has this bug, but the
    // MR version is not expected to have it.

    # if defined(__STL_USE_NAMESPACES) && !defined(__STD_QUALIFIER)
    # define __STD_QUALIFIER std::
    # else
    # define __STD_QUALIFIER
    # endif

    # ifdef __STL_USE_EXCEPTIONS
    # define __STL_TRY try
    # define __STL_CATCH_ALL catch(...)
    # define __STL_THROW(x) throw x
    # define __STL_RETHROW throw
    # define __STL_NOTHROW throw()
    # define __STL_UNWIND(action) catch(...) { action; throw; }
    # else
    # define __STL_TRY
    # define __STL_CATCH_ALL if (false)
    # define __STL_THROW(x)
    # define __STL_RETHROW
    # define __STL_NOTHROW
    # define __STL_UNWIND(action)
    # endif

    #ifdef __STL_ASSERTIONS
    # include <stdio.h>
    # define __stl_assert(expr) \
    if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \
    __FILE__, __LINE__, # expr); abort(); }
    #else
    # define __stl_assert(expr)
    #endif

    #if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \
    || defined(__STL_PTHREADS) || defined(__STL_UITHREADS)
    # define __STL_THREADS
    # define __STL_VOLATILE volatile
    #else
    # define __STL_VOLATILE
    #endif

    #if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \
    && defined(__STL_MEMBER_TEMPLATES) \
    && !defined(_STL_NO_CONCEPT_CHECKS)
    # define __STL_USE_CONCEPT_CHECKS
    #endif


    #endif /* __STL_CONFIG_H */

    // Local Variables:
    // mode:C++
    // End:

  5. #80
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1996,1997
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_CONSTRUCT_H
    #define __SGI_STL_INTERNAL_CONSTRUCT_H

    #include <new.h>

    __STL_BEGIN_NAMESPACE

    // construct and destroy. These functions are not part of the C++ standard,
    // and are provided for backward compatibility with the HP STL. We also
    // provide internal names _Construct and _Destroy that can be used within
    // the library, so that standard-conforming pieces don't have to rely on
    // non-standard extensions.

    // Internal names

    template <class _T1, class _T2>
    inline void _Construct(_T1* __p, const _T2& __value) {
    new ((void*) __p) _T1(__value);
    }

    template <class _T1>
    inline void _Construct(_T1* __p) {
    new ((void*) __p) _T1();
    }

    template <class _Tp>
    inline void _Destroy(_Tp* __pointer) {
    __pointer->~_Tp();
    }

    template <class _ForwardIterator>
    void
    __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
    {
    for ( ; __first != __last; ++__first)
    destroy(&*__first);
    }

    template <class _ForwardIterator>
    inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}

    template <class _ForwardIterator, class _Tp>
    inline void
    __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
    {
    typedef typename __type_traits<_Tp>::has_trivial_destructor
    _Trivial_destructor;
    __destroy_aux(__first, __last, _Trivial_destructor());
    }

    template <class _ForwardIterator>
    inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
    __destroy(__first, __last, __VALUE_TYPE(__first));
    }

    inline void _Destroy(char*, char*) {}
    inline void _Destroy(int*, int*) {}
    inline void _Destroy(long*, long*) {}
    inline void _Destroy(float*, float*) {}
    inline void _Destroy(double*, double*) {}
    #ifdef __STL_HAS_WCHAR_T
    inline void _Destroy(wchar_t*, wchar_t*) {}
    #endif /* __STL_HAS_WCHAR_T */

    // --------------------------------------------------
    // Old names from the HP STL.

    template <class _T1, class _T2>
    inline void construct(_T1* __p, const _T2& __value) {
    _Construct(__p, __value);
    }

    template <class _T1>
    inline void construct(_T1* __p) {
    _Construct(__p);
    }

    template <class _Tp>
    inline void destroy(_Tp* __pointer) {
    _Destroy(__pointer);
    }

    template <class _ForwardIterator>
    inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
    _Destroy(__first, __last);
    }

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */

    // Local Variables:
    // mode:C++
    // End:

  6. #81
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1999
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    // WARNING: This is an internal header file, included by other C++
    // standard library headers. You should not attempt to use this header
    // file directly.

    #ifndef __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H
    #define __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H

    // This file contains a few small adapters that allow a character
    // traits class to be used as a function object.

    __STL_BEGIN_NAMESPACE

    template <class _Traits>
    struct _Eq_traits
    : public binary_function<typename _Traits::char_type,
    typename _Traits::char_type,
    bool>
    {
    bool operator()(const typename _Traits::char_type& __x,
    const typename _Traits::char_type& __y) const
    { return _Traits::eq(__x, __y); }
    };

    template <class _Traits>
    struct _Eq_int_traits
    : public binary_function<typename _Traits::char_type,
    typename _Traits::int_type,
    bool>
    {
    bool operator()(const typename _Traits::char_type& __x,
    const typename _Traits::int_type& __y) const
    { return _Traits::eq_int_type(_Traits::to_int_type(__x), __y); }
    };

    template <class _Traits>
    struct _Lt_traits
    : public binary_function<typename _Traits::char_type,
    typename _Traits::char_type,
    bool>
    {
    bool operator()(const typename _Traits::char_type& __x,
    const typename _Traits::char_type& __y) const
    { return _Traits::lt(__x, __y); }
    };

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H */

    // Local Variables:
    // mode:C++
    // End:

  7. #82
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1997
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #include <concept_checks.h>

    #ifndef __SGI_STL_INTERNAL_DEQUE_H
    #define __SGI_STL_INTERNAL_DEQUE_H

    /* Class invariants:
    * For any nonsingular iterator i:
    * i.node is the address of an element in the map array. The
    * contents of i.node is a pointer to the beginning of a node.
    * i.first == *(i.node)
    * i.last == i.first + node_size
    * 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, and that a deque
    * with N elements, where N is the buffer size, must have two nodes.
    * 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).
    * A pointer in the range [map, map + map_size) points to an allocated node
    * if and only if the pointer is in the range [start.node, finish.node].
    */


    /*
    * In previous versions of deque, there was an extra template
    * parameter so users could control the node size. This extension
    * turns out to violate the C++ standard (it can be detected using
    * template template parameters), and it has been removed.
    */

    __STL_BEGIN_NAMESPACE

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma set woff 1174
    #pragma set woff 1375
    #endif

    // Note: this function is simply a kludge to work around several compilers'
    // bugs in handling constant expressions.
    inline size_t __deque_buf_size(size_t __size) {
    return __size < 512 ? size_t(512 / __size) : size_t(1);
    }

    template <class _Tp, class _Ref, class _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 { return *_M_cur; }
    #ifndef __SGI_STL_NO_ARROW_OPERATOR
    pointer operator->() const { return _M_cur; }
    #endif /* __SGI_STL_NO_ARROW_OPERATOR */

    difference_type operator-(const _Self& __x) const {
    return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) +
    (_M_cur - _M_first) + (__x._M_last - __x._M_cur);
    }

    _Self& operator++() {
    ++_M_cur;
    if (_M_cur == _M_last) {
    _M_set_node(_M_node + 1);
    _M_cur = _M_first;
    }
    return *this;
    }
    _Self operator++(int) {
    _Self __tmp = *this;
    ++*this;
    return __tmp;
    }

    _Self& operator--() {
    if (_M_cur == _M_first) {
    _M_set_node(_M_node - 1);
    _M_cur = _M_last;
    }
    --_M_cur;
    return *this;
    }
    _Self operator--(int) {
    _Self __tmp = *this;
    --*this;
    return __tmp;
    }

    _Self& operator+=(difference_type __n)
    {
    difference_type __offset = __n + (_M_cur - _M_first);
    if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
    _M_cur += __n;
    else {
    difference_type __node_offset =
    __offset > 0 ? __offset / difference_type(_S_buffer_size())
    : -difference_type((-__offset - 1) / _S_buffer_size()) - 1;
    _M_set_node(_M_node + __node_offset);
    _M_cur = _M_first +
    (__offset - __node_offset * difference_type(_S_buffer_size()));
    }
    return *this;
    }

    _Self operator+(difference_type __n) const
    {
    _Self __tmp = *this;
    return __tmp += __n;
    }

    _Self& operator-=(difference_type __n) { return *this += -__n; }

    _Self operator-(difference_type __n) const {
    _Self __tmp = *this;
    return __tmp -= __n;
    }

    reference operator[](difference_type __n) const { return *(*this + __n); }

    bool operator==(const _Self& __x) const { return _M_cur == __x._M_cur; }
    bool operator!=(const _Self& __x) const { return !(*this == __x); }
    bool operator<(const _Self& __x) const {
    return (_M_node == __x._M_node) ?
    (_M_cur < __x._M_cur) : (_M_node < __x._M_node);
    }
    bool operator>(const _Self& __x) const { return __x < *this; }
    bool operator<=(const _Self& __x) const { return !(__x < *this); }
    bool operator>=(const _Self& __x) const { return !(*this < __x); }

    void _M_set_node(_Map_pointer __new_node) {
    _M_node = __new_node;
    _M_first = *__new_node;
    _M_last = _M_first + difference_type(_S_buffer_size());
    }
    };

    template <class _Tp, class _Ref, class _Ptr>
    inline _Deque_iterator<_Tp, _Ref, _Ptr>
    operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
    {
    return __x + __n;
    }

    #ifndef __STL_CLASS_PARTIAL_SPECIALIZATION

    template <class _Tp, class _Ref, class _Ptr>
    inline random_access_iterator_tag
    iterator_category(const _Deque_iterator<_Tp,_Ref,_Ptr>&)
    {
    return random_access_iterator_tag();
    }

    template <class _Tp, class _Ref, class _Ptr>
    inline _Tp* value_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) { return 0; }

    template <class _Tp, class _Ref, class _Ptr>
    inline ptrdiff_t* distance_type(const _Deque_iterator<_Tp,_Ref,_Ptr>&) {
    return 0;
    }

    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    // Deque base class. It has two purposes. First, its constructor
    // and destructor allocate (but don't initialize) storage. This makes
    // exception safety easier. Second, the base class encapsulates all of
    // the differences between SGI-style allocators and standard-conforming
    // allocators.

    #ifdef __STL_USE_STD_ALLOCATORS

    // Base class for ordinary allocators.
    template <class _Tp, class _Alloc, bool __is_static>
    class _Deque_alloc_base {
    public:
    typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
    allocator_type get_allocator() const { return _M_node_allocator; }

    _Deque_alloc_base(const allocator_type& __a)
    : _M_node_allocator(__a), _M_map_allocator(__a),
    _M_map(0), _M_map_size(0)
    {}

    protected:
    typedef typename _Alloc_traits<_Tp*, _Alloc>::allocator_type
    _Map_allocator_type;

    allocator_type _M_node_allocator;
    _Map_allocator_type _M_map_allocator;

    _Tp* _M_allocate_node() {
    return _M_node_allocator.allocate(__deque_buf_size(sizeof (_Tp)));
    }
    void _M_deallocate_node(_Tp* __p) {
    _M_node_allocator.deallocate(__p, __deque_buf_size(sizeof(_Tp)));
    }
    _Tp** _M_allocate_map(size_t __n)
    { return _M_map_allocator.allocate(__n); }
    void _M_deallocate_map(_Tp** __p, size_t __n)
    { _M_map_allocator.deallocate(__p, __n); }

    _Tp** _M_map;
    size_t _M_map_size;
    };

    // Specialization for instanceless allocators.
    template <class _Tp, class _Alloc>
    class _Deque_alloc_base<_Tp, _Alloc, true>
    {
    public:
    typedef typename _Alloc_traits<_Tp,_Alloc>::allocator_type allocator_type;
    allocator_type get_allocator() const { return allocator_type(); }

    _Deque_alloc_base(const allocator_type&) : _M_map(0), _M_map_size(0) {}

    protected:
    typedef typename _Alloc_traits<_Tp, _Alloc>::_Alloc_type _Node_alloc_type;
    typedef typename _Alloc_traits<_Tp*, _Alloc>::_Alloc_type _Map_alloc_type;

    _Tp* _M_allocate_node() {
    return _Node_alloc_type::allocate(__deque_buf_size(sizeof (_Tp)));
    }
    void _M_deallocate_node(_Tp* __p) {
    _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp)));
    }
    _Tp** _M_allocate_map(size_t __n)
    { return _Map_alloc_type::allocate(__n); }
    void _M_deallocate_map(_Tp** __p, size_t __n)
    { _Map_alloc_type::deallocate(__p, __n); }

    _Tp** _M_map;
    size_t _M_map_size;
    };

    template <class _Tp, class _Alloc>
    class _Deque_base
    : public _Deque_alloc_base<_Tp,_Alloc,
    _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
    {
    public:
    typedef _Deque_alloc_base<_Tp,_Alloc,
    _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
    _Base;
    typedef typename _Base::allocator_type allocator_type;
    typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
    typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;

    _Deque_base(const allocator_type& __a, size_t __num_elements)
    : _Base(__a), _M_start(), _M_finish()
    { _M_initialize_map(__num_elements); }
    _Deque_base(const allocator_type& __a)
    : _Base(__a), _M_start(), _M_finish() {}
    ~_Deque_base();

    protected:
    void _M_initialize_map(size_t);
    void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
    void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
    enum { _S_initial_map_size = 8 };

    protected:
    iterator _M_start;
    iterator _M_finish;
    };

    #else /* __STL_USE_STD_ALLOCATORS */

    template <class _Tp, class _Alloc>
    class _Deque_base {
    public:
    typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
    typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;

    typedef _Alloc allocator_type;
    allocator_type get_allocator() const { return allocator_type(); }

    _Deque_base(const allocator_type&, size_t __num_elements)
    : _M_map(0), _M_map_size(0), _M_start(), _M_finish() {
    _M_initialize_map(__num_elements);
    }
    _Deque_base(const allocator_type&)
    : _M_map(0), _M_map_size(0), _M_start(), _M_finish() {}
    ~_Deque_base();

    protected:
    void _M_initialize_map(size_t);
    void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
    void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
    enum { _S_initial_map_size = 8 };

    protected:
    _Tp** _M_map;
    size_t _M_map_size;
    iterator _M_start;
    iterator _M_finish;

    typedef simple_alloc<_Tp, _Alloc> _Node_alloc_type;
    typedef simple_alloc<_Tp*, _Alloc> _Map_alloc_type;

    _Tp* _M_allocate_node()
    { return _Node_alloc_type::allocate(__deque_buf_size(sizeof (_Tp))); }
    void _M_deallocate_node(_Tp* __p)
    { _Node_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp))); }
    _Tp** _M_allocate_map(size_t __n)
    { return _Map_alloc_type::allocate(__n); }
    void _M_deallocate_map(_Tp** __p, size_t __n)
    { _Map_alloc_type::deallocate(__p, __n); }
    };

    #endif /* __STL_USE_STD_ALLOCATORS */

    // Non-inline member functions from _Deque_base.

    template <class _Tp, class _Alloc>
    _Deque_base<_Tp,_Alloc>::~_Deque_base() {
    if (_M_map) {
    _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1);
    _M_deallocate_map(_M_map, _M_map_size);
    }
    }

    template <class _Tp, class _Alloc>
    void
    _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
    {
    size_t __num_nodes =
    __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;

    _M_map_size = max((size_t) _S_initial_map_size, __num_nodes + 2);
    _M_map = _M_allocate_map(_M_map_size);

    _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2;
    _Tp** __nfinish = __nstart + __num_nodes;

    __STL_TRY {
    _M_create_nodes(__nstart, __nfinish);
    }
    __STL_UNWIND((_M_deallocate_map(_M_map, _M_map_size),
    _M_map = 0, _M_map_size = 0));
    _M_start._M_set_node(__nstart);
    _M_finish._M_set_node(__nfinish - 1);
    _M_start._M_cur = _M_start._M_first;
    _M_finish._M_cur = _M_finish._M_first +
    __num_elements % __deque_buf_size(sizeof(_Tp));
    }

    template <class _Tp, class _Alloc>
    void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
    {
    _Tp** __cur;
    __STL_TRY {
    for (__cur = __nstart; __cur < __nfinish; ++__cur)
    *__cur = _M_allocate_node();
    }
    __STL_UNWIND(_M_destroy_nodes(__nstart, __cur));
    }

    template <class _Tp, class _Alloc>
    void
    _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
    {
    for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
    _M_deallocate_node(*__n);
    }

    template <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    class deque : protected _Deque_base<_Tp, _Alloc> {

    // requirements:

    __STL_CLASS_REQUIRES(_Tp, _Assignable);

    typedef _Deque_base<_Tp, _Alloc> _Base;
    public: // Basic types
    typedef _Tp value_type;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef value_type& reference;
    typedef const value_type& const_reference;
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;

    typedef typename _Base::allocator_type allocator_type;
    allocator_type get_allocator() const { return _Base::get_allocator(); }

    public: // Iterators
    typedef typename _Base::iterator iterator;
    typedef typename _Base::const_iterator const_iterator;

    #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
    typedef reverse_iterator<const_iterator> const_reverse_iterator;
    typedef reverse_iterator<iterator> reverse_iterator;
    #else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
    typedef reverse_iterator<const_iterator, value_type, const_reference,
    difference_type>
    const_reverse_iterator;
    typedef reverse_iterator<iterator, value_type, reference, difference_type>
    reverse_iterator;
    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    protected: // Internal typedefs
    typedef pointer* _Map_pointer;
    static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }

    protected:
    #ifdef __STL_USE_NAMESPACES
    using _Base::_M_initialize_map;
    using _Base::_M_create_nodes;
    using _Base::_M_destroy_nodes;
    using _Base::_M_allocate_node;
    using _Base::_M_deallocate_node;
    using _Base::_M_allocate_map;
    using _Base::_M_deallocate_map;

    using _Base::_M_map;
    using _Base::_M_map_size;
    using _Base::_M_start;
    using _Base::_M_finish;
    #endif /* __STL_USE_NAMESPACES */

    public: // Basic accessors
    iterator begin() { return _M_start; }
    iterator end() { return _M_finish; }
    const_iterator begin() const { return _M_start; }
    const_iterator end() const { return _M_finish; }

    reverse_iterator rbegin() { return reverse_iterator(_M_finish); }
    reverse_iterator rend() { return reverse_iterator(_M_start); }
    const_reverse_iterator rbegin() const
    { return const_reverse_iterator(_M_finish); }
    const_reverse_iterator rend() const
    { return const_reverse_iterator(_M_start); }

    reference operator[](size_type __n)
    { return _M_start[difference_type(__n)]; }
    const_reference operator[](size_type __n) const
    { return _M_start[difference_type(__n)]; }

    #ifdef __STL_THROW_RANGE_ERRORS
    void _M_range_check(size_type __n) const {
    if (__n >= this->size())
    __stl_throw_range_error("deque");
    }

    reference at(size_type __n)
    { _M_range_check(__n); return (*this)[__n]; }
    const_reference at(size_type __n) const
    { _M_range_check(__n); return (*this)[__n]; }
    #endif /* __STL_THROW_RANGE_ERRORS */

    reference front() { return *_M_start; }
    reference back() {
    iterator __tmp = _M_finish;
    --__tmp;
    return *__tmp;
    }
    const_reference front() const { return *_M_start; }
    const_reference back() const {
    const_iterator __tmp = _M_finish;
    --__tmp;
    return *__tmp;
    }

    size_type size() const { return _M_finish - _M_start; }
    size_type max_size() const { return size_type(-1); }
    bool empty() const { return _M_finish == _M_start; }

  8. #83
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    public: // Constructor, destructor.
    explicit deque(const allocator_type& __a = allocator_type())
    : _Base(__a, 0) {}
    deque(const deque& __x) : _Base(__x.get_allocator(), __x.size())
    { uninitialized_copy(__x.begin(), __x.end(), _M_start); }
    deque(size_type __n, const value_type& __value,
    const allocator_type& __a = allocator_type()) : _Base(__a, __n)
    { _M_fill_initialize(__value); }
    explicit deque(size_type __n) : _Base(allocator_type(), __n)
    { _M_fill_initialize(value_type()); }

    #ifdef __STL_MEMBER_TEMPLATES

    // Check whether it's an integral type. If so, it's not an iterator.
    template <class _Inpu erator>
    deque(_Inpu erator __first, _Inpu erator __last,
    const allocator_type& __a = allocator_type()) : _Base(__a) {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_initialize_dispatch(__first, __last, _Integral());
    }

    template <class _Integer>
    void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
    _M_initialize_map(__n);
    _M_fill_initialize(__x);
    }

    template <class _Inpu er>
    void _M_initialize_dispatch(_Inpu er __first, _Inpu er __last,
    __false_type) {
    _M_range_initialize(__first, __last, __ITERATOR_CATEGORY(__first));
    }

    #else /* __STL_MEMBER_TEMPLATES */

    deque(const value_type* __first, const value_type* __last,
    const allocator_type& __a = allocator_type())
    : _Base(__a, __last - __first)
    { uninitialized_copy(__first, __last, _M_start); }
    deque(const_iterator __first, const_iterator __last,
    const allocator_type& __a = allocator_type())
    : _Base(__a, __last - __first)
    { uninitialized_copy(__first, __last, _M_start); }

    #endif /* __STL_MEMBER_TEMPLATES */

    ~deque() { destroy(_M_start, _M_finish); }

    deque& operator= (const deque& __x) {
    const size_type __len = size();
    if (&__x != this) {
    if (__len >= __x.size())
    erase(copy(__x.begin(), __x.end(), _M_start), _M_finish);
    else {
    const_iterator __mid = __x.begin() + difference_type(__len);
    copy(__x.begin(), __mid, _M_start);
    insert(_M_finish, __mid, __x.end());
    }
    }
    return *this;
    }

    void swap(deque& __x) {
    __STD::swap(_M_start, __x._M_start);
    __STD::swap(_M_finish, __x._M_finish);
    __STD::swap(_M_map, __x._M_map);
    __STD::swap(_M_map_size, __x._M_map_size);
    }

    public:
    // assign(), a generalized assignment member function. Two
    // versions: one that takes a count, and one that takes a range.
    // The range version is a member template, so we dispatch on whether
    // or not the type is an integer.

    void _M_fill_assign(size_type __n, const _Tp& __val) {
    if (__n > size()) {
    fill(begin(), end(), __val);
    insert(end(), __n - size(), __val);
    }
    else {
    erase(begin() + __n, end());
    fill(begin(), end(), __val);
    }
    }

    void assign(size_type __n, const _Tp& __val) {
    _M_fill_assign(__n, __val);
    }

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Inpu erator>
    void assign(_Inpu erator __first, _Inpu erator __last) {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_assign_dispatch(__first, __last, _Integral());
    }

    private: // helper functions for assign()

    template <class _Integer>
    void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
    { _M_fill_assign((size_type) __n, (_Tp) __val); }

    template <class _Inpu erator>
    void _M_assign_dispatch(_Inpu erator __first, _Inpu erator __last,
    __false_type) {
    _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first));
    }

    template <class _Inpu erator>
    void _M_assign_aux(_Inpu erator __first, _Inpu erator __last,
    input_iterator_tag);

    template <class _ForwardIterator>
    void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag) {
    size_type __len = 0;
    distance(__first, __last, __len);
    if (__len > size()) {
    _ForwardIterator __mid = __first;
    advance(__mid, size());
    copy(__first, __mid, begin());
    insert(end(), __mid, __last);
    }
    else
    erase(copy(__first, __last, begin()), end());
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    public: // push_* and pop_*

    void push_back(const value_type& __t) {
    if (_M_finish._M_cur != _M_finish._M_last - 1) {
    construct(_M_finish._M_cur, __t);
    ++_M_finish._M_cur;
    }
    else
    _M_push_back_aux(__t);
    }

    void push_back() {
    if (_M_finish._M_cur != _M_finish._M_last - 1) {
    construct(_M_finish._M_cur);
    ++_M_finish._M_cur;
    }
    else
    _M_push_back_aux();
    }

    void push_front(const value_type& __t) {
    if (_M_start._M_cur != _M_start._M_first) {
    construct(_M_start._M_cur - 1, __t);
    --_M_start._M_cur;
    }
    else
    _M_push_front_aux(__t);
    }

    void push_front() {
    if (_M_start._M_cur != _M_start._M_first) {
    construct(_M_start._M_cur - 1);
    --_M_start._M_cur;
    }
    else
    _M_push_front_aux();
    }


    void pop_back() {
    if (_M_finish._M_cur != _M_finish._M_first) {
    --_M_finish._M_cur;
    destroy(_M_finish._M_cur);
    }
    else
    _M_pop_back_aux();
    }

    void pop_front() {
    if (_M_start._M_cur != _M_start._M_last - 1) {
    destroy(_M_start._M_cur);
    ++_M_start._M_cur;
    }
    else
    _M_pop_front_aux();
    }

    public: // Insert

    iterator insert(iterator position, const value_type& __x) {
    if (position._M_cur == _M_start._M_cur) {
    push_front(__x);
    return _M_start;
    }
    else if (position._M_cur == _M_finish._M_cur) {
    push_back(__x);
    iterator __tmp = _M_finish;
    --__tmp;
    return __tmp;
    }
    else {
    return _M_insert_aux(position, __x);
    }
    }

    iterator insert(iterator __position)
    { return insert(__position, value_type()); }

    void insert(iterator __pos, size_type __n, const value_type& __x)
    { _M_fill_insert(__pos, __n, __x); }

    void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);

    #ifdef __STL_MEMBER_TEMPLATES

    // Check whether it's an integral type. If so, it's not an iterator.
    template <class _Inpu erator>
    void insert(iterator __pos, _Inpu erator __first, _Inpu erator __last) {
    typedef typename _Is_integer<_Inpu erator>::_Integral _Integral;
    _M_insert_dispatch(__pos, __first, __last, _Integral());
    }

    template <class _Integer>
    void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
    __true_type) {
    _M_fill_insert(__pos, (size_type) __n, (value_type) __x);
    }

    template <class _Inpu erator>
    void _M_insert_dispatch(iterator __pos,
    _Inpu erator __first, _Inpu erator __last,
    __false_type) {
    insert(__pos, __first, __last, __ITERATOR_CATEGORY(__first));
    }

    #else /* __STL_MEMBER_TEMPLATES */

    void insert(iterator __pos,
    const value_type* __first, const value_type* __last);
    void insert(iterator __pos,
    const_iterator __first, const_iterator __last);

    #endif /* __STL_MEMBER_TEMPLATES */

    void resize(size_type __new_size, const value_type& __x) {
    const size_type __len = size();
    if (__new_size < __len)
    erase(_M_start + __new_size, _M_finish);
    else
    insert(_M_finish, __new_size - __len, __x);
    }

    void resize(size_type new_size) { resize(new_size, value_type()); }

    public: // Erase
    iterator erase(iterator __pos) {
    iterator __next = __pos;
    ++__next;
    difference_type __index = __pos - _M_start;
    if (size_type(__index) < (this->size() >> 1)) {
    copy_backward(_M_start, __pos, __next);
    pop_front();
    }
    else {
    copy(__next, _M_finish, __pos);
    pop_back();
    }
    return _M_start + __index;
    }

    iterator erase(iterator __first, iterator __last);
    void clear();

    protected: // Internal construction/destruction

    void _M_fill_initialize(const value_type& __value);

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Inpu erator>
    void _M_range_initialize(_Inpu erator __first, _Inpu erator __last,
    input_iterator_tag);

    template <class _ForwardIterator>
    void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag);

    #endif /* __STL_MEMBER_TEMPLATES */

    protected: // Internal push_* and pop_*

    void _M_push_back_aux(const value_type&);
    void _M_push_back_aux();
    void _M_push_front_aux(const value_type&);
    void _M_push_front_aux();
    void _M_pop_back_aux();
    void _M_pop_front_aux();

    protected: // Internal insert functions

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Inpu erator>
    void insert(iterator __pos, _Inpu erator __first, _Inpu erator __last,
    input_iterator_tag);

    template <class _ForwardIterator>
    void insert(iterator __pos,
    _ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag);

    #endif /* __STL_MEMBER_TEMPLATES */

    iterator _M_insert_aux(iterator __pos, const value_type& __x);
    iterator _M_insert_aux(iterator __pos);
    void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x);

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _ForwardIterator>
    void _M_insert_aux(iterator __pos,
    _ForwardIterator __first, _ForwardIterator __last,
    size_type __n);

    #else /* __STL_MEMBER_TEMPLATES */

    void _M_insert_aux(iterator __pos,
    const value_type* __first, const value_type* __last,
    size_type __n);

    void _M_insert_aux(iterator __pos,
    const_iterator __first, const_iterator __last,
    size_type __n);

    #endif /* __STL_MEMBER_TEMPLATES */

    iterator _M_reserve_elements_at_front(size_type __n) {
    size_type __vacancies = _M_start._M_cur - _M_start._M_first;
    if (__n > __vacancies)
    _M_new_elements_at_front(__n - __vacancies);
    return _M_start - difference_type(__n);
    }

    iterator _M_reserve_elements_at_back(size_type __n) {
    size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1;
    if (__n > __vacancies)
    _M_new_elements_at_back(__n - __vacancies);
    return _M_finish + difference_type(__n);
    }

    void _M_new_elements_at_front(size_type __new_elements);
    void _M_new_elements_at_back(size_type __new_elements);

    protected: // Allocation of _M_map and nodes

    // 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.)

    void _M_reserve_map_at_back (size_type __nodes_to_add = 1) {
    if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map))
    _M_reallocate_map(__nodes_to_add, false);
    }

    void _M_reserve_map_at_front (size_type __nodes_to_add = 1) {
    if (__nodes_to_add > size_type(_M_start._M_node - _M_map))
    _M_reallocate_map(__nodes_to_add, true);
    }

    void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
    };

    // Non-inline member functions

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Tp, class _Alloc>
    template <class _Inpu er>
    void deque<_Tp, _Alloc>
    ::_M_assign_aux(_Inpu er __first, _Inpu er __last, input_iterator_tag)
    {
    iterator __cur = begin();
    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
    *__cur = *__first;
    if (__first == __last)
    erase(__cur, end());
    else
    insert(end(), __first, __last);
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    template <class _Tp, class _Alloc>
    void deque<_Tp, _Alloc>::_M_fill_insert(iterator __pos,
    size_type __n, const value_type& __x)
    {
    if (__pos._M_cur == _M_start._M_cur) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    __STL_TRY {
    uninitialized_fill(__new_start, _M_start, __x);
    _M_start = __new_start;
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else if (__pos._M_cur == _M_finish._M_cur) {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    __STL_TRY {
    uninitialized_fill(_M_finish, __new_finish, __x);
    _M_finish = __new_finish;
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    else
    _M_insert_aux(__pos, __n, __x);
    }

    #ifndef __STL_MEMBER_TEMPLATES

    template <class _Tp, class _Alloc>
    void deque<_Tp, _Alloc>::insert(iterator __pos,
    const value_type* __first,
    const value_type* __last) {
    size_type __n = __last - __first;
    if (__pos._M_cur == _M_start._M_cur) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, __new_start);
    _M_start = __new_start;
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else if (__pos._M_cur == _M_finish._M_cur) {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, _M_finish);
    _M_finish = __new_finish;
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    else
    _M_insert_aux(__pos, __first, __last, __n);
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::insert(iterator __pos,
    const_iterator __first, const_iterator __last)
    {
    size_type __n = __last - __first;
    if (__pos._M_cur == _M_start._M_cur) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, __new_start);
    _M_start = __new_start;
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else if (__pos._M_cur == _M_finish._M_cur) {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, _M_finish);
    _M_finish = __new_finish;
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    else
    _M_insert_aux(__pos, __first, __last, __n);
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    template <class _Tp, class _Alloc>
    typename deque<_Tp,_Alloc>::iterator
    deque<_Tp,_Alloc>::erase(iterator __first, iterator __last)
    {
    if (__first == _M_start && __last == _M_finish) {
    clear();
    return _M_finish;
    }
    else {
    difference_type __n = __last - __first;
    difference_type __elems_before = __first - _M_start;
    if (__elems_before < difference_type((this->size() - __n) / 2)) {
    copy_backward(_M_start, __first, __last);
    iterator __new_start = _M_start + __n;
    destroy(_M_start, __new_start);
    _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
    _M_start = __new_start;
    }
    else {
    copy(__last, _M_finish, __first);
    iterator __new_finish = _M_finish - __n;
    destroy(__new_finish, _M_finish);
    _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1);
    _M_finish = __new_finish;
    }
    return _M_start + __elems_before;
    }
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::clear()
    {
    for (_Map_pointer __node = _M_start._M_node + 1;
    __node < _M_finish._M_node;
    ++__node) {
    destroy(*__node, *__node + _S_buffer_size());
    _M_deallocate_node(*__node);
    }

    if (_M_start._M_node != _M_finish._M_node) {
    destroy(_M_start._M_cur, _M_start._M_last);
    destroy(_M_finish._M_first, _M_finish._M_cur);
    _M_deallocate_node(_M_finish._M_first);
    }
    else
    destroy(_M_start._M_cur, _M_finish._M_cur);

    _M_finish = _M_start;
    }

    // Precondition: _M_start and _M_finish have already been initialized,
    // but none of the deque's elements have yet been constructed.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __value) {
    _Map_pointer __cur;
    __STL_TRY {
    for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur)
    uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
    uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value);
    }
    __STL_UNWIND(destroy(_M_start, iterator(*__cur, __cur)));
    }

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Tp, class _Alloc> template <class _Inpu erator>
    void deque<_Tp,_Alloc>::_M_range_initialize(_Inpu era tor __first,
    _Inpu erator __last,
    input_iterator_tag)
    {
    _M_initialize_map(0);
    __STL_TRY {
    for ( ; __first != __last; ++__first)
    push_back(*__first);
    }
    __STL_UNWIND(clear());
    }

    template <class _Tp, class _Alloc> template <class _ForwardIterator>
    void deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIte rator __first,
    _ForwardIterator __last,
    forward_iterator_tag)
    {
    size_type __n = 0;
    distance(__first, __last, __n);
    _M_initialize_map(__n);

    _Map_pointer __cur_node;
    __STL_TRY {
    for (__cur_node = _M_start._M_node;
    __cur_node < _M_finish._M_node;
    ++__cur_node) {
    _ForwardIterator __mid = __first;
    advance(__mid, _S_buffer_size());
    uninitialized_copy(__first, __mid, *__cur_node);
    __first = __mid;
    }
    uninitialized_copy(__first, __last, _M_finish._M_first);
    }
    __STL_UNWIND(destroy(_M_start, iterator(*__cur_node, __cur_node)));
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_push_back_aux(const value_type& __t)
    {
    value_type __t_copy = __t;
    _M_reserve_map_at_back();
    *(_M_finish._M_node + 1) = _M_allocate_node();
    __STL_TRY {
    construct(_M_finish._M_cur, __t_copy);
    _M_finish._M_set_node(_M_finish._M_node + 1);
    _M_finish._M_cur = _M_finish._M_first;
    }
    __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_nod e + 1)));
    }

  9. #84
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_push_back_aux()
    {
    _M_reserve_map_at_back();
    *(_M_finish._M_node + 1) = _M_allocate_node();
    __STL_TRY {
    construct(_M_finish._M_cur);
    _M_finish._M_set_node(_M_finish._M_node + 1);
    _M_finish._M_cur = _M_finish._M_first;
    }
    __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_nod e + 1)));
    }

    // Called only if _M_start._M_cur == _M_start._M_first.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t)
    {
    value_type __t_copy = __t;
    _M_reserve_map_at_front();
    *(_M_start._M_node - 1) = _M_allocate_node();
    __STL_TRY {
    _M_start._M_set_node(_M_start._M_node - 1);
    _M_start._M_cur = _M_start._M_last - 1;
    construct(_M_start._M_cur, __t_copy);
    }
    __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));
    }

    // Called only if _M_start._M_cur == _M_start._M_first.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_push_front_aux()
    {
    _M_reserve_map_at_front();
    *(_M_start._M_node - 1) = _M_allocate_node();
    __STL_TRY {
    _M_start._M_set_node(_M_start._M_node - 1);
    _M_start._M_cur = _M_start._M_last - 1;
    construct(_M_start._M_cur);
    }
    __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));
    }

    // Called only if _M_finish._M_cur == _M_finish._M_first.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_pop_back_aux()
    {
    _M_deallocate_node(_M_finish._M_first);
    _M_finish._M_set_node(_M_finish._M_node - 1);
    _M_finish._M_cur = _M_finish._M_last - 1;
    destroy(_M_finish._M_cur);
    }

    // Called only if _M_start._M_cur == _M_start._M_last - 1. Note that
    // if the deque has at least one element (a precondition for this member
    // function), and if _M_start._M_cur == _M_start._M_last, then the deque
    // must have at least two nodes.
    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_pop_front_aux()
    {
    destroy(_M_start._M_cur);
    _M_deallocate_node(_M_start._M_first);
    _M_start._M_set_node(_M_start._M_node + 1);
    _M_start._M_cur = _M_start._M_first;
    }

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Tp, class _Alloc> template <class _Inpu erator>
    void deque<_Tp,_Alloc>::insert(iterator __pos,
    _Inpu erator __first, _Inpu erator __last,
    input_iterator_tag)
    {
    copy(__first, __last, inserter(*this, __pos));
    }

    template <class _Tp, class _Alloc> template <class _ForwardIterator>
    void
    deque<_Tp,_Alloc>::insert(iterator __pos,
    _ForwardIterator __first, _ForwardIterator __last,
    forward_iterator_tag) {
    size_type __n = 0;
    distance(__first, __last, __n);
    if (__pos._M_cur == _M_start._M_cur) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, __new_start);
    _M_start = __new_start;
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else if (__pos._M_cur == _M_finish._M_cur) {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    __STL_TRY {
    uninitialized_copy(__first, __last, _M_finish);
    _M_finish = __new_finish;
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    else
    _M_insert_aux(__pos, __first, __last, __n);
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    template <class _Tp, class _Alloc>
    typename deque<_Tp, _Alloc>::iterator
    deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos, const value_type& __x)
    {
    difference_type __index = __pos - _M_start;
    value_type __x_copy = __x;
    if (size_type(__index) < this->size() / 2) {
    push_front(front());
    iterator __front1 = _M_start;
    ++__front1;
    iterator __front2 = __front1;
    ++__front2;
    __pos = _M_start + __index;
    iterator __pos1 = __pos;
    ++__pos1;
    copy(__front2, __pos1, __front1);
    }
    else {
    push_back(back());
    iterator __back1 = _M_finish;
    --__back1;
    iterator __back2 = __back1;
    --__back2;
    __pos = _M_start + __index;
    copy_backward(__pos, __back2, __back1);
    }
    *__pos = __x_copy;
    return __pos;
    }

    template <class _Tp, class _Alloc>
    typename deque<_Tp,_Alloc>::iterator
    deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos)
    {
    difference_type __index = __pos - _M_start;
    if (__index < size() / 2) {
    push_front(front());
    iterator __front1 = _M_start;
    ++__front1;
    iterator __front2 = __front1;
    ++__front2;
    __pos = _M_start + __index;
    iterator __pos1 = __pos;
    ++__pos1;
    copy(__front2, __pos1, __front1);
    }
    else {
    push_back(back());
    iterator __back1 = _M_finish;
    --__back1;
    iterator __back2 = __back1;
    --__back2;
    __pos = _M_start + __index;
    copy_backward(__pos, __back2, __back1);
    }
    *__pos = value_type();
    return __pos;
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
    size_type __n,
    const value_type& __x)
    {
    const difference_type __elems_before = __pos - _M_start;
    size_type __length = this->size();
    value_type __x_copy = __x;
    if (__elems_before < difference_type(__length / 2)) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    iterator __old_start = _M_start;
    __pos = _M_start + __elems_before;
    __STL_TRY {
    if (__elems_before >= difference_type(__n)) {
    iterator __start_n = _M_start + difference_type(__n);
    uninitialized_copy(_M_start, __start_n, __new_start);
    _M_start = __new_start;
    copy(__start_n, __pos, __old_start);
    fill(__pos - difference_type(__n), __pos, __x_copy);
    }
    else {
    __uninitialized_copy_fill(_M_start, __pos, __new_start,
    _M_start, __x_copy);
    _M_start = __new_start;
    fill(__old_start, __pos, __x_copy);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    iterator __old_finish = _M_finish;
    const difference_type __elems_after =
    difference_type(__length) - __elems_before;
    __pos = _M_finish - __elems_after;
    __STL_TRY {
    if (__elems_after > difference_type(__n)) {
    iterator __finish_n = _M_finish - difference_type(__n);
    uninitialized_copy(__finish_n, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy_backward(__pos, __finish_n, __old_finish);
    fill(__pos, __pos + difference_type(__n), __x_copy);
    }
    else {
    __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n),
    __x_copy, __pos, _M_finish);
    _M_finish = __new_finish;
    fill(__pos, __old_finish, __x_copy);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    }

    #ifdef __STL_MEMBER_TEMPLATES

    template <class _Tp, class _Alloc> template <class _ForwardIterator>
    void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
    _ForwardIterator __first,
    _ForwardIterator __last,
    size_type __n)
    {
    const difference_type __elemsbefore = __pos - _M_start;
    size_type __length = size();
    if (__elemsbefore < __length / 2) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    iterator __old_start = _M_start;
    __pos = _M_start + __elemsbefore;
    __STL_TRY {
    if (__elemsbefore >= difference_type(__n)) {
    iterator __start_n = _M_start + difference_type(__n);
    uninitialized_copy(_M_start, __start_n, __new_start);
    _M_start = __new_start;
    copy(__start_n, __pos, __old_start);
    copy(__first, __last, __pos - difference_type(__n));
    }
    else {
    _ForwardIterator __mid = __first;
    advance(__mid, difference_type(__n) - __elemsbefore);
    __uninitialized_copy_copy(_M_start, __pos, __first, __mid,
    __new_start);
    _M_start = __new_start;
    copy(__mid, __last, __old_start);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    iterator __old_finish = _M_finish;
    const difference_type __elemsafter =
    difference_type(__length) - __elemsbefore;
    __pos = _M_finish - __elemsafter;
    __STL_TRY {
    if (__elemsafter > difference_type(__n)) {
    iterator __finish_n = _M_finish - difference_type(__n);
    uninitialized_copy(__finish_n, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy_backward(__pos, __finish_n, __old_finish);
    copy(__first, __last, __pos);
    }
    else {
    _ForwardIterator __mid = __first;
    advance(__mid, __elemsafter);
    __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy(__first, __mid, __pos);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    }

    #else /* __STL_MEMBER_TEMPLATES */

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
    const value_type* __first,
    const value_type* __last,
    size_type __n)
    {
    const difference_type __elemsbefore = __pos - _M_start;
    size_type __length = size();
    if (__elemsbefore < __length / 2) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    iterator __old_start = _M_start;
    __pos = _M_start + __elemsbefore;
    __STL_TRY {
    if (__elemsbefore >= difference_type(__n)) {
    iterator __start_n = _M_start + difference_type(__n);
    uninitialized_copy(_M_start, __start_n, __new_start);
    _M_start = __new_start;
    copy(__start_n, __pos, __old_start);
    copy(__first, __last, __pos - difference_type(__n));
    }
    else {
    const value_type* __mid =
    __first + (difference_type(__n) - __elemsbefore);
    __uninitialized_copy_copy(_M_start, __pos, __first, __mid,
    __new_start);
    _M_start = __new_start;
    copy(__mid, __last, __old_start);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    iterator __old_finish = _M_finish;
    const difference_type __elemsafter =
    difference_type(__length) - __elemsbefore;
    __pos = _M_finish - __elemsafter;
    __STL_TRY {
    if (__elemsafter > difference_type(__n)) {
    iterator __finish_n = _M_finish - difference_type(__n);
    uninitialized_copy(__finish_n, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy_backward(__pos, __finish_n, __old_finish);
    copy(__first, __last, __pos);
    }
    else {
    const value_type* __mid = __first + __elemsafter;
    __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy(__first, __mid, __pos);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
    const_iterator __first,
    const_iterator __last,
    size_type __n)
    {
    const difference_type __elemsbefore = __pos - _M_start;
    size_type __length = size();
    if (__elemsbefore < __length / 2) {
    iterator __new_start = _M_reserve_elements_at_front(__n);
    iterator __old_start = _M_start;
    __pos = _M_start + __elemsbefore;
    __STL_TRY {
    if (__elemsbefore >= __n) {
    iterator __start_n = _M_start + __n;
    uninitialized_copy(_M_start, __start_n, __new_start);
    _M_start = __new_start;
    copy(__start_n, __pos, __old_start);
    copy(__first, __last, __pos - difference_type(__n));
    }
    else {
    const_iterator __mid = __first + (__n - __elemsbefore);
    __uninitialized_copy_copy(_M_start, __pos, __first, __mid,
    __new_start);
    _M_start = __new_start;
    copy(__mid, __last, __old_start);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
    }
    else {
    iterator __new_finish = _M_reserve_elements_at_back(__n);
    iterator __old_finish = _M_finish;
    const difference_type __elemsafter = __length - __elemsbefore;
    __pos = _M_finish - __elemsafter;
    __STL_TRY {
    if (__elemsafter > __n) {
    iterator __finish_n = _M_finish - difference_type(__n);
    uninitialized_copy(__finish_n, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy_backward(__pos, __finish_n, __old_finish);
    copy(__first, __last, __pos);
    }
    else {
    const_iterator __mid = __first + __elemsafter;
    __uninitialized_copy_copy(__mid, __last, __pos, _M_finish, _M_finish);
    _M_finish = __new_finish;
    copy(__first, __mid, __pos);
    }
    }
    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1,
    __new_finish._M_node + 1));
    }
    }

    #endif /* __STL_MEMBER_TEMPLATES */

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_t ype __new_elems)
    {
    size_type __new_nodes
    = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
    _M_reserve_map_at_front(__new_nodes);
    size_type __i;
    __STL_TRY {
    for (__i = 1; __i <= __new_nodes; ++__i)
    *(_M_start._M_node - __i) = _M_allocate_node();
    }
    # ifdef __STL_USE_EXCEPTIONS
    catch(...) {
    for (size_type __j = 1; __j < __i; ++__j)
    _M_deallocate_node(*(_M_start._M_node - __j));
    throw;
    }
    # endif /* __STL_USE_EXCEPTIONS */
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_ty pe __new_elems)
    {
    size_type __new_nodes
    = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
    _M_reserve_map_at_back(__new_nodes);
    size_type __i;
    __STL_TRY {
    for (__i = 1; __i <= __new_nodes; ++__i)
    *(_M_finish._M_node + __i) = _M_allocate_node();
    }
    # ifdef __STL_USE_EXCEPTIONS
    catch(...) {
    for (size_type __j = 1; __j < __i; ++__j)
    _M_deallocate_node(*(_M_finish._M_node + __j));
    throw;
    }
    # endif /* __STL_USE_EXCEPTIONS */
    }

    template <class _Tp, class _Alloc>
    void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
    bool __add_at_front)
    {
    size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1;
    size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;

    _Map_pointer __new_nstart;
    if (_M_map_size > 2 * __new_num_nodes) {
    __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2
    + (__add_at_front ? __nodes_to_add : 0);
    if (__new_nstart < _M_start._M_node)
    copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
    else
    copy_backward(_M_start._M_node, _M_finish._M_node + 1,
    __new_nstart + __old_num_nodes);
    }
    else {
    size_type __new_map_size =
    _M_map_size + max(_M_map_size, __nodes_to_add) + 2;

    _Map_pointer __new_map = _M_allocate_map(__new_map_size);
    __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
    + (__add_at_front ? __nodes_to_add : 0);
    copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart);
    _M_deallocate_map(_M_map, _M_map_size);

    _M_map = __new_map;
    _M_map_size = __new_map_size;
    }

    _M_start._M_set_node(__new_nstart);
    _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
    }


    // Nonmember functions.

    template <class _Tp, class _Alloc>
    inline bool operator==(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return __x.size() == __y.size() &&
    equal(__x.begin(), __x.end(), __y.begin());
    }

    template <class _Tp, class _Alloc>
    inline bool operator<(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return lexicographical_compare(__x.begin(), __x.end(),
    __y.begin(), __y.end());
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Tp, class _Alloc>
    inline bool operator!=(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return !(__x == __y);
    }

    template <class _Tp, class _Alloc>
    inline bool operator>(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return __y < __x;
    }

    template <class _Tp, class _Alloc>
    inline bool operator<=(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return !(__y < __x);
    }
    template <class _Tp, class _Alloc>
    inline bool operator>=(const deque<_Tp, _Alloc>& __x,
    const deque<_Tp, _Alloc>& __y) {
    return !(__x < __y);
    }

    template <class _Tp, class _Alloc>
    inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) {
    __x.swap(__y);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma reset woff 1174
    #pragma reset woff 1375
    #endif

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_DEQUE_H */

    // Local Variables:
    // mode:C++
    // End:

  10. #85
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1998
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    #ifndef __SGI_STL_EXCEPTION_H
    #define __SGI_STL_EXCEPTION_H

    // This header exists solely for portability. Normally it just includes
    // the header <exception>.

    // The header <exception> contains low-level functions that interact
    // with a compiler's exception-handling mechanism. It is assumed to
    // be supplied with the compiler, rather than with the library, because
    // it is inherently tied very closely to the compiler itself.

    // On platforms where <exception> does not exist, this header defines
    // an exception base class. This is *not* a subs ute for everything
    // in <exception>, but it suffices to support a bare minimum of STL
    // functionality.

    #include <stl_config.h>

    #ifndef __STL_NO_EXCEPTION_HEADER

    #include <exception>
    #define __STL_EXCEPTION_BASE exception

    #else /* __STL_NO_EXCEPTION_HEADER */

    __STL_BEGIN_NAMESPACE

    class _Exception {
    public:
    virtual ~_Exception() __STL_NOTHROW {}
    virtual const char* what() const __STL_NOTHROW { return ""; }
    };

    #define __STL_EXCEPTION_BASE _Exception

    __STL_END_NAMESPACE

    #endif /* __STL_NO_EXCEPTION_HEADER */

    #endif /* __SGI_STL_EXCEPTION_H */

    // Local Variables:
    // mode:C++
    // End:

  11. #86
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1996-1998
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_FUNCTION_H
    #define __SGI_STL_INTERNAL_FUNCTION_H

    __STL_BEGIN_NAMESPACE

    template <class _Arg, class _Result>
    struct unary_function {
    typedef _Arg argument_type;
    typedef _Result result_type;
    };

    template <class _Arg1, class _Arg2, class _Result>
    struct binary_function {
    typedef _Arg1 first_argument_type;
    typedef _Arg2 second_argument_type;
    typedef _Result result_type;
    };

    template <class _Tp>
    struct plus : public binary_function<_Tp,_Tp,_Tp> {
    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
    };

    template <class _Tp>
    struct minus : public binary_function<_Tp,_Tp,_Tp> {
    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
    };

    template <class _Tp>
    struct multiplies : public binary_function<_Tp,_Tp,_Tp> {
    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
    };

    template <class _Tp>
    struct divides : public binary_function<_Tp,_Tp,_Tp> {
    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
    };

    // iden y_element (not part of the C++ standard).

    template <class _Tp> inline _Tp iden y_element(plus<_Tp>) {
    return _Tp(0);
    }
    template <class _Tp> inline _Tp iden y_element(multiplies<_Tp>) {
    return _Tp(1);
    }

    template <class _Tp>
    struct modulus : public binary_function<_Tp,_Tp,_Tp>
    {
    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
    };

    template <class _Tp>
    struct negate : public unary_function<_Tp,_Tp>
    {
    _Tp operator()(const _Tp& __x) const { return -__x; }
    };

    template <class _Tp>
    struct equal_to : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
    };

    template <class _Tp>
    struct not_equal_to : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
    };

    template <class _Tp>
    struct greater : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
    };

    template <class _Tp>
    struct less : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
    };

    template <class _Tp>
    struct greater_equal : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
    };

    template <class _Tp>
    struct less_equal : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
    };

    template <class _Tp>
    struct logical_and : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
    };

    template <class _Tp>
    struct logical_or : public binary_function<_Tp,_Tp,bool>
    {
    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
    };

    template <class _Tp>
    struct logical_not : public unary_function<_Tp,bool>
    {
    bool operator()(const _Tp& __x) const { return !__x; }
    };

    template <class _Predicate>
    class unary_negate
    : public unary_function<typename _Predicate::argument_type, bool> {
    protected:
    _Predicate _M_pred;
    public:
    explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {}
    bool operator()(const typename _Predicate::argument_type& __x) const {
    return !_M_pred(__x);
    }
    };

    template <class _Predicate>
    inline unary_negate<_Predicate>
    not1(const _Predicate& __pred)
    {
    return unary_negate<_Predicate>(__pred);
    }

    template <class _Predicate>
    class binary_negate
    : public binary_function<typename _Predicate::first_argument_type,
    typename _Predicate::second_argument_type,
    bool> {
    protected:
    _Predicate _M_pred;
    public:
    explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {}
    bool operator()(const typename _Predicate::first_argument_type& __x,
    const typename _Predicate::second_argument_type& __y) const
    {
    return !_M_pred(__x, __y);
    }
    };

    template <class _Predicate>
    inline binary_negate<_Predicate>
    not2(const _Predicate& __pred)
    {
    return binary_negate<_Predicate>(__pred);
    }

    template <class _Operation>
    class binder1st
    : public unary_function<typename _Operation::second_argument_type,
    typename _Operation::result_type> {
    protected:
    _Operation op;
    typename _Operation::first_argument_type value;
    public:
    binder1st(const _Operation& __x,
    const typename _Operation::first_argument_type& __y)
    : op(__x), value(__y) {}
    typename _Operation::result_type
    operator()(const typename _Operation::second_argument_type& __x) const {
    return op(value, __x);
    }
    };

    template <class _Operation, class _Tp>
    inline binder1st<_Operation>
    bind1st(const _Operation& __fn, const _Tp& __x)
    {
    typedef typename _Operation::first_argument_type _Arg1_type;
    return binder1st<_Operation>(__fn, _Arg1_type(__x));
    }

    template <class _Operation>
    class binder2nd
    : public unary_function<typename _Operation::first_argument_type,
    typename _Operation::result_type> {
    protected:
    _Operation op;
    typename _Operation::second_argument_type value;
    public:
    binder2nd(const _Operation& __x,
    const typename _Operation::second_argument_type& __y)
    : op(__x), value(__y) {}
    typename _Operation::result_type
    operator()(const typename _Operation::first_argument_type& __x) const {
    return op(__x, value);
    }
    };

    template <class _Operation, class _Tp>
    inline binder2nd<_Operation>
    bind2nd(const _Operation& __fn, const _Tp& __x)
    {
    typedef typename _Operation::second_argument_type _Arg2_type;
    return binder2nd<_Operation>(__fn, _Arg2_type(__x));
    }

    // unary_compose and binary_compose (extensions, not part of the standard).

    template <class _Operation1, class _Operation2>
    class unary_compose
    : public unary_function<typename _Operation2::argument_type,
    typename _Operation1::result_type>
    {
    protected:
    _Operation1 _M_fn1;
    _Operation2 _M_fn2;
    public:
    unary_compose(const _Operation1& __x, const _Operation2& __y)
    : _M_fn1(__x), _M_fn2(__y) {}
    typename _Operation1::result_type
    operator()(const typename _Operation2::argument_type& __x) const {
    return _M_fn1(_M_fn2(__x));
    }
    };

    template <class _Operation1, class _Operation2>
    inline unary_compose<_Operation1,_Operation2>
    compose1(const _Operation1& __fn1, const _Operation2& __fn2)
    {
    return unary_compose<_Operation1,_Operation2>(__fn1, __fn2);
    }

    template <class _Operation1, class _Operation2, class _Operation3>
    class binary_compose
    : public unary_function<typename _Operation2::argument_type,
    typename _Operation1::result_type> {
    protected:
    _Operation1 _M_fn1;
    _Operation2 _M_fn2;
    _Operation3 _M_fn3;
    public:
    binary_compose(const _Operation1& __x, const _Operation2& __y,
    const _Operation3& __z)
    : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
    typename _Operation1::result_type
    operator()(const typename _Operation2::argument_type& __x) const {
    return _M_fn1(_M_fn2(__x), _M_fn3(__x));
    }
    };

    template <class _Operation1, class _Operation2, class _Operation3>
    inline binary_compose<_Operation1, _Operation2, _Operation3>
    compose2(const _Operation1& __fn1, const _Operation2& __fn2,
    const _Operation3& __fn3)
    {
    return binary_compose<_Operation1,_Operation2,_Operation3 >
    (__fn1, __fn2, __fn3);
    }

    template <class _Arg, class _Result>
    class pointer_to_unary_function : public unary_function<_Arg, _Result> {
    protected:
    _Result (*_M_ptr)(_Arg);
    public:
    pointer_to_unary_function() {}
    explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}
    _Result operator()(_Arg __x) const { return _M_ptr(__x); }
    };

    template <class _Arg, class _Result>
    inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg))
    {
    return pointer_to_unary_function<_Arg, _Result>(__x);
    }

    template <class _Arg1, class _Arg2, class _Result>
    class pointer_to_binary_function :
    public binary_function<_Arg1,_Arg2,_Result> {
    protected:
    _Result (*_M_ptr)(_Arg1, _Arg2);
    public:
    pointer_to_binary_function() {}
    explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
    : _M_ptr(__x) {}
    _Result operator()(_Arg1 __x, _Arg2 __y) const {
    return _M_ptr(__x, __y);
    }
    };

    template <class _Arg1, class _Arg2, class _Result>
    inline pointer_to_binary_function<_Arg1,_Arg2,_Result>
    ptr_fun(_Result (*__x)(_Arg1, _Arg2)) {
    return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__ x);
    }

    // iden y is an extensions: it is not part of the standard.
    template <class _Tp>
    struct _Iden y : public unary_function<_Tp,_Tp> {
    const _Tp& operator()(const _Tp& __x) const { return __x; }
    };

    template <class _Tp> struct iden y : public _Iden y<_Tp> {};

    // select1st and select2nd are extensions: they are not part of the standard.
    template <class _Pair>
    struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
    const typename _Pair::first_type& operator()(const _Pair& __x) const {
    return __x.first;
    }
    };

    template <class _Pair>
    struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>
    {
    const typename _Pair::second_type& operator()(const _Pair& __x) const {
    return __x.second;
    }
    };

    template <class _Pair> struct select1st : public _Select1st<_Pair> {};
    template <class _Pair> struct select2nd : public _Select2nd<_Pair> {};

    // project1st and project2nd are extensions: they are not part of the standard
    template <class _Arg1, class _Arg2>
    struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
    _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
    };

    template <class _Arg1, class _Arg2>
    struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
    _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
    };

    template <class _Arg1, class _Arg2>
    struct project1st : public _Project1st<_Arg1, _Arg2> {};

    template <class _Arg1, class _Arg2>
    struct project2nd : public _Project2nd<_Arg1, _Arg2> {};

    // constant_void_fun, constant_unary_fun, and constant_binary_fun are
    // extensions: they are not part of the standard. (The same, of course,
    // is true of the helper functions constant0, constant1, and constant2.)

    template <class _Result>
    struct _Constant_void_fun {
    typedef _Result result_type;
    result_type _M_val;

    _Constant_void_fun(const result_type& __v) : _M_val(__v) {}
    const result_type& operator()() const { return _M_val; }
    };

  12. #87
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    template <class _Result, class _Argument>
    struct _Constant_unary_fun {
    typedef _Argument argument_type;
    typedef _Result result_type;
    result_type _M_val;

    _Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
    const result_type& operator()(const _Argument&) const { return _M_val; }
    };

    template <class _Result, class _Arg1, class _Arg2>
    struct _Constant_binary_fun {
    typedef _Arg1 first_argument_type;
    typedef _Arg2 second_argument_type;
    typedef _Result result_type;
    _Result _M_val;

    _Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
    const result_type& operator()(const _Arg1&, const _Arg2&) const {
    return _M_val;
    }
    };

    template <class _Result>
    struct constant_void_fun : public _Constant_void_fun<_Result> {
    constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {}
    };


    template <class _Result,
    class _Argument __STL_DEPENDENT_DEFAULT_TMPL(_Result)>
    struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument>
    {
    constant_unary_fun(const _Result& __v)
    : _Constant_unary_fun<_Result, _Argument>(__v) {}
    };


    template <class _Result,
    class _Arg1 __STL_DEPENDENT_DEFAULT_TMPL(_Result),
    class _Arg2 __STL_DEPENDENT_DEFAULT_TMPL(_Arg1)>
    struct constant_binary_fun
    : public _Constant_binary_fun<_Result, _Arg1, _Arg2>
    {
    constant_binary_fun(const _Result& __v)
    : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
    };

    template <class _Result>
    inline constant_void_fun<_Result> constant0(const _Result& __val)
    {
    return constant_void_fun<_Result>(__val);
    }

    template <class _Result>
    inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val)
    {
    return constant_unary_fun<_Result,_Result>(__val);
    }

    template <class _Result>
    inline constant_binary_fun<_Result,_Result,_Result>
    constant2(const _Result& __val)
    {
    return constant_binary_fun<_Result,_Result,_Result>(__val );
    }

    // subtractive_rng is an extension: it is not part of the standard.
    // Note: this code assumes that int is 32 bits.
    class subtractive_rng : public unary_function<unsigned int, unsigned int> {
    private:
    unsigned int _M_table[55];
    size_t _M_index1;
    size_t _M_index2;
    public:
    unsigned int operator()(unsigned int __limit) {
    _M_index1 = (_M_index1 + 1) % 55;
    _M_index2 = (_M_index2 + 1) % 55;
    _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
    return _M_table[_M_index1] % __limit;
    }

    void _M_initialize(unsigned int __seed)
    {
    unsigned int __k = 1;
    _M_table[54] = __seed;
    size_t __i;
    for (__i = 0; __i < 54; __i++) {
    size_t __ii = (21 * (__i + 1) % 55) - 1;
    _M_table[__ii] = __k;
    __k = __seed - __k;
    __seed = _M_table[__ii];
    }
    for (int __loop = 0; __loop < 4; __loop++) {
    for (__i = 0; __i < 55; __i++)
    _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
    }
    _M_index1 = 0;
    _M_index2 = 31;
    }

    subtractive_rng(unsigned int __seed) { _M_initialize(__seed); }
    subtractive_rng() { _M_initialize(161803398u); }
    };


    // Adaptor function objects: pointers to member functions.

    // There are a total of 16 = 2^4 function objects in this family.
    // (1) Member functions taking no arguments vs member functions taking
    // one argument.
    // (2) Call through pointer vs call through reference.
    // (3) Member function with void return type vs member function with
    // non-void return type.
    // (4) Const vs non-const member function.

    // Note that choice (3) is nothing more than a workaround: according
    // to the draft, compilers should handle void and non-void the same way.
    // This feature is not yet widely implemented, though. You can only use
    // member functions returning void if your compiler supports partial
    // specialization.

    // All of this complexity is in the function objects themselves. You can
    // ignore it by using the helper function mem_fun and mem_fun_ref,
    // which create whichever type of adaptor is appropriate.
    // (mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,
    // but they are provided for backward compatibility.)


    template <class _Ret, class _Tp>
    class mem_fun_t : public unary_function<_Tp*,_Ret> {
    public:
    explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}
    _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
    private:
    _Ret (_Tp::*_M_f)();
    };

    template <class _Ret, class _Tp>
    class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
    public:
    explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
    _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
    private:
    _Ret (_Tp::*_M_f)() const;
    };


    template <class _Ret, class _Tp>
    class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
    public:
    explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) {}
    _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
    private:
    _Ret (_Tp::*_M_f)();
    };

    template <class _Ret, class _Tp>
    class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
    public:
    explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
    _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
    private:
    _Ret (_Tp::*_M_f)() const;
    };

    template <class _Ret, class _Tp, class _Arg>
    class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
    public:
    explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
    _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
    private:
    _Ret (_Tp::*_M_f)(_Arg);
    };

    template <class _Ret, class _Tp, class _Arg>
    class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
    public:
    explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
    _Ret operator()(const _Tp* __p, _Arg __x) const
    { return (__p->*_M_f)(__x); }
    private:
    _Ret (_Tp::*_M_f)(_Arg) const;
    };

    template <class _Ret, class _Tp, class _Arg>
    class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
    public:
    explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
    _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
    private:
    _Ret (_Tp::*_M_f)(_Arg);
    };

    template <class _Ret, class _Tp, class _Arg>
    class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
    public:
    explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
    _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
    private:
    _Ret (_Tp::*_M_f)(_Arg) const;
    };

    #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION

    template <class _Tp>
    class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
    public:
    explicit mem_fun_t(void (_Tp::*__pf)()) : _M_f(__pf) {}
    void operator()(_Tp* __p) const { (__p->*_M_f)(); }
    private:
    void (_Tp::*_M_f)();
    };

    template <class _Tp>
    class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
    public:
    explicit const_mem_fun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}
    void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
    private:
    void (_Tp::*_M_f)() const;
    };

    template <class _Tp>
    class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
    public:
    explicit mem_fun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {}
    void operator()(_Tp& __r) const { (__r.*_M_f)(); }
    private:
    void (_Tp::*_M_f)();
    };

    template <class _Tp>
    class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
    public:
    explicit const_mem_fun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {}
    void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
    private:
    void (_Tp::*_M_f)() const;
    };

    template <class _Tp, class _Arg>
    class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
    public:
    explicit mem_fun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
    void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
    private:
    void (_Tp::*_M_f)(_Arg);
    };

    template <class _Tp, class _Arg>
    class const_mem_fun1_t<void, _Tp, _Arg>
    : public binary_function<const _Tp*,_Arg,void> {
    public:
    explicit const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
    void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
    private:
    void (_Tp::*_M_f)(_Arg) const;
    };

    template <class _Tp, class _Arg>
    class mem_fun1_ref_t<void, _Tp, _Arg>
    : public binary_function<_Tp,_Arg,void> {
    public:
    explicit mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {}
    void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
    private:
    void (_Tp::*_M_f)(_Arg);
    };

    template <class _Tp, class _Arg>
    class const_mem_fun1_ref_t<void, _Tp, _Arg>
    : public binary_function<_Tp,_Arg,void> {
    public:
    explicit const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {}
    void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
    private:
    void (_Tp::*_M_f)(_Arg) const;
    };

    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    // Mem_fun adaptor helper functions. There are only two:
    // mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref
    // are provided for backward compatibility, but they are no longer
    // part of the C++ standard.)

    template <class _Ret, class _Tp>
    inline mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)())
    { return mem_fun_t<_Ret,_Tp>(__f); }

    template <class _Ret, class _Tp>
    inline const_mem_fun_t<_Ret,_Tp> mem_fun(_Ret (_Tp::*__f)() const)
    { return const_mem_fun_t<_Ret,_Tp>(__f); }

    template <class _Ret, class _Tp>
    inline mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)())
    { return mem_fun_ref_t<_Ret,_Tp>(__f); }

    template <class _Ret, class _Tp>
    inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
    { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg))
    { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const)
    { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
    { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>
    mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
    { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg))
    { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const)
    { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
    { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }

    template <class _Ret, class _Tp, class _Arg>
    inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg>
    mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
    { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); }

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_FUNCTION_H */

    // Local Variables:
    // mode:C++
    // End:

  13. #88
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1996-1998
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_HASH_FUN_H
    #define __SGI_STL_HASH_FUN_H

    #include <stddef.h>

    __STL_BEGIN_NAMESPACE

    template <class _Key> struct hash { };

    inline size_t __stl_hash_string(const char* __s)
    {
    unsigned long __h = 0;
    for ( ; *__s; ++__s)
    __h = 5*__h + *__s;

    return size_t(__h);
    }

    __STL_TEMPLATE_NULL struct hash<char*>
    {
    size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
    };

    __STL_TEMPLATE_NULL struct hash<const char*>
    {
    size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
    };

    __STL_TEMPLATE_NULL struct hash<char> {
    size_t operator()(char __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<unsigned char> {
    size_t operator()(unsigned char __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<signed char> {
    size_t operator()(unsigned char __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<short> {
    size_t operator()(short __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<unsigned short> {
    size_t operator()(unsigned short __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<int> {
    size_t operator()(int __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<unsigned int> {
    size_t operator()(unsigned int __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<long> {
    size_t operator()(long __x) const { return __x; }
    };
    __STL_TEMPLATE_NULL struct hash<unsigned long> {
    size_t operator()(unsigned long __x) const { return __x; }
    };

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_HASH_FUN_H */

    // Local Variables:
    // mode:C++
    // End:

  14. #89
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1996
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_HASH_MAP_H
    #define __SGI_STL_INTERNAL_HASH_MAP_H

    #include <concept_checks.h>

    __STL_BEGIN_NAMESPACE

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma set woff 1174
    #pragma set woff 1375
    #endif

    // Forward declaration of equality operator; needed for friend declaration.

    template <class _Key, class _Tp,
    class _HashFcn __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),
    class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),
    class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    class hash_map;

    template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
    inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
    const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);

    template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
    class _Alloc>
    class hash_map
    {
    // requirements:

    __STL_CLASS_REQUIRES(_Key, _Assignable);
    __STL_CLASS_REQUIRES(_Tp, _Assignable);
    __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
    __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);

    private:
    typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
    _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
    _Ht _M_ht;

    public:
    typedef typename _Ht::key_type key_type;
    typedef _Tp data_type;
    typedef _Tp mapped_type;
    typedef typename _Ht::value_type value_type;
    typedef typename _Ht::hasher hasher;
    typedef typename _Ht::key_equal key_equal;

    typedef typename _Ht::size_type size_type;
    typedef typename _Ht::difference_type difference_type;
    typedef typename _Ht::pointer pointer;
    typedef typename _Ht::const_pointer const_pointer;
    typedef typename _Ht::reference reference;
    typedef typename _Ht::const_reference const_reference;

    typedef typename _Ht::iterator iterator;
    typedef typename _Ht::const_iterator const_iterator;

    typedef typename _Ht::allocator_type allocator_type;

    hasher hash_funct() const { return _M_ht.hash_funct(); }
    key_equal key_eq() const { return _M_ht.key_eq(); }
    allocator_type get_allocator() const { return _M_ht.get_allocator(); }

    public:
    hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    explicit hash_map(size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    hash_map(size_type __n, const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a) {}

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    hash_map(_Inpu erator __f, _Inpu erator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_map(_Inpu erator __f, _Inpu erator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_map(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_map(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }

    #else
    hash_map(const value_type* __f, const value_type* __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const value_type* __f, const value_type* __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }

    hash_map(const_iterator __f, const_iterator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const_iterator __f, const_iterator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_map(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */

    public:
    size_type size() const { return _M_ht.size(); }
    size_type max_size() const { return _M_ht.max_size(); }
    bool empty() const { return _M_ht.empty(); }
    void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _K1, class _T1, class _HF, class _EqK, class _Al>
    friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
    const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
    #else /* __STL_MEMBER_TEMPLATES */
    friend bool __STD_QUALIFIER
    operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);
    #endif /* __STL_MEMBER_TEMPLATES */


    iterator begin() { return _M_ht.begin(); }
    iterator end() { return _M_ht.end(); }
    const_iterator begin() const { return _M_ht.begin(); }
    const_iterator end() const { return _M_ht.end(); }

    public:
    pair<iterator,bool> insert(const value_type& __obj)
    { return _M_ht.insert_unique(__obj); }
    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void insert(_Inpu erator __f, _Inpu erator __l)
    { _M_ht.insert_unique(__f,__l); }
    #else
    void insert(const value_type* __f, const value_type* __l) {
    _M_ht.insert_unique(__f,__l);
    }
    void insert(const_iterator __f, const_iterator __l)
    { _M_ht.insert_unique(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */
    pair<iterator,bool> insert_noresize(const value_type& __obj)
    { return _M_ht.insert_unique_noresize(__obj); }

    iterator find(const key_type& __key) { return _M_ht.find(__key); }
    const_iterator find(const key_type& __key) const
    { return _M_ht.find(__key); }

    _Tp& operator[](const key_type& __key) {
    return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
    }

    size_type count(const key_type& __key) const { return _M_ht.count(__key); }

    pair<iterator, iterator> equal_range(const key_type& __key)
    { return _M_ht.equal_range(__key); }
    pair<const_iterator, const_iterator>
    equal_range(const key_type& __key) const
    { return _M_ht.equal_range(__key); }

    size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    void erase(iterator __it) { _M_ht.erase(__it); }
    void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    void clear() { _M_ht.clear(); }

    void resize(size_type __hint) { _M_ht.resize(__hint); }
    size_type bucket_count() const { return _M_ht.bucket_count(); }
    size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    size_type elems_in_bucket(size_type __n) const
    { return _M_ht.elems_in_bucket(__n); }
    };

    template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    inline bool
    operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    {
    return __hm1._M_ht == __hm2._M_ht;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    inline bool
    operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
    return !(__hm1 == __hm2);
    }

    template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    inline void
    swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    {
    __hm1.swap(__hm2);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    // Forward declaration of equality operator; needed for friend declaration.

    template <class _Key, class _Tp,
    class _HashFcn __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),
    class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),
    class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    class hash_multimap;

    template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
    inline bool
    operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
    const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2);

    template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
    class _Alloc>
    class hash_multimap
    {
    // requirements:

    __STL_CLASS_REQUIRES(_Key, _Assignable);
    __STL_CLASS_REQUIRES(_Tp, _Assignable);
    __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
    __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);

    private:
    typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
    _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
    _Ht;
    _Ht _M_ht;

    public:
    typedef typename _Ht::key_type key_type;
    typedef _Tp data_type;
    typedef _Tp mapped_type;
    typedef typename _Ht::value_type value_type;
    typedef typename _Ht::hasher hasher;
    typedef typename _Ht::key_equal key_equal;

    typedef typename _Ht::size_type size_type;
    typedef typename _Ht::difference_type difference_type;
    typedef typename _Ht::pointer pointer;
    typedef typename _Ht::const_pointer const_pointer;
    typedef typename _Ht::reference reference;
    typedef typename _Ht::const_reference const_reference;

    typedef typename _Ht::iterator iterator;
    typedef typename _Ht::const_iterator const_iterator;

    typedef typename _Ht::allocator_type allocator_type;

    hasher hash_funct() const { return _M_ht.hash_funct(); }
    key_equal key_eq() const { return _M_ht.key_eq(); }
    allocator_type get_allocator() const { return _M_ht.get_allocator(); }

    public:
    hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    explicit hash_multimap(size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    hash_multimap(size_type __n, const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a) {}

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    hash_multimap(_Inpu erator __f, _Inpu erator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multimap(_Inpu erator __f, _Inpu erator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multimap(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multimap(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }

    #else
    hash_multimap(const value_type* __f, const value_type* __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }

    hash_multimap(const_iterator __f, const_iterator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */

    public:
    size_type size() const { return _M_ht.size(); }
    size_type max_size() const { return _M_ht.max_size(); }
    bool empty() const { return _M_ht.empty(); }
    void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _K1, class _T1, class _HF, class _EqK, class _Al>
    friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
    const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
    #else /* __STL_MEMBER_TEMPLATES */
    friend bool __STD_QUALIFIER
    operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,const hash_multimap&);
    #endif /* __STL_MEMBER_TEMPLATES */

    iterator begin() { return _M_ht.begin(); }
    iterator end() { return _M_ht.end(); }
    const_iterator begin() const { return _M_ht.begin(); }
    const_iterator end() const { return _M_ht.end(); }

    public:
    iterator insert(const value_type& __obj)
    { return _M_ht.insert_equal(__obj); }
    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void insert(_Inpu erator __f, _Inpu erator __l)
    { _M_ht.insert_equal(__f,__l); }
    #else
    void insert(const value_type* __f, const value_type* __l) {
    _M_ht.insert_equal(__f,__l);
    }
    void insert(const_iterator __f, const_iterator __l)
    { _M_ht.insert_equal(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */
    iterator insert_noresize(const value_type& __obj)
    { return _M_ht.insert_equal_noresize(__obj); }

    iterator find(const key_type& __key) { return _M_ht.find(__key); }
    const_iterator find(const key_type& __key) const
    { return _M_ht.find(__key); }

    size_type count(const key_type& __key) const { return _M_ht.count(__key); }

    pair<iterator, iterator> equal_range(const key_type& __key)
    { return _M_ht.equal_range(__key); }
    pair<const_iterator, const_iterator>
    equal_range(const key_type& __key) const
    { return _M_ht.equal_range(__key); }

    size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    void erase(iterator __it) { _M_ht.erase(__it); }
    void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    void clear() { _M_ht.clear(); }

    public:
    void resize(size_type __hint) { _M_ht.resize(__hint); }
    size_type bucket_count() const { return _M_ht.bucket_count(); }
    size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    size_type elems_in_bucket(size_type __n) const
    { return _M_ht.elems_in_bucket(__n); }
    };

    template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
    inline bool
    operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
    const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
    {
    return __hm1._M_ht == __hm2._M_ht;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
    inline bool
    operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
    const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {
    return !(__hm1 == __hm2);
    }

    template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    inline void
    swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Allo c>& __hm1,
    hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    {
    __hm1.swap(__hm2);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    // Specialization of insert_iterator so that it will work for hash_map
    // and hash_multimap.

    #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION

    template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
    class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
    protected:
    typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
    _Container* container;
    public:
    typedef _Container container_type;
    typedef output_iterator_tag iterator_category;
    typedef void value_type;
    typedef void difference_type;
    typedef void pointer;
    typedef void reference;

    insert_iterator(_Container& __x) : container(&__x) {}
    insert_iterator(_Container& __x, typename _Container::iterator)
    : container(&__x) {}
    insert_iterator<_Container>&
    operator=(const typename _Container::value_type& __value) {
    container->insert(__value);
    return *this;
    }
    insert_iterator<_Container>& operator*() { return *this; }
    insert_iterator<_Container>& operator++() { return *this; }
    insert_iterator<_Container>& operator++(int) { return *this; }
    };

    template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
    class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
    protected:
    typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
    _Container* container;
    typename _Container::iterator iter;
    public:
    typedef _Container container_type;
    typedef output_iterator_tag iterator_category;
    typedef void value_type;
    typedef void difference_type;
    typedef void pointer;
    typedef void reference;

    insert_iterator(_Container& __x) : container(&__x) {}
    insert_iterator(_Container& __x, typename _Container::iterator)
    : container(&__x) {}
    insert_iterator<_Container>&
    operator=(const typename _Container::value_type& __value) {
    container->insert(__value);
    return *this;
    }
    insert_iterator<_Container>& operator*() { return *this; }
    insert_iterator<_Container>& operator++() { return *this; }
    insert_iterator<_Container>& operator++(int) { return *this; }
    };

    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma reset woff 1174
    #pragma reset woff 1375
    #endif

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_HASH_MAP_H */

    // Local Variables:
    // mode:C++
    // End:

  15. #90
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1996
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_HASH_SET_H
    #define __SGI_STL_INTERNAL_HASH_SET_H

    #include <concept_checks.h>

    __STL_BEGIN_NAMESPACE

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma set woff 1174
    #pragma set woff 1375
    #endif

    // Forward declaration of equality operator; needed for friend declaration.

    template <class _Value,
    class _HashFcn __STL_DEPENDENT_DEFAULT_TMPL(hash<_Value>),
    class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>),
    class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
    class hash_set;

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2);

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    class hash_set
    {
    // requirements:

    __STL_CLASS_REQUIRES(_Value, _Assignable);
    __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);
    __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);

    private:
    typedef hashtable<_Value, _Value, _HashFcn, _Iden y<_Value>,
    _EqualKey, _Alloc> _Ht;
    _Ht _M_ht;

    public:
    typedef typename _Ht::key_type key_type;
    typedef typename _Ht::value_type value_type;
    typedef typename _Ht::hasher hasher;
    typedef typename _Ht::key_equal key_equal;

    typedef typename _Ht::size_type size_type;
    typedef typename _Ht::difference_type difference_type;
    typedef typename _Ht::const_pointer pointer;
    typedef typename _Ht::const_pointer const_pointer;
    typedef typename _Ht::const_reference reference;
    typedef typename _Ht::const_reference const_reference;

    typedef typename _Ht::const_iterator iterator;
    typedef typename _Ht::const_iterator const_iterator;

    typedef typename _Ht::allocator_type allocator_type;

    hasher hash_funct() const { return _M_ht.hash_funct(); }
    key_equal key_eq() const { return _M_ht.key_eq(); }
    allocator_type get_allocator() const { return _M_ht.get_allocator(); }

    public:
    hash_set()
    : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    explicit hash_set(size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    hash_set(size_type __n, const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a) {}

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    hash_set(_Inpu erator __f, _Inpu erator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_set(_Inpu erator __f, _Inpu erator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_set(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    template <class _Inpu erator>
    hash_set(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }
    #else

    hash_set(const value_type* __f, const value_type* __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const value_type* __f, const value_type* __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }

    hash_set(const_iterator __f, const_iterator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const_iterator __f, const_iterator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_unique(__f, __l); }
    hash_set(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_unique(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */

    public:
    size_type size() const { return _M_ht.size(); }
    size_type max_size() const { return _M_ht.max_size(); }
    bool empty() const { return _M_ht.empty(); }
    void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Val, class _HF, class _EqK, class _Al>
    friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&,
    const hash_set<_Val, _HF, _EqK, _Al>&);
    #else /* __STL_MEMBER_TEMPLATES */
    friend bool __STD_QUALIFIER
    operator== __STL_NULL_TMPL_ARGS (const hash_set&, const hash_set&);
    #endif /* __STL_MEMBER_TEMPLATES */

    iterator begin() const { return _M_ht.begin(); }
    iterator end() const { return _M_ht.end(); }

    public:
    pair<iterator, bool> insert(const value_type& __obj)
    {
    pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);
    return pair<iterator,bool>(__p.first, __p.second);
    }
    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void insert(_Inpu erator __f, _Inpu erator __l)
    { _M_ht.insert_unique(__f,__l); }
    #else
    void insert(const value_type* __f, const value_type* __l) {
    _M_ht.insert_unique(__f,__l);
    }
    void insert(const_iterator __f, const_iterator __l)
    {_M_ht.insert_unique(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */
    pair<iterator, bool> insert_noresize(const value_type& __obj)
    {
    pair<typename _Ht::iterator, bool> __p =
    _M_ht.insert_unique_noresize(__obj);
    return pair<iterator, bool>(__p.first, __p.second);
    }

    iterator find(const key_type& __key) const { return _M_ht.find(__key); }

    size_type count(const key_type& __key) const { return _M_ht.count(__key); }

    pair<iterator, iterator> equal_range(const key_type& __key) const
    { return _M_ht.equal_range(__key); }

    size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    void erase(iterator __it) { _M_ht.erase(__it); }
    void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    void clear() { _M_ht.clear(); }

    public:
    void resize(size_type __hint) { _M_ht.resize(__hint); }
    size_type bucket_count() const { return _M_ht.bucket_count(); }
    size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    size_type elems_in_bucket(size_type __n) const
    { return _M_ht.elems_in_bucket(__n); }
    };

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2)
    {
    return __hs1._M_ht == __hs2._M_ht;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) {
    return !(__hs1 == __hs2);
    }

    template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
    inline void
    swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
    hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
    {
    __hs1.swap(__hs2);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */


    template <class _Value,
    class _HashFcn __STL_DEPENDENT_DEFAULT_TMPL(hash<_Value>),
    class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Value>),
    class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
    class hash_multiset;

    template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2);


    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    class hash_multiset
    {
    // requirements:

    __STL_CLASS_REQUIRES(_Value, _Assignable);
    __STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);
    __STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);

    private:
    typedef hashtable<_Value, _Value, _HashFcn, _Iden y<_Value>,
    _EqualKey, _Alloc> _Ht;
    _Ht _M_ht;

    public:
    typedef typename _Ht::key_type key_type;
    typedef typename _Ht::value_type value_type;
    typedef typename _Ht::hasher hasher;
    typedef typename _Ht::key_equal key_equal;

    typedef typename _Ht::size_type size_type;
    typedef typename _Ht::difference_type difference_type;
    typedef typename _Ht::const_pointer pointer;
    typedef typename _Ht::const_pointer const_pointer;
    typedef typename _Ht::const_reference reference;
    typedef typename _Ht::const_reference const_reference;

    typedef typename _Ht::const_iterator iterator;
    typedef typename _Ht::const_iterator const_iterator;

    typedef typename _Ht::allocator_type allocator_type;

    hasher hash_funct() const { return _M_ht.hash_funct(); }
    key_equal key_eq() const { return _M_ht.key_eq(); }
    allocator_type get_allocator() const { return _M_ht.get_allocator(); }

    public:
    hash_multiset()
    : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    explicit hash_multiset(size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    hash_multiset(size_type __n, const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a) {}

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    hash_multiset(_Inpu erator __f, _Inpu erator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multiset(_Inpu erator __f, _Inpu erator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multiset(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    template <class _Inpu erator>
    hash_multiset(_Inpu erator __f, _Inpu erator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }
    #else

    hash_multiset(const value_type* __f, const value_type* __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const value_type* __f, const value_type* __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }

    hash_multiset(const_iterator __f, const_iterator __l)
    : _M_ht(100, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const_iterator __f, const_iterator __l, size_type __n)
    : _M_ht(__n, hasher(), key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf)
    : _M_ht(__n, __hf, key_equal(), allocator_type())
    { _M_ht.insert_equal(__f, __l); }
    hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
    const hasher& __hf, const key_equal& __eql,
    const allocator_type& __a = allocator_type())
    : _M_ht(__n, __hf, __eql, __a)
    { _M_ht.insert_equal(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */

    public:
    size_type size() const { return _M_ht.size(); }
    size_type max_size() const { return _M_ht.max_size(); }
    bool empty() const { return _M_ht.empty(); }
    void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Val, class _HF, class _EqK, class _Al>
    friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&,
    const hash_multiset<_Val, _HF, _EqK, _Al>&);
    #else /* __STL_MEMBER_TEMPLATES */
    friend bool __STD_QUALIFIER
    operator== __STL_NULL_TMPL_ARGS (const hash_multiset&,const hash_multiset&);
    #endif /* __STL_MEMBER_TEMPLATES */

    iterator begin() const { return _M_ht.begin(); }
    iterator end() const { return _M_ht.end(); }

    public:
    iterator insert(const value_type& __obj)
    { return _M_ht.insert_equal(__obj); }
    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void insert(_Inpu erator __f, _Inpu erator __l)
    { _M_ht.insert_equal(__f,__l); }
    #else
    void insert(const value_type* __f, const value_type* __l) {
    _M_ht.insert_equal(__f,__l);
    }
    void insert(const_iterator __f, const_iterator __l)
    { _M_ht.insert_equal(__f, __l); }
    #endif /*__STL_MEMBER_TEMPLATES */
    iterator insert_noresize(const value_type& __obj)
    { return _M_ht.insert_equal_noresize(__obj); }

    iterator find(const key_type& __key) const { return _M_ht.find(__key); }

    size_type count(const key_type& __key) const { return _M_ht.count(__key); }

    pair<iterator, iterator> equal_range(const key_type& __key) const
    { return _M_ht.equal_range(__key); }

    size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    void erase(iterator __it) { _M_ht.erase(__it); }
    void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    void clear() { _M_ht.clear(); }

    public:
    void resize(size_type __hint) { _M_ht.resize(__hint); }
    size_type bucket_count() const { return _M_ht.bucket_count(); }
    size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    size_type elems_in_bucket(size_type __n) const
    { return _M_ht.elems_in_bucket(__n); }
    };

    template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
    {
    return __hs1._M_ht == __hs2._M_ht;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
    inline bool
    operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
    const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
    return !(__hs1 == __hs2);
    }

    template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
    inline void
    swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc> & __hs1,
    hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
    __hs1.swap(__hs2);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

    // Specialization of insert_iterator so that it will work for hash_set
    // and hash_multiset.

    #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    class insert_iterator<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > {
    protected:
    typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
    _Container* container;
    public:
    typedef _Container container_type;
    typedef output_iterator_tag iterator_category;
    typedef void value_type;
    typedef void difference_type;
    typedef void pointer;
    typedef void reference;

    insert_iterator(_Container& __x) : container(&__x) {}
    insert_iterator(_Container& __x, typename _Container::iterator)
    : container(&__x) {}
    insert_iterator<_Container>&
    operator=(const typename _Container::value_type& __value) {
    container->insert(__value);
    return *this;
    }
    insert_iterator<_Container>& operator*() { return *this; }
    insert_iterator<_Container>& operator++() { return *this; }
    insert_iterator<_Container>& operator++(int) { return *this; }
    };

    template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
    class insert_iterator<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > {
    protected:
    typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
    _Container* container;
    typename _Container::iterator iter;
    public:
    typedef _Container container_type;
    typedef output_iterator_tag iterator_category;
    typedef void value_type;
    typedef void difference_type;
    typedef void pointer;
    typedef void reference;

    insert_iterator(_Container& __x) : container(&__x) {}
    insert_iterator(_Container& __x, typename _Container::iterator)
    : container(&__x) {}
    insert_iterator<_Container>&
    operator=(const typename _Container::value_type& __value) {
    container->insert(__value);
    return *this;
    }
    insert_iterator<_Container>& operator*() { return *this; }
    insert_iterator<_Container>& operator++() { return *this; }
    insert_iterator<_Container>& operator++(int) { return *this; }
    };

    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    #pragma reset woff 1174
    #pragma reset woff 1375
    #endif

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_HASH_SET_H */

    // Local Variables:
    // mode:C++
    // End:

  16. #91
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    /*
    * Copyright (c) 1996,1997
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    *
    * Copyright (c) 1994
    * Hewlett-Packard Company
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Hewlett-Packard Company makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    *
    */

    /* NOTE: This is an internal header file, included by other STL headers.
    * You should not attempt to use it directly.
    */

    #ifndef __SGI_STL_INTERNAL_HASHTABLE_H
    #define __SGI_STL_INTERNAL_HASHTABLE_H

    // Hashtable class, used to implement the hashed associative containers
    // hash_set, hash_map, hash_multiset, and hash_multimap.

    #include <stl_algobase.h>
    #include <stl_alloc.h>
    #include <stl_construct.h>
    #include <stl_tempbuf.h>
    #include <stl_algo.h>
    #include <stl_uninitialized.h>
    #include <stl_function.h>
    #include <stl_vector.h>
    #include <stl_hash_fun.h>

    __STL_BEGIN_NAMESPACE

    template <class _Val>
    struct _Hashtable_node
    {
    _Hashtable_node* _M_next;
    _Val _M_val;
    };

    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc = alloc>
    class hashtable;

    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc>
    struct _Hashtable_iterator;

    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc>
    struct _Hashtable_const_iterator;

    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc>
    struct _Hashtable_iterator {
    typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey ,_Alloc>
    _Hashtable;
    typedef _Hashtable_iterator<_Val, _Key, _HashFcn,
    _ExtractKey, _EqualKey, _Alloc>
    iterator;
    typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn,
    _ExtractKey, _EqualKey, _Alloc>
    const_iterator;
    typedef _Hashtable_node<_Val> _Node;

    typedef forward_iterator_tag iterator_category;
    typedef _Val value_type;
    typedef ptrdiff_t difference_type;
    typedef size_t size_type;
    typedef _Val& reference;
    typedef _Val* pointer;

    _Node* _M_cur;
    _Hashtable* _M_ht;

    _Hashtable_iterator(_Node* __n, _Hashtable* __tab)
    : _M_cur(__n), _M_ht(__tab) {}
    _Hashtable_iterator() {}
    reference operator*() const { return _M_cur->_M_val; }
    #ifndef __SGI_STL_NO_ARROW_OPERATOR
    pointer operator->() const { return &(operator*()); }
    #endif /* __SGI_STL_NO_ARROW_OPERATOR */
    iterator& operator++();
    iterator operator++(int);
    bool operator==(const iterator& __it) const
    { return _M_cur == __it._M_cur; }
    bool operator!=(const iterator& __it) const
    { return _M_cur != __it._M_cur; }
    };


    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc>
    struct _Hashtable_const_iterator {
    typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey ,_Alloc>
    _Hashtable;
    typedef _Hashtable_iterator<_Val,_Key,_HashFcn,
    _ExtractKey,_EqualKey,_Alloc>
    iterator;
    typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn,
    _ExtractKey, _EqualKey, _Alloc>
    const_iterator;
    typedef _Hashtable_node<_Val> _Node;

    typedef forward_iterator_tag iterator_category;
    typedef _Val value_type;
    typedef ptrdiff_t difference_type;
    typedef size_t size_type;
    typedef const _Val& reference;
    typedef const _Val* pointer;

    const _Node* _M_cur;
    const _Hashtable* _M_ht;

    _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab)
    : _M_cur(__n), _M_ht(__tab) {}
    _Hashtable_const_iterator() {}
    _Hashtable_const_iterator(const iterator& __it)
    : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {}
    reference operator*() const { return _M_cur->_M_val; }
    #ifndef __SGI_STL_NO_ARROW_OPERATOR
    pointer operator->() const { return &(operator*()); }
    #endif /* __SGI_STL_NO_ARROW_OPERATOR */
    const_iterator& operator++();
    const_iterator operator++(int);
    bool operator==(const const_iterator& __it) const
    { return _M_cur == __it._M_cur; }
    bool operator!=(const const_iterator& __it) const
    { return _M_cur != __it._M_cur; }
    };

    // Note: assumes long is at least 32 bits.
    enum { __stl_num_primes = 28 };

    static const unsigned long __stl_prime_list[__stl_num_primes] =
    {
    53ul, 97ul, 193ul, 389ul, 769ul,
    1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
    49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
    1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
    50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
    1610612741ul, 3221225473ul, 4294967291ul
    };

    inline unsigned long __stl_next_prime(unsigned long __n)
    {
    const unsigned long* __first = __stl_prime_list;
    const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes;
    const unsigned long* pos = lower_bound(__first, __last, __n);
    return pos == __last ? *(__last - 1) : *pos;
    }

    // Forward declaration of operator==.

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    class hashtable;

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,
    const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2);


    // Hashtables handle allocators a bit differently than other containers
    // do. If we're using standard-conforming allocators, then a hashtable
    // unconditionally has a member variable to hold its allocator, even if
    // it so happens that all instances of the allocator type are identical.
    // This is because, for hashtables, this extra storage is negligible.
    // Additionally, a base class wouldn't serve any other purposes; it
    // wouldn't, for example, simplify the exception-handling code.

    template <class _Val, class _Key, class _HashFcn,
    class _ExtractKey, class _EqualKey, class _Alloc>
    class hashtable {
    public:
    typedef _Key key_type;
    typedef _Val value_type;
    typedef _HashFcn hasher;
    typedef _EqualKey key_equal;

    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef value_type& reference;
    typedef const value_type& const_reference;

    hasher hash_funct() const { return _M_hash; }
    key_equal key_eq() const { return _M_equals; }

    private:
    typedef _Hashtable_node<_Val> _Node;

    #ifdef __STL_USE_STD_ALLOCATORS
    public:
    typedef typename _Alloc_traits<_Val,_Alloc>::allocator_type allocator_type;
    allocator_type get_allocator() const { return _M_node_allocator; }
    private:
    typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator;
    _Node* _M_get_node() { return _M_node_allocator.allocate(1); }
    void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); }
    # define __HASH_ALLOC_INIT(__a) _M_node_allocator(__a),
    #else /* __STL_USE_STD_ALLOCATORS */
    public:
    typedef _Alloc allocator_type;
    allocator_type get_allocator() const { return allocator_type(); }
    private:
    typedef simple_alloc<_Node, _Alloc> _M_node_allocator_type;
    _Node* _M_get_node() { return _M_node_allocator_type::allocate(1); }
    void _M_put_node(_Node* __p) { _M_node_allocator_type::deallocate(__p, 1); }
    # define __HASH_ALLOC_INIT(__a)
    #endif /* __STL_USE_STD_ALLOCATORS */

    private:
    hasher _M_hash;
    key_equal _M_equals;
    _ExtractKey _M_get_key;
    vector<_Node*,_Alloc> _M_buckets;
    size_type _M_num_elements;

    public:
    typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey ,_EqualKey,_Alloc>
    iterator;
    typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_Extr actKey,_EqualKey,
    _Alloc>
    const_iterator;

    friend struct
    _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey ,_EqualKey,_Alloc>;
    friend struct
    _Hashtable_const_iterator<_Val,_Key,_HashFcn,_Extr actKey,_EqualKey,_Alloc>;

    public:
    hashtable(size_type __n,
    const _HashFcn& __hf,
    const _EqualKey& __eql,
    const _ExtractKey& __ext,
    const allocator_type& __a = allocator_type())
    : __HASH_ALLOC_INIT(__a)
    _M_hash(__hf),
    _M_equals(__eql),
    _M_get_key(__ext),
    _M_buckets(__a),
    _M_num_elements(0)
    {
    _M_initialize_buckets(__n);
    }

    hashtable(size_type __n,
    const _HashFcn& __hf,
    const _EqualKey& __eql,
    const allocator_type& __a = allocator_type())
    : __HASH_ALLOC_INIT(__a)
    _M_hash(__hf),
    _M_equals(__eql),
    _M_get_key(_ExtractKey()),
    _M_buckets(__a),
    _M_num_elements(0)
    {
    _M_initialize_buckets(__n);
    }

    hashtable(const hashtable& __ht)
    : __HASH_ALLOC_INIT(__ht.get_allocator())
    _M_hash(__ht._M_hash),
    _M_equals(__ht._M_equals),
    _M_get_key(__ht._M_get_key),
    _M_buckets(__ht.get_allocator()),
    _M_num_elements(0)
    {
    _M_copy_from(__ht);
    }

    #undef __HASH_ALLOC_INIT

    hashtable& operator= (const hashtable& __ht)
    {
    if (&__ht != this) {
    clear();
    _M_hash = __ht._M_hash;
    _M_equals = __ht._M_equals;
    _M_get_key = __ht._M_get_key;
    _M_copy_from(__ht);
    }
    return *this;
    }

    ~hashtable() { clear(); }

    size_type size() const { return _M_num_elements; }
    size_type max_size() const { return size_type(-1); }
    bool empty() const { return size() == 0; }

    void swap(hashtable& __ht)
    {
    __STD::swap(_M_hash, __ht._M_hash);
    __STD::swap(_M_equals, __ht._M_equals);
    __STD::swap(_M_get_key, __ht._M_get_key);
    _M_buckets.swap(__ht._M_buckets);
    __STD::swap(_M_num_elements, __ht._M_num_elements);
    }

    iterator begin()
    {
    for (size_type __n = 0; __n < _M_buckets.size(); ++__n)
    if (_M_buckets[__n])
    return iterator(_M_buckets[__n], this);
    return end();
    }

    iterator end() { return iterator(0, this); }

    const_iterator begin() const
    {
    for (size_type __n = 0; __n < _M_buckets.size(); ++__n)
    if (_M_buckets[__n])
    return const_iterator(_M_buckets[__n], this);
    return end();
    }

    const_iterator end() const { return const_iterator(0, this); }

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Vl, class _Ky, class _HF, class _Ex, class _Eq, class _Al>
    friend bool operator== (const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&,
    const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&);
    #else /* __STL_MEMBER_TEMPLATES */
    friend bool __STD_QUALIFIER
    operator== __STL_NULL_TMPL_ARGS (const hashtable&, const hashtable&);
    #endif /* __STL_MEMBER_TEMPLATES */

    public:

    size_type bucket_count() const { return _M_buckets.size(); }

    size_type max_bucket_count() const
    { return __stl_prime_list[(int)__stl_num_primes - 1]; }

    size_type elems_in_bucket(size_type __bucket) const
    {
    size_type __result = 0;
    for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next)
    __result += 1;
    return __result;
    }

    pair<iterator, bool> insert_unique(const value_type& __obj)
    {
    resize(_M_num_elements + 1);
    return insert_unique_noresize(__obj);
    }

    iterator insert_equal(const value_type& __obj)
    {
    resize(_M_num_elements + 1);
    return insert_equal_noresize(__obj);
    }

    pair<iterator, bool> insert_unique_noresize(const value_type& __obj);
    iterator insert_equal_noresize(const value_type& __obj);

    #ifdef __STL_MEMBER_TEMPLATES
    template <class _Inpu erator>
    void insert_unique(_Inpu erator __f, _Inpu erator __l)
    {
    insert_unique(__f, __l, __ITERATOR_CATEGORY(__f));
    }

    template <class _Inpu erator>
    void insert_equal(_Inpu erator __f, _Inpu erator __l)
    {
    insert_equal(__f, __l, __ITERATOR_CATEGORY(__f));
    }

    template <class _Inpu erator>
    void insert_unique(_Inpu erator __f, _Inpu erator __l,
    input_iterator_tag)
    {
    for ( ; __f != __l; ++__f)
    insert_unique(*__f);
    }

    template <class _Inpu erator>
    void insert_equal(_Inpu erator __f, _Inpu erator __l,
    input_iterator_tag)
    {
    for ( ; __f != __l; ++__f)
    insert_equal(*__f);
    }

    template <class _ForwardIterator>
    void insert_unique(_ForwardIterator __f, _ForwardIterator __l,
    forward_iterator_tag)
    {
    size_type __n = 0;
    distance(__f, __l, __n);
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_unique_noresize(*__f);
    }

    template <class _ForwardIterator>
    void insert_equal(_ForwardIterator __f, _ForwardIterator __l,
    forward_iterator_tag)
    {
    size_type __n = 0;
    distance(__f, __l, __n);
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_equal_noresize(*__f);
    }

    #else /* __STL_MEMBER_TEMPLATES */
    void insert_unique(const value_type* __f, const value_type* __l)
    {
    size_type __n = __l - __f;
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_unique_noresize(*__f);
    }

    void insert_equal(const value_type* __f, const value_type* __l)
    {
    size_type __n = __l - __f;
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_equal_noresize(*__f);
    }

    void insert_unique(const_iterator __f, const_iterator __l)
    {
    size_type __n = 0;
    distance(__f, __l, __n);
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_unique_noresize(*__f);
    }

    void insert_equal(const_iterator __f, const_iterator __l)
    {
    size_type __n = 0;
    distance(__f, __l, __n);
    resize(_M_num_elements + __n);
    for ( ; __n > 0; --__n, ++__f)
    insert_equal_noresize(*__f);
    }
    #endif /*__STL_MEMBER_TEMPLATES */

    reference find_or_insert(const value_type& __obj);

    iterator find(const key_type& __key)
    {
    size_type __n = _M_bkt_num_key(__key);
    _Node* __first;
    for ( __first = _M_buckets[__n];
    __first && !_M_equals(_M_get_key(__first->_M_val), __key);
    __first = __first->_M_next)
    {}
    return iterator(__first, this);
    }

    const_iterator find(const key_type& __key) const
    {
    size_type __n = _M_bkt_num_key(__key);
    const _Node* __first;
    for ( __first = _M_buckets[__n];
    __first && !_M_equals(_M_get_key(__first->_M_val), __key);
    __first = __first->_M_next)
    {}
    return const_iterator(__first, this);
    }

    size_type count(const key_type& __key) const
    {
    const size_type __n = _M_bkt_num_key(__key);
    size_type __result = 0;

    for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next)
    if (_M_equals(_M_get_key(__cur->_M_val), __key))
    ++__result;
    return __result;
    }

    pair<iterator, iterator>
    equal_range(const key_type& __key);

    pair<const_iterator, const_iterator>
    equal_range(const key_type& __key) const;

    size_type erase(const key_type& __key);
    void erase(const iterator& __it);
    void erase(iterator __first, iterator __last);

    void erase(const const_iterator& __it);
    void erase(const_iterator __first, const_iterator __last);

    void resize(size_type __num_elements_hint);
    void clear();

  17. #92
    俺はまんこが大好きなんだよ baseline bum's Avatar
    My Team
    San Antonio Spurs
    Post Count
    97,883
    private:
    size_type _M_next_size(size_type __n) const
    { return __stl_next_prime(__n); }

    void _M_initialize_buckets(size_type __n)
    {
    const size_type __n_buckets = _M_next_size(__n);
    _M_buckets.reserve(__n_buckets);
    _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0);
    _M_num_elements = 0;
    }

    size_type _M_bkt_num_key(const key_type& __key) const
    {
    return _M_bkt_num_key(__key, _M_buckets.size());
    }

    size_type _M_bkt_num(const value_type& __obj) const
    {
    return _M_bkt_num_key(_M_get_key(__obj));
    }

    size_type _M_bkt_num_key(const key_type& __key, size_t __n) const
    {
    return _M_hash(__key) % __n;
    }

    size_type _M_bkt_num(const value_type& __obj, size_t __n) const
    {
    return _M_bkt_num_key(_M_get_key(__obj), __n);
    }

    _Node* _M_new_node(const value_type& __obj)
    {
    _Node* __n = _M_get_node();
    __n->_M_next = 0;
    __STL_TRY {
    construct(&__n->_M_val, __obj);
    return __n;
    }
    __STL_UNWIND(_M_put_node(__n));
    }

    void _M_delete_node(_Node* __n)
    {
    destroy(&__n->_M_val);
    _M_put_node(__n);
    }

    void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last);
    void _M_erase_bucket(const size_type __n, _Node* __last);

    void _M_copy_from(const hashtable& __ht);

    };

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>&
    _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>: :operator++()
    {
    const _Node* __old = _M_cur;
    _M_cur = _M_cur->_M_next;
    if (!_M_cur) {
    size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);
    while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())
    _M_cur = _M_ht->_M_buckets[__bucket];
    }
    return *this;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>
    _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>: :operator++(int)
    {
    iterator __tmp = *this;
    ++*this;
    return __tmp;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>&
    _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>::operator++()
    {
    const _Node* __old = _M_cur;
    _M_cur = _M_cur->_M_next;
    if (!_M_cur) {
    size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val);
    while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size())
    _M_cur = _M_ht->_M_buckets[__bucket];
    }
    return *this;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>
    _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>::operator++(int)
    {
    const_iterator __tmp = *this;
    ++*this;
    return __tmp;
    }

    #ifndef __STL_CLASS_PARTIAL_SPECIALIZATION

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline forward_iterator_tag
    iterator_category(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& )
    {
    return forward_iterator_tag();
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline _Val*
    value_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& )
    {
    return (_Val*) 0;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::differenc e_type*
    distance_type(const _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& )
    {
    return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::differen ce_type*) 0;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline forward_iterator_tag
    iterator_category(const _Hashtable_const_iterator<_Val,_Key,_HF,
    _ExK,_EqK,_All>&)
    {
    return forward_iterator_tag();
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline _Val*
    value_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>&)
    {
    return (_Val*) 0;
    }

    template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
    class _All>
    inline hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::differenc e_type*
    distance_type(const _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK, _All>&)
    {
    return (hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::differen ce_type*) 0;
    }

    #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,
    const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2)
    {
    typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node;
    if (__ht1._M_buckets.size() != __ht2._M_buckets.size())
    return false;
    for (int __n = 0; __n < __ht1._M_buckets.size(); ++__n) {
    _Node* __cur1 = __ht1._M_buckets[__n];
    _Node* __cur2 = __ht2._M_buckets[__n];
    for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val;
    __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next)
    {}
    if (__cur1 || __cur2)
    return false;
    }
    return true;
    }

    #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    inline bool operator!=(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1,
    const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) {
    return !(__ht1 == __ht2);
    }

    template <class _Val, class _Key, class _HF, class _Extract, class _EqKey,
    class _All>
    inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1,
    hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) {
    __ht1.swap(__ht2);
    }

    #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */


    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    pair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator, bool>
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::insert_unique_noresize(const value_type& __obj)
    {
    const size_type __n = _M_bkt_num(__obj);
    _Node* __first = _M_buckets[__n];

    for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))
    return pair<iterator, bool>(iterator(__cur, this), false);

    _Node* __tmp = _M_new_node(__obj);
    __tmp->_M_next = __first;
    _M_buckets[__n] = __tmp;
    ++_M_num_elements;
    return pair<iterator, bool>(iterator(__tmp, this), true);
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::insert_equal_noresize(const value_type& __obj)
    {
    const size_type __n = _M_bkt_num(__obj);
    _Node* __first = _M_buckets[__n];

    for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) {
    _Node* __tmp = _M_new_node(__obj);
    __tmp->_M_next = __cur->_M_next;
    __cur->_M_next = __tmp;
    ++_M_num_elements;
    return iterator(__tmp, this);
    }

    _Node* __tmp = _M_new_node(__obj);
    __tmp->_M_next = __first;
    _M_buckets[__n] = __tmp;
    ++_M_num_elements;
    return iterator(__tmp, this);
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_ins ert(const value_type& __obj)
    {
    resize(_M_num_elements + 1);

    size_type __n = _M_bkt_num(__obj);
    _Node* __first = _M_buckets[__n];

    for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
    if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))
    return __cur->_M_val;

    _Node* __tmp = _M_new_node(__obj);
    __tmp->_M_next = __first;
    _M_buckets[__n] = __tmp;
    ++_M_num_elements;
    return __tmp->_M_val;
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    pair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator,
    typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator>
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range (const key_type& __key)
    {
    typedef pair<iterator, iterator> _Pii;
    const size_type __n = _M_bkt_num_key(__key);

    for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next)
    if (_M_equals(_M_get_key(__first->_M_val), __key)) {
    for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next)
    if (!_M_equals(_M_get_key(__cur->_M_val), __key))
    return _Pii(iterator(__first, this), iterator(__cur, this));
    for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)
    if (_M_buckets[__m])
    return _Pii(iterator(__first, this),
    iterator(_M_buckets[__m], this));
    return _Pii(iterator(__first, this), end());
    }
    return _Pii(end(), end());
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    pair<typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_itera tor,
    typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_itera tor>
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::equal_range(const key_type& __key) const
    {
    typedef pair<const_iterator, const_iterator> _Pii;
    const size_type __n = _M_bkt_num_key(__key);

    for (const _Node* __first = _M_buckets[__n] ;
    __first;
    __first = __first->_M_next) {
    if (_M_equals(_M_get_key(__first->_M_val), __key)) {
    for (const _Node* __cur = __first->_M_next;
    __cur;
    __cur = __cur->_M_next)
    if (!_M_equals(_M_get_key(__cur->_M_val), __key))
    return _Pii(const_iterator(__first, this),
    const_iterator(__cur, this));
    for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m)
    if (_M_buckets[__m])
    return _Pii(const_iterator(__first, this),
    const_iterator(_M_buckets[__m], this));
    return _Pii(const_iterator(__first, this), end());
    }
    }
    return _Pii(end(), end());
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key)
    {
    const size_type __n = _M_bkt_num_key(__key);
    _Node* __first = _M_buckets[__n];
    size_type __erased = 0;

    if (__first) {
    _Node* __cur = __first;
    _Node* __next = __cur->_M_next;
    while (__next) {
    if (_M_equals(_M_get_key(__next->_M_val), __key)) {
    __cur->_M_next = __next->_M_next;
    _M_delete_node(__next);
    __next = __cur->_M_next;
    ++__erased;
    --_M_num_elements;
    }
    else {
    __cur = __next;
    __next = __cur->_M_next;
    }
    }
    if (_M_equals(_M_get_key(__first->_M_val), __key)) {
    _M_buckets[__n] = __first->_M_next;
    _M_delete_node(__first);
    ++__erased;
    --_M_num_elements;
    }
    }
    return __erased;
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it)
    {
    _Node* __p = __it._M_cur;
    if (__p) {
    const size_type __n = _M_bkt_num(__p->_M_val);
    _Node* __cur = _M_buckets[__n];

    if (__cur == __p) {
    _M_buckets[__n] = __cur->_M_next;
    _M_delete_node(__cur);
    --_M_num_elements;
    }
    else {
    _Node* __next = __cur->_M_next;
    while (__next) {
    if (__next == __p) {
    __cur->_M_next = __next->_M_next;
    _M_delete_node(__next);
    --_M_num_elements;
    break;
    }
    else {
    __cur = __next;
    __next = __cur->_M_next;
    }
    }
    }
    }
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::erase(iterator __first, iterator __last)
    {
    size_type __f_bucket = __first._M_cur ?
    _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size();
    size_type __l_bucket = __last._M_cur ?
    _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size();

    if (__first._M_cur == __last._M_cur)
    return;
    else if (__f_bucket == __l_bucket)
    _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);
    else {
    _M_erase_bucket(__f_bucket, __first._M_cur, 0);
    for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
    _M_erase_bucket(__n, 0);
    if (__l_bucket != _M_buckets.size())
    _M_erase_bucket(__l_bucket, __last._M_cur);
    }
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    inline void
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const _iterator __first,
    const_iterator __last)
    {
    erase(iterator(const_cast<_Node*>(__first._M_cur),
    const_cast<hashtable*>(__first._M_ht)),
    iterator(const_cast<_Node*>(__last._M_cur),
    const_cast<hashtable*>(__last._M_ht)));
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    inline void
    hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it)
    {
    erase(iterator(const_cast<_Node*>(__it._M_cur),
    const_cast<hashtable*>(__it._M_ht)));
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::resize(size_type __num_elements_hint)
    {
    const size_type __old_n = _M_buckets.size();
    if (__num_elements_hint > __old_n) {
    const size_type __n = _M_next_size(__num_elements_hint);
    if (__n > __old_n) {
    vector<_Node*, _All> __tmp(__n, (_Node*)(0),
    _M_buckets.get_allocator());
    __STL_TRY {
    for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
    _Node* __first = _M_buckets[__bucket];
    while (__first) {
    size_type __new_bucket = _M_bkt_num(__first->_M_val, __n);
    _M_buckets[__bucket] = __first->_M_next;
    __first->_M_next = __tmp[__new_bucket];
    __tmp[__new_bucket] = __first;
    __first = _M_buckets[__bucket];
    }
    }
    _M_buckets.swap(__tmp);
    }
    # ifdef __STL_USE_EXCEPTIONS
    catch(...) {
    for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) {
    while (__tmp[__bucket]) {
    _Node* __next = __tmp[__bucket]->_M_next;
    _M_delete_node(__tmp[__bucket]);
    __tmp[__bucket] = __next;
    }
    }
    throw;
    }
    # endif /* __STL_USE_EXCEPTIONS */
    }
    }
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last)
    {
    _Node* __cur = _M_buckets[__n];
    if (__cur == __first)
    _M_erase_bucket(__n, __last);
    else {
    _Node* __next;
    for (__next = __cur->_M_next;
    __next != __first;
    __cur = __next, __next = __cur->_M_next)
    ;
    while (__next != __last) {
    __cur->_M_next = __next->_M_next;
    _M_delete_node(__next);
    __next = __cur->_M_next;
    --_M_num_elements;
    }
    }
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::_M_erase_bucket(const size_type __n, _Node* __last)
    {
    _Node* __cur = _M_buckets[__n];
    while (__cur != __last) {
    _Node* __next = __cur->_M_next;
    _M_delete_node(__cur);
    __cur = __next;
    _M_buckets[__n] = __cur;
    --_M_num_elements;
    }
    }

    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear()
    {
    for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {
    _Node* __cur = _M_buckets[__i];
    while (__cur != 0) {
    _Node* __next = __cur->_M_next;
    _M_delete_node(__cur);
    __cur = __next;
    }
    _M_buckets[__i] = 0;
    }
    _M_num_elements = 0;
    }


    template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
    void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
    ::_M_copy_from(const hashtable& __ht)
    {
    _M_buckets.clear();
    _M_buckets.reserve(__ht._M_buckets.size());
    _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0);
    __STL_TRY {
    for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
    const _Node* __cur = __ht._M_buckets[__i];
    if (__cur) {
    _Node* __copy = _M_new_node(__cur->_M_val);
    _M_buckets[__i] = __copy;

    for (_Node* __next = __cur->_M_next;
    __next;
    __cur = __next, __next = __cur->_M_next) {
    __copy->_M_next = _M_new_node(__next->_M_val);
    __copy = __copy->_M_next;
    }
    }
    }
    _M_num_elements = __ht._M_num_elements;
    }
    __STL_UNWIND(clear());
    }

    __STL_END_NAMESPACE

    #endif /* __SGI_STL_INTERNAL_HASHTABLE_H */

    // Local Variables:
    // mode:C++
    // End:

  18. #93
    Believe.
    My Team
    San Antonio Spurs
    Post Count
    24,896
    Might as well, imo. You will never laugh this hard again in your life.
    http://www.spurstalk.com/forums/show...ker+mul roll

  19. #94
    Executive Mitch's Avatar
    My Team
    Los Angeles Lakers
    Post Count
    6,573
    If he comes out, it's back to worshipping LkrFan's skull ing of Crockett

  20. #95
    TheDrewShow is salty lefty's Avatar
    My Team
    San Antonio Spurs
    Post Count
    101,216
    /*
    * Copyright (c) 1999
    * Silicon Graphics Computer Systems, Inc.
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its do entation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies and
    * that both that copyright notice and this permission notice appear
    * in supporting do entation. Silicon Graphics makes no
    * representations about the suitability of this software for any
    * purpose. It is provided "as is" without express or implied warranty.
    */

    #ifndef __CONCEPT_CHECKS_H
    #define __CONCEPT_CHECKS_H

    /*
    Use these macro like assertions, but they assert properties
    on types (usually template arguments). In technical terms they
    verify whether a type "models" a "concept".

    This set of requirements and the terminology used here is derived
    from the book "Generic Programming and the STL" by Matt Austern
    (Addison Wesley). For further information please consult that
    book. The requirements also are intended to match the ANSI/ISO C++
    standard.

    This file covers the basic concepts and the iterator concepts.
    There are several other files that provide the requirements
    for the STL containers:
    container_concepts.h
    sequence_concepts.h
    assoc_container_concepts.h

    Jeremy Siek, 1999

    TO DO:
    - some issues with regards to concept classification and mutability
    including AssociativeContianer -> ForwardContainer
    and SortedAssociativeContainer -> ReversibleContainer
    - HashedAssociativeContainer
    - Allocator
    - Function Object Concepts

    */

    #ifndef __STL_USE_CONCEPT_CHECKS

    // Some compilers lack the features that are necessary for concept checks.
    // On those compilers we define the concept check macros to do nothing.
    #define __STL_REQUIRES(__type_var, __concept) do {} while(0)
    #define __STL_CLASS_REQUIRES(__type_var, __concept) \
    static int __##__type_var##_##__concept
    #define __STL_CONVERTIBLE(__type_x, __type_y) do {} while(0)
    #define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0)
    #define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
    static int __##__type_x##__type_y##_require_same_type
    #define __STL_GENERATOR_CHECK(__func, __ret) do {} while(0)
    #define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \
    static int __##__func##__ret##_generator_check
    #define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0)
    #define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
    static int __##__func##__ret##__arg##_unary_function_check
    #define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
    do {} while(0)
    #define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
    static int __##__func##__ret##__first##__second##_binary_func tion_check
    #define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
    do {} while(0)
    #define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
    static int __##__opname##__ret##__first##__second##_require_b inary_op

    #else /* __STL_USE_CONCEPT_CHECKS */

    // This macro tests whether the template argument "__type_var"
    // satisfies the requirements of "__concept". Here is a list of concepts
    // that we know how to check:
    // _Allocator
    // _Assignable
    // _DefaultConstructible
    // _EqualityComparable
    // _LessThanComparable
    // _TrivialIterator
    // _Inpu erator
    // _Outpu erator
    // _ForwardIterator
    // _BidirectionalIterator
    // _RandomAccessIterator
    // _Mutable_TrivialIterator
    // _Mutable_ForwardIterator
    // _Mutable_BidirectionalIterator
    // _Mutable_RandomAccessIterator

    #define __STL_REQUIRES(__type_var, __concept) \
    do { \
    void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\
    ::__concept##_requirement_violation; __x = __x; } while (0)

    // Use this to check whether type X is convertible to type Y
    #define __STL_CONVERTIBLE(__type_x, __type_y) \
    do { \
    void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \
    __type_y >::__type_X_is_not_convertible_to_type_Y; \
    __x = __x; } while (0)

    // Use this to test whether two template arguments are the same type
    #define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) \
    do { \
    void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \
    __type_y >::__type_X_not_same_as_type_Y; \
    __x = __x; } while (0)


    // function object checks
    #define __STL_GENERATOR_CHECK(__func, __ret) \
    do { \
    __ret (*__x)( __func&) = \
    _STL_GENERATOR_ERROR< \
    __func, __ret>::__generator_requirement_violation; \
    __x = __x; } while (0)


    #define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
    do { \
    __ret (*__x)( __func&, const __arg& ) = \
    _STL_UNARY_FUNCTION_ERROR< \
    __func, __ret, __arg>::__unary_function_requirement_violation; \
    __x = __x; } while (0)


    #define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
    do { \
    __ret (*__x)( __func&, const __first&, const __second& ) = \
    _STL_BINARY_FUNCTION_ERROR< \
    __func, __ret, __first, __second>::__binary_function_requirement_violation ; \
    __x = __x; } while (0)


    #define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
    do { \
    __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \
    __ret, __first, __second>::__binary_operator_requirement_violation ; \
    __ret (*__y)( const __first&, const __second& ) = \
    _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \
    __const_binary_operator_requirement_violation; \
    __y = __y; __x = __x; } while (0)


    #ifdef __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE

    #define __STL_CLASS_REQUIRES(__type_var, __concept)
    #define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y)
    #define __STL_CLASS_GENERATOR_CHECK(__func, __ret)
    #define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg)
    #define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second)
    #define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second)

    #else

    // Use this macro inside of template classes, where you would
    // like to place requirements on the template arguments to the class
    // Warning: do not pass pointers and such (e.g. T*) in as the __type_var,
    // since the type_var is used to construct identifiers. Instead typedef
    // the pointer type, then use the typedef name for the __type_var.
    #define __STL_CLASS_REQUIRES(__type_var, __concept) \
    typedef void (* __func##__type_var##__concept)( __type_var ); \
    template <__func##__type_var##__concept _Tp1> \
    struct __dummy_struct_##__type_var##__concept { }; \
    static __dummy_struct_##__type_var##__concept< \
    __concept##_concept_specification< \
    __type_var>::__concept##_requirement_violation> \
    __dummy_ptr_##__type_var##__concept


    #define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
    typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \
    __type_y ); \
    template < __func_##__type_x##__type_y##same_type _Tp1> \
    struct __dummy_struct_##__type_x##__type_y##_same_type { }; \
    static __dummy_struct_##__type_x##__type_y##_same_type< \
    _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \
    __dummy_ptr_##__type_x##__type_y##_same_type


    #define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \
    typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \
    template <__f_##__func##__ret##_generator _Tp1> \
    struct __dummy_struct_##__func##__ret##_generator { }; \
    static __dummy_struct_##__func##__ret##_generator< \
    _STL_GENERATOR_ERROR< \
    __func, __ret>::__generator_requirement_violation> \
    __dummy_ptr_##__func##__ret##_generator


    #define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
    typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \
    const __arg& ); \
    template <__f_##__func##__ret##__arg##_unary_check _Tp1> \
    struct __dummy_struct_##__func##__ret##__arg##_unary_chec k { }; \
    static __dummy_struct_##__func##__ret##__arg##_unary_chec k< \
    _STL_UNARY_FUNCTION_ERROR< \
    __func, __ret, __arg>::__unary_function_requirement_violation> \
    __dummy_ptr_##__func##__ret##__arg##_unary_check


    #define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
    typedef __ret (* __f_##__func##__ret##__first##__second##_binary_ch eck)( __func&, const __first&,\
    const __second& ); \
    template <__f_##__func##__ret##__first##__second##_binary_c heck _Tp1> \
    struct __dummy_struct_##__func##__ret##__first##__second# #_binary_check { }; \
    static __dummy_struct_##__func##__ret##__first##__second# #_binary_check< \
    _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \
    __binary_function_requirement_violation> \
    __dummy_ptr_##__func##__ret##__first##__second##_b inary_check


    #define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
    typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op )(const __first&, \
    const __second& ); \
    template <__f_##__func##__ret##__first##__second##_binary_o p _Tp1> \
    struct __dummy_struct_##__func##__ret##__first##__second# #_binary_op { }; \
    static __dummy_struct_##__func##__ret##__first##__second# #_binary_op< \
    _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \
    __binary_operator_requirement_violation> \
    __dummy_ptr_##__func##__ret##__first##__second##_b inary_op

    #endif

    /* helper class for finding non-const version of a type. Need to have
    something to assign to etc. when testing constant iterators. */

    template <class _Tp>
    struct _Mutable_trait {
    typedef _Tp _Type;
    };
    template <class _Tp>
    struct _Mutable_trait<const _Tp> {
    typedef _Tp _Type;
    };


    /* helper function for avoiding compiler warnings about unused variables */
    template <class _Type>
    void __sink_unused_warning(_Type) { }

    template <class _TypeX, class _TypeY>
    struct _STL_CONVERT_ERROR {
    static void
    __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) {
    _TypeY __y = __x;
    __sink_unused_warning(__y);
    }
    };


    template <class _Type> struct __check_equal { };

    template <class _TypeX, class _TypeY>
    struct _STL_SAME_TYPE_ERROR {
    static void
    __type_X_not_same_as_type_Y(_TypeX , _TypeY ) {
    __check_equal<_TypeX> t1 = __check_equal<_TypeY>();
    }
    };


    // Some Functon Object Checks

    template <class _Func, class _Ret>
    struct _STL_GENERATOR_ERROR {
    static _Ret __generator_requirement_violation(_Func& __f) {
    return __f();
    }
    };

    template <class _Func>
    struct _STL_GENERATOR_ERROR<_Func, void> {
    static void __generator_requirement_violation(_Func& __f) {
    __f();
    }
    };


    template <class _Func, class _Ret, class _Arg>
    struct _STL_UNARY_FUNCTION_ERROR {
    static _Ret
    __unary_function_requirement_violation(_Func& __f,
    const _Arg& __arg) {
    return __f(__arg);
    }
    };

    template <class _Func, class _Arg>
    struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> {
    static void
    __unary_function_requirement_violation(_Func& __f,
    const _Arg& __arg) {
    __f(__arg);
    }
    };

    template <class _Func, class _Ret, class _First, class _Second>
    struct _STL_BINARY_FUNCTION_ERROR {
    static _Ret
    __binary_function_requirement_violation(_Func& __f,
    const _First& __first,
    const _Second& __second) {
    return __f(__first, __second);
    }
    };

    template <class _Func, class _First, class _Second>
    struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> {
    static void
    __binary_function_requirement_violation(_Func& __f,
    const _First& __first,
    const _Second& __second) {
    __f(__first, __second);
    }
    };


    #define __STL_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \
    template <class _Ret, class _First, class _Second> \
    struct _STL_BINARY##_NAME##_ERROR { \
    static _Ret \
    __const_binary_operator_requirement_violation(cons t _First& __first, \
    const _Second& __second) { \
    return __first _OP __second; \
    } \
    static _Ret \
    __binary_operator_requirement_violation(_First& __first, \
    _Second& __second) { \
    return __first _OP __second; \
    } \
    }

    __STL_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL);
    __STL_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL);
    __STL_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN);
    __STL_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL);
    __STL_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN);
    __STL_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL);
    __STL_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS);
    __STL_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES);
    __STL_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE);
    __STL_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT);
    __STL_DEFINE_BINARY_OP_CHECK(%, _OP_MOD);
    // ...

    // TODO, add unary operators (prefix and postfix)

    /*
    The presence of this class is just to trick EDG into displaying
    these error messages before any other errors. Without the
    classes, the errors in the functions get reported after
    other class errors deep inside the library. The name
    choice just makes for an eye catching error message
    */
    struct _STL_ERROR {

    template <class _Type>
    static _Type
    __default_constructor_requirement_violation(_Type) {
    return _Type();
    }
    template <class _Type>
    static _Type
    __assignment_operator_requirement_violation(_Type __a) {
    __a = __a;
    return __a;
    }
    template <class _Type>
    static _Type
    __copy_constructor_requirement_violation(_Type __a) {
    _Type __c(__a);
    return __c;
    }
    template <class _Type>
    static _Type
    __const_parameter_required_for_copy_constructor(_T ype /* __a */,
    const _Type& __b) {
    _Type __c(__b);
    return __c;
    }
    template <class _Type>
    static _Type
    __const_parameter_required_for_assignment_operator (_Type __a,
    const _Type& __b) {
    __a = __b;
    return __a;
    }

  21. #96
    🏆🏆🏆🏆🏆 ElNono's Avatar
    My Team
    San Antonio Spurs
    Post Count
    153,473
    crofl lakerfan getting shat on, per par

  22. #97
    moral victory, tbh. Franklin's Avatar
    My Team
    San Antonio Spurs
    Post Count
    4,059
    at least no Laker fan is going to kill himself after knowing that Duncan is gay, instead they'll plan to launch serious pursuits for the big fundamental since they themselves are also sexual (and marriage is legal in their state).

  23. #98
    Veteran Thebesteva's Avatar
    My Team
    Los Angeles Lakers
    Post Count
    12,201
    Does baselines computer have cancer or something?

  24. #99
    Board Man Comes Home Clipper Nation's Avatar
    My Team
    Los Angeles Clippers
    Post Count
    54,257
    Kobe Bryant has reportedly appeared in a gay sex tape, though the flimsy rumor from a gossip website has sparked anger among some Los Angeles Lakers fans.

    The report alleges that the NBA All-Star appears in an explicit video with a man who plays basketball for Cal State Bernadino. There is also a video that reportedly shows the tryst, though details are far from specific.

    The Kobe Bryant gay sex tape report originated from MediaTakeOut.com a gossip site that reported “your fav player on the Los Angeles Lakers gets caught up in gay sex scandal… they got him on tape!”


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •