📄 deque_spec.h
字号:
// -*- C++ -*-
/***************************************************************************
*
* deque_spec.h - deque <_TypeT*> partial specialization
*
***************************************************************************
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation 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 documentation. 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) 1994-2001 Rogue Wave Software, Inc. All Rights Reserved.
*
* This computer software is owned by Rogue Wave Software, Inc. and is
* protected by U.S. copyright laws and other laws and by international
* treaties. This computer software is furnished by Rogue Wave Software,
* Inc. pursuant to a written license agreement and may be used, copied,
* transmitted, and stored only in accordance with the terms of such
* license and with the inclusion of the above copyright notice. This
* computer software or any other copies thereof may not be provided or
* otherwise made available to any other person.
*
* U.S. Government Restricted Rights. This computer software is provided
* with Restricted Rights. Use, duplication, or disclosure by the
* Government is subject to restrictions as set forth in subparagraph (c)
* (1) (ii) of The Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
* Commercial Computer Software--Restricted Rights at 48 CFR 52.227-19,
* as applicable. Manufacturer is Rogue Wave Software, Inc., 5500
* Flatiron Parkway, Boulder, Colorado 80301 USA.
*
**************************************************************************/
#ifndef __STD_DEQUE_SPEC__
#define __STD_DEQUE_SPEC__
#include <rw/_defs.h>
#ifndef __STD_DEQUE__
#include <deque>
#endif // __STD_DEQUE__
_RWSTD_NAMESPACE_BEGIN (std)
template class deque <void*, allocator <void*> >;
template <class _TypeT>
class deque <_TypeT*, allocator <_TypeT*> >
{
typedef allocator <_TypeT*> _Allocator;
typedef _RWSTD_REBIND (_Allocator, void*) __imp_alloc_type;
typedef deque <void*, __imp_alloc_type> __imp_type;
__imp_type __imp;
public:
typedef _TypeT* value_type;
typedef _Allocator allocator_type;
class iterator;
class const_iterator;
friend class iterator;
friend class const_iterator;
typedef _TYPENAME allocator_type::reference reference;
typedef _TYPENAME allocator_type::const_reference const_reference;
typedef _TYPENAME allocator_type::size_type size_type;
typedef _TYPENAME allocator_type::difference_type difference_type;
typedef _TYPENAME allocator_type::pointer pointer;
typedef _TYPENAME allocator_type::const_pointer const_pointer;
protected:
typedef _RWSTD_REBIND (_Allocator, pointer) __map_alloc_type;
typedef _TYPENAME __map_alloc_type::pointer __map_pointer;
typedef _STD::iterator <random_access_iterator_tag, value_type,
difference_type, pointer,reference> __it;
typedef _STD::iterator <random_access_iterator_tag, value_type,
difference_type, const_pointer, const_reference> __cit;
public:
class const_iterator;
class iterator : public __it
{
typedef _TYPENAME __imp_type::iterator __imp_iter;
__imp_iter __imp;
friend class deque<_TypeT, allocator <_TypeT> >;
friend class const_iterator;
// implicit conversions from and to implementation-specific iterator
// used only internally
iterator (const __imp_iter &imp)
: __imp (imp) {}
operator __imp_iter () {
return __imp;
}
public:
iterator () {}
__iterator_base::reference operator* () const {
return __iterator_base::reference (*__imp);
}
#ifndef _RWSTD_NO_NONCLASS_ARROW_RETURN
__iterator_base::pointer operator-> () const {
return __iterator_base::pointer (&*__imp);
}
#endif // _RWSTD_NO_NONCLASS_ARROW_RETURN
iterator& operator++ () {
++__imp;
return *this;
}
iterator operator++ (int) {
iterator tmp = *this;
++*this;
return tmp;
}
iterator& operator-- () {
--__imp;
return *this;
}
iterator operator-- (int) {
iterator tmp = *this;
--*this;
return tmp;
}
iterator& operator+= (__iterator_base::difference_type n) {
__imp += n;
return *this;
}
iterator& operator-= (__iterator_base::difference_type n) {
__imp -= n;
return *this;
}
__iterator_base::difference_type operator- (const iterator& x) const {
return __imp - x.__imp;
}
iterator operator- (__iterator_base::difference_type n) {
return __imp - n;
}
iterator operator+ (__iterator_base::difference_type n) {
return __imp + n;
}
__iterator_base::reference operator[] (__iterator_base::difference_type n) {
return __imp [n];
}
bool operator== (const iterator &x) const {
return __imp == x.__imp;
}
bool operator< (const iterator &x) const {
return __imp < x.__imp;
}
bool operator> (const iterator &x) const {
return x.__imp < *this;
}
bool operator!= (const iterator &x) const {
return !(*this == x.__imp);
}
bool operator<= (const iterator &x) const {
return !(*x.__imp < *this);
}
bool operator>= (const iterator &x) const {
return !(x.__imp < *this);
}
};
class const_iterator : public __cit
{
typedef _TYPENAME __imp_type::const_iterator __imp_iter;
__imp_iter __imp;
friend class deque<_TypeT, allocator <_TypeT> >;
const_iterator (const __imp_iter &imp): __imp (imp) {}
public:
const_iterator () {}
const_iterator (const iterator &x) : __imp (x.__imp) {}
const_reference operator* () const {
return const_reference (*__imp);
}
#ifndef _RWSTD_NO_NONCLASS_ARROW_RETURN
const_pointer operator-> () const {
return const_pointer (&*__imp);
}
#endif // _RWSTD_NO_NONCLASS_ARROW_RETURN
const_iterator& operator++ () {
++__imp;
return *this;
}
const_iterator operator++ (int) {
const_iterator tmp = *this;
++*this;
return tmp;
}
const_iterator& operator-- () {
--__imp;
return *this;
}
const_iterator operator-- (int) {
const_iterator tmp = *this;
--*this;
return tmp;
}
const_iterator& operator+= (__iterator_base::difference_type n) {
__imp += n;
return *this;
}
const_iterator& operator-= (__iterator_base::difference_type n) {
__imp -= n;
return *this;
}
__iterator_base::difference_type operator- (const const_iterator& x) const {
return __imp - x.__imp;
}
const_iterator operator- (__iterator_base::difference_type n) {
return __imp - n;
}
const_iterator operator+ (__iterator_base::difference_type n) {
return __imp + n;
}
const_reference operator[] (__iterator_base::difference_type n) {
return __imp [n];
}
bool operator== (const const_iterator &x) const {
return __imp == x.__imp;
}
bool operator< (const const_iterator &x) const {
return __imp < x.__imp;
}
bool operator> (const const_iterator &x) const {
return x.__imp < *this;
}
bool operator!= (const const_iterator &x) const {
return !(*this == x.__imp);
}
bool operator<= (const const_iterator &x) const {
return !(*x.__imp < *this);
}
bool operator>= (const const_iterator &x) const {
return !(x.__imp < *this);
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -