gccxml_gem 0.9.3-x86-darwin-11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +84 -0
- data/bin/gccxml +0 -0
- data/bin/gccxml_cc1plus +0 -0
- data/gccxml.rb +57 -0
- data/share/doc/gccxml-0.9/Copyright.txt +55 -0
- data/share/doc/gccxml-0.9/gccxml.html +168 -0
- data/share/doc/gccxml-0.9/gccxml.txt +293 -0
- data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
- data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
- data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
- data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
- data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
- data/share/gccxml-0.9/GCC/2.95/complex +38 -0
- data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
- data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
- data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
- data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
- data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
- data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
- data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
- data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
- data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
- data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
- data/share/gccxml-0.9/GCC/2.95/deque +19 -0
- data/share/gccxml-0.9/GCC/2.95/exception +20 -0
- data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/functional +64 -0
- data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
- data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
- data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
- data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
- data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
- data/share/gccxml-0.9/GCC/2.95/list +19 -0
- data/share/gccxml-0.9/GCC/2.95/map +20 -0
- data/share/gccxml-0.9/GCC/2.95/memory +21 -0
- data/share/gccxml-0.9/GCC/2.95/new +13 -0
- data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
- data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/2.95/queue +20 -0
- data/share/gccxml-0.9/GCC/2.95/set +20 -0
- data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
- data/share/gccxml-0.9/GCC/2.95/stack +19 -0
- data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
- data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
- data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
- data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
- data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
- data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
- data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
- data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
- data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
- data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
- data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
- data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
- data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
- data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
- data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
- data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
- data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
- data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
- data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
- data/share/gccxml-0.9/GCC/2.95/string +26 -0
- data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
- data/share/gccxml-0.9/GCC/2.95/utility +25 -0
- data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
- data/share/gccxml-0.9/GCC/2.95/vector +19 -0
- data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
- data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
- data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +585 -0
- data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
- data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
- data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
- data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
- data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
- data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
- data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
- data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
- data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
- data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
- data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
- data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
- data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
- data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
- data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +669 -0
- data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
- data/share/gccxml-0.9/GCC/4.0/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_emmintrin.h +1037 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_mmintrin.h +669 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_xmmintrin.h +870 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_emmintrin.h +977 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_mmintrin.h +636 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_xmmintrin.h +833 -0
- data/share/gccxml-0.9/GCC/4.0/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.0/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +622 -0
- data/share/gccxml-0.9/GCC/4.1/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_emmintrin.h +1509 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_mmintrin.h +942 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_xmmintrin.h +1192 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_emmintrin.h +1004 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_mmintrin.h +637 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_xmmintrin.h +834 -0
- data/share/gccxml-0.9/GCC/4.1/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_emmintrin.h +1509 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_mmintrin.h +942 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_xmmintrin.h +1192 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_emmintrin.h +1013 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_mmintrin.h +663 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_xmmintrin.h +860 -0
- data/share/gccxml-0.9/GCC/4.2/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.3/emmintrin.h +1043 -0
- data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +183 -0
- data/share/gccxml-0.9/GCC/4.3/mmintrin.h +663 -0
- data/share/gccxml-0.9/GCC/4.3/xmmintrin.h +867 -0
- data/share/gccxml-0.9/GCC/4.4/bits/c++config.h +1431 -0
- data/share/gccxml-0.9/GCC/4.4/emmintrin.h +1041 -0
- data/share/gccxml-0.9/GCC/4.4/gccxml_builtins.h +153 -0
- data/share/gccxml-0.9/GCC/4.4/mmintrin.h +662 -0
- data/share/gccxml-0.9/GCC/4.4/xmmintrin.h +864 -0
- data/share/gccxml-0.9/GCC/4.5/gccxml_builtins.h +154 -0
- data/share/gccxml-0.9/GCC/4.5/iomanip +349 -0
- data/share/gccxml-0.9/GCC/COPYING.RUNTIME +73 -0
- data/share/gccxml-0.9/GCC/COPYING3 +674 -0
- data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
- data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
- data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
- data/share/gccxml-0.9/IBM/README +8 -0
- data/share/gccxml-0.9/IBM/find_flags +51 -0
- data/share/gccxml-0.9/IBM/find_flags_common +48 -0
- data/share/gccxml-0.9/Intel/find_flags +56 -0
- data/share/gccxml-0.9/Intel/pthread.h +16 -0
- data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
- data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
- data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
- data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
- data/share/gccxml-0.9/MIPSpro/find_flags +70 -0
- data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
- data/share/gccxml-0.9/Sun/5.8/Cstd.patch +156 -0
- data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
- data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
- data/share/gccxml-0.9/Sun/README +8 -0
- data/share/gccxml-0.9/Sun/find_flags +51 -0
- data/share/gccxml-0.9/Sun/find_flags_common +42 -0
- data/share/gccxml-0.9/gccxml_config +2 -0
- data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
- data/share/man/man1/gccxml.1 +246 -0
- metadata +243 -0
@@ -0,0 +1,843 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright (c) 1994
|
4
|
+
* Hewlett-Packard Company
|
5
|
+
*
|
6
|
+
* Permission to use, copy, modify, distribute and sell this software
|
7
|
+
* and its documentation for any purpose is hereby granted without fee,
|
8
|
+
* provided that the above copyright notice appear in all copies and
|
9
|
+
* that both that copyright notice and this permission notice appear
|
10
|
+
* in supporting documentation. Hewlett-Packard Company makes no
|
11
|
+
* representations about the suitability of this software for any
|
12
|
+
* purpose. It is provided "as is" without express or implied warranty.
|
13
|
+
*
|
14
|
+
*
|
15
|
+
* Copyright (c) 1996,1997
|
16
|
+
* Silicon Graphics Computer Systems, Inc.
|
17
|
+
*
|
18
|
+
* Permission to use, copy, modify, distribute and sell this software
|
19
|
+
* and its documentation for any purpose is hereby granted without fee,
|
20
|
+
* provided that the above copyright notice appear in all copies and
|
21
|
+
* that both that copyright notice and this permission notice appear
|
22
|
+
* in supporting documentation. Silicon Graphics makes no
|
23
|
+
* representations about the suitability of this software for any
|
24
|
+
* purpose. It is provided "as is" without express or implied warranty.
|
25
|
+
*/
|
26
|
+
|
27
|
+
/* NOTE: This is an internal header file, included by other STL headers.
|
28
|
+
* You should not attempt to use it directly.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#ifndef __SGI_STL_INTERNAL_LIST_H
|
32
|
+
#define __SGI_STL_INTERNAL_LIST_H
|
33
|
+
|
34
|
+
__STL_BEGIN_NAMESPACE
|
35
|
+
|
36
|
+
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
37
|
+
#pragma set woff 1174
|
38
|
+
#pragma set woff 1375
|
39
|
+
#endif
|
40
|
+
|
41
|
+
template <class _Tp>
|
42
|
+
struct _List_node {
|
43
|
+
typedef void* _Void_pointer;
|
44
|
+
_Void_pointer _M_next;
|
45
|
+
_Void_pointer _M_prev;
|
46
|
+
_Tp _M_data;
|
47
|
+
};
|
48
|
+
|
49
|
+
template<class _Tp, class _Ref, class _Ptr>
|
50
|
+
struct _List_iterator {
|
51
|
+
typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
|
52
|
+
typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
|
53
|
+
typedef _List_iterator<_Tp,_Ref,_Ptr> _Self;
|
54
|
+
|
55
|
+
typedef bidirectional_iterator_tag iterator_category;
|
56
|
+
typedef _Tp value_type;
|
57
|
+
typedef _Ptr pointer;
|
58
|
+
typedef _Ref reference;
|
59
|
+
typedef _List_node<_Tp> _Node;
|
60
|
+
typedef size_t size_type;
|
61
|
+
typedef ptrdiff_t difference_type;
|
62
|
+
|
63
|
+
_Node* _M_node;
|
64
|
+
|
65
|
+
_List_iterator(_Node* __x) : _M_node(__x) {}
|
66
|
+
_List_iterator() {}
|
67
|
+
_List_iterator(const iterator& __x) : _M_node(__x._M_node) {}
|
68
|
+
|
69
|
+
bool operator==(const _Self& __x) const { return _M_node == __x._M_node; }
|
70
|
+
bool operator!=(const _Self& __x) const { return _M_node != __x._M_node; }
|
71
|
+
reference operator*() const { return (*_M_node)._M_data; }
|
72
|
+
|
73
|
+
#ifndef __SGI_STL_NO_ARROW_OPERATOR
|
74
|
+
pointer operator->() const { return &(operator*()); }
|
75
|
+
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
|
76
|
+
|
77
|
+
_Self& operator++() {
|
78
|
+
_M_node = (_Node*)(_M_node->_M_next);
|
79
|
+
return *this;
|
80
|
+
}
|
81
|
+
_Self operator++(int) {
|
82
|
+
_Self __tmp = *this;
|
83
|
+
++*this;
|
84
|
+
return __tmp;
|
85
|
+
}
|
86
|
+
_Self& operator--() {
|
87
|
+
_M_node = (_Node*)(_M_node->_M_prev);
|
88
|
+
return *this;
|
89
|
+
}
|
90
|
+
_Self operator--(int) {
|
91
|
+
_Self __tmp = *this;
|
92
|
+
--*this;
|
93
|
+
return __tmp;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
|
98
|
+
|
99
|
+
template <class _Tp, class _Ref, class _Ptr>
|
100
|
+
inline bidirectional_iterator_tag
|
101
|
+
iterator_category(const _List_iterator<_Tp, _Ref, _Ptr>&)
|
102
|
+
{
|
103
|
+
return bidirectional_iterator_tag();
|
104
|
+
}
|
105
|
+
|
106
|
+
template <class _Tp, class _Ref, class _Ptr>
|
107
|
+
inline _Tp*
|
108
|
+
value_type(const _List_iterator<_Tp, _Ref, _Ptr>&)
|
109
|
+
{
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
template <class _Tp, class _Ref, class _Ptr>
|
114
|
+
inline ptrdiff_t*
|
115
|
+
distance_type(const _List_iterator<_Tp, _Ref, _Ptr>&)
|
116
|
+
{
|
117
|
+
return 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
121
|
+
|
122
|
+
|
123
|
+
// Base class that encapsulates details of allocators. Three cases:
|
124
|
+
// an ordinary standard-conforming allocator, a standard-conforming
|
125
|
+
// allocator with no non-static data, and an SGI-style allocator.
|
126
|
+
// This complexity is necessary only because we're worrying about backward
|
127
|
+
// compatibility and because we want to avoid wasting storage on an
|
128
|
+
// allocator instance if it isn't necessary.
|
129
|
+
|
130
|
+
#ifdef __STL_USE_STD_ALLOCATORS
|
131
|
+
|
132
|
+
// Base for general standard-conforming allocators.
|
133
|
+
template <class _Tp, class _Allocator, bool _IsStatic>
|
134
|
+
class _List_alloc_base {
|
135
|
+
public:
|
136
|
+
typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
|
137
|
+
allocator_type;
|
138
|
+
allocator_type get_allocator() const { return _Node_allocator; }
|
139
|
+
|
140
|
+
_List_alloc_base(const allocator_type& __a) : _Node_allocator(__a) {}
|
141
|
+
|
142
|
+
protected:
|
143
|
+
_List_node<_Tp>* _M_get_node()
|
144
|
+
{ return _Node_allocator.allocate(1); }
|
145
|
+
void _M_put_node(_List_node<_Tp>* __p)
|
146
|
+
{ _Node_allocator.deallocate(__p, 1); }
|
147
|
+
|
148
|
+
protected:
|
149
|
+
typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type
|
150
|
+
_Node_allocator;
|
151
|
+
_List_node<_Tp>* _M_node;
|
152
|
+
};
|
153
|
+
|
154
|
+
// Specialization for instanceless allocators.
|
155
|
+
|
156
|
+
template <class _Tp, class _Allocator>
|
157
|
+
class _List_alloc_base<_Tp, _Allocator, true> {
|
158
|
+
public:
|
159
|
+
typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
|
160
|
+
allocator_type;
|
161
|
+
allocator_type get_allocator() const { return allocator_type(); }
|
162
|
+
|
163
|
+
_List_alloc_base(const allocator_type&) {}
|
164
|
+
|
165
|
+
protected:
|
166
|
+
typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type
|
167
|
+
_Alloc_type;
|
168
|
+
_List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }
|
169
|
+
void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); }
|
170
|
+
|
171
|
+
protected:
|
172
|
+
_List_node<_Tp>* _M_node;
|
173
|
+
};
|
174
|
+
|
175
|
+
template <class _Tp, class _Alloc>
|
176
|
+
class _List_base
|
177
|
+
: public _List_alloc_base<_Tp, _Alloc,
|
178
|
+
_Alloc_traits<_Tp, _Alloc>::_S_instanceless>
|
179
|
+
{
|
180
|
+
public:
|
181
|
+
typedef _List_alloc_base<_Tp, _Alloc,
|
182
|
+
_Alloc_traits<_Tp, _Alloc>::_S_instanceless>
|
183
|
+
_Base;
|
184
|
+
using _Base::_M_node;
|
185
|
+
using _Base::_M_get_node;
|
186
|
+
typedef typename _Base::allocator_type allocator_type;
|
187
|
+
|
188
|
+
_List_base(const allocator_type& __a) : _Base(__a) {
|
189
|
+
_M_node = _M_get_node();
|
190
|
+
_M_node->_M_next = _M_node;
|
191
|
+
_M_node->_M_prev = _M_node;
|
192
|
+
}
|
193
|
+
~_List_base() {
|
194
|
+
clear();
|
195
|
+
_M_put_node(_M_node);
|
196
|
+
}
|
197
|
+
|
198
|
+
void clear();
|
199
|
+
};
|
200
|
+
|
201
|
+
#else /* __STL_USE_STD_ALLOCATORS */
|
202
|
+
|
203
|
+
template <class _Tp, class _Alloc>
|
204
|
+
class _List_base
|
205
|
+
{
|
206
|
+
public:
|
207
|
+
typedef _Alloc allocator_type;
|
208
|
+
allocator_type get_allocator() const { return allocator_type(); }
|
209
|
+
|
210
|
+
_List_base(const allocator_type&) {
|
211
|
+
_M_node = _M_get_node();
|
212
|
+
_M_node->_M_next = _M_node;
|
213
|
+
_M_node->_M_prev = _M_node;
|
214
|
+
}
|
215
|
+
~_List_base() {
|
216
|
+
clear();
|
217
|
+
_M_put_node(_M_node);
|
218
|
+
}
|
219
|
+
|
220
|
+
void clear();
|
221
|
+
|
222
|
+
protected:
|
223
|
+
typedef simple_alloc<_List_node<_Tp>, _Alloc> _Alloc_type;
|
224
|
+
_List_node<_Tp>* _M_get_node() { return _Alloc_type::allocate(1); }
|
225
|
+
void _M_put_node(_List_node<_Tp>* __p) { _Alloc_type::deallocate(__p, 1); }
|
226
|
+
|
227
|
+
protected:
|
228
|
+
_List_node<_Tp>* _M_node;
|
229
|
+
};
|
230
|
+
|
231
|
+
#endif /* __STL_USE_STD_ALLOCATORS */
|
232
|
+
|
233
|
+
template <class _Tp, class _Alloc>
|
234
|
+
void
|
235
|
+
_List_base<_Tp,_Alloc>::clear()
|
236
|
+
{
|
237
|
+
_List_node<_Tp>* __cur = (_List_node<_Tp>*) _M_node->_M_next;
|
238
|
+
while (__cur != _M_node) {
|
239
|
+
_List_node<_Tp>* __tmp = __cur;
|
240
|
+
__cur = (_List_node<_Tp>*) __cur->_M_next;
|
241
|
+
destroy(&__tmp->_M_data);
|
242
|
+
_M_put_node(__tmp);
|
243
|
+
}
|
244
|
+
_M_node->_M_next = _M_node;
|
245
|
+
_M_node->_M_prev = _M_node;
|
246
|
+
}
|
247
|
+
|
248
|
+
template <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
|
249
|
+
class list : protected _List_base<_Tp, _Alloc> {
|
250
|
+
typedef _List_base<_Tp, _Alloc> _Base;
|
251
|
+
protected:
|
252
|
+
typedef void* _Void_pointer;
|
253
|
+
|
254
|
+
public:
|
255
|
+
typedef _Tp value_type;
|
256
|
+
typedef value_type* pointer;
|
257
|
+
typedef const value_type* const_pointer;
|
258
|
+
typedef value_type& reference;
|
259
|
+
typedef const value_type& const_reference;
|
260
|
+
typedef _List_node<_Tp> _Node;
|
261
|
+
typedef size_t size_type;
|
262
|
+
typedef ptrdiff_t difference_type;
|
263
|
+
|
264
|
+
typedef typename _Base::allocator_type allocator_type;
|
265
|
+
allocator_type get_allocator() const { return _Base::get_allocator(); }
|
266
|
+
|
267
|
+
public:
|
268
|
+
typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
|
269
|
+
typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
|
270
|
+
|
271
|
+
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
|
272
|
+
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
273
|
+
typedef reverse_iterator<iterator> reverse_iterator;
|
274
|
+
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
275
|
+
typedef reverse_bidirectional_iterator<const_iterator,value_type,
|
276
|
+
const_reference,difference_type>
|
277
|
+
const_reverse_iterator;
|
278
|
+
typedef reverse_bidirectional_iterator<iterator,value_type,reference,
|
279
|
+
difference_type>
|
280
|
+
reverse_iterator;
|
281
|
+
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
|
282
|
+
|
283
|
+
protected:
|
284
|
+
#ifdef __STL_HAS_NAMESPACES
|
285
|
+
using _Base::_M_node;
|
286
|
+
using _Base::_M_put_node;
|
287
|
+
using _Base::_M_get_node;
|
288
|
+
#endif /* __STL_HAS_NAMESPACES */
|
289
|
+
|
290
|
+
protected:
|
291
|
+
_Node* _M_create_node(const _Tp& __x)
|
292
|
+
{
|
293
|
+
_Node* __p = _M_get_node();
|
294
|
+
__STL_TRY {
|
295
|
+
construct(&__p->_M_data, __x);
|
296
|
+
}
|
297
|
+
__STL_UNWIND(_M_put_node(__p));
|
298
|
+
return __p;
|
299
|
+
}
|
300
|
+
|
301
|
+
_Node* _M_create_node()
|
302
|
+
{
|
303
|
+
_Node* __p = _M_get_node();
|
304
|
+
__STL_TRY {
|
305
|
+
construct(&__p->_M_data);
|
306
|
+
}
|
307
|
+
__STL_UNWIND(_M_put_node(__p));
|
308
|
+
return __p;
|
309
|
+
}
|
310
|
+
|
311
|
+
public:
|
312
|
+
explicit list(const allocator_type& __a = allocator_type()) : _Base(__a) {}
|
313
|
+
|
314
|
+
iterator begin() { return (_Node*)(_M_node->_M_next); }
|
315
|
+
const_iterator begin() const { return (_Node*)(_M_node->_M_next); }
|
316
|
+
|
317
|
+
iterator end() { return _M_node; }
|
318
|
+
const_iterator end() const { return _M_node; }
|
319
|
+
|
320
|
+
reverse_iterator rbegin()
|
321
|
+
{ return reverse_iterator(end()); }
|
322
|
+
const_reverse_iterator rbegin() const
|
323
|
+
{ return const_reverse_iterator(end()); }
|
324
|
+
|
325
|
+
reverse_iterator rend()
|
326
|
+
{ return reverse_iterator(begin()); }
|
327
|
+
const_reverse_iterator rend() const
|
328
|
+
{ return const_reverse_iterator(begin()); }
|
329
|
+
|
330
|
+
bool empty() const { return _M_node->_M_next == _M_node; }
|
331
|
+
size_type size() const {
|
332
|
+
size_type __result = 0;
|
333
|
+
distance(begin(), end(), __result);
|
334
|
+
return __result;
|
335
|
+
}
|
336
|
+
size_type max_size() const { return size_type(-1); }
|
337
|
+
|
338
|
+
reference front() { return *begin(); }
|
339
|
+
const_reference front() const { return *begin(); }
|
340
|
+
reference back() { return *(--end()); }
|
341
|
+
const_reference back() const { return *(--end()); }
|
342
|
+
|
343
|
+
void swap(list<_Tp, _Alloc>& __x) { __STD::swap(_M_node, __x._M_node); }
|
344
|
+
|
345
|
+
iterator insert(iterator __position, const _Tp& __x) {
|
346
|
+
_Node* __tmp = _M_create_node(__x);
|
347
|
+
__tmp->_M_next = __position._M_node;
|
348
|
+
__tmp->_M_prev = __position._M_node->_M_prev;
|
349
|
+
((_Node*) (__position._M_node->_M_prev))->_M_next = __tmp;
|
350
|
+
__position._M_node->_M_prev = __tmp;
|
351
|
+
return __tmp;
|
352
|
+
}
|
353
|
+
iterator insert(iterator __position) { return insert(__position, _Tp()); }
|
354
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
355
|
+
// Check whether it's an integral type. If so, it's not an iterator.
|
356
|
+
|
357
|
+
template<class _Integer>
|
358
|
+
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
|
359
|
+
__true_type) {
|
360
|
+
insert(__pos, (size_type) __n, (_Tp) __x);
|
361
|
+
}
|
362
|
+
|
363
|
+
template <class _InputIterator>
|
364
|
+
void _M_insert_dispatch(iterator __pos,
|
365
|
+
_InputIterator __first, _InputIterator __last,
|
366
|
+
__false_type);
|
367
|
+
|
368
|
+
template <class _InputIterator>
|
369
|
+
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
|
370
|
+
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
|
371
|
+
_M_insert_dispatch(__pos, __first, __last, _Integral());
|
372
|
+
}
|
373
|
+
|
374
|
+
#else /* __STL_MEMBER_TEMPLATES */
|
375
|
+
void insert(iterator __position, const _Tp* __first, const _Tp* __last);
|
376
|
+
void insert(iterator __position,
|
377
|
+
const_iterator __first, const_iterator __last);
|
378
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
379
|
+
void insert(iterator __pos, size_type __n, const _Tp& __x);
|
380
|
+
|
381
|
+
void push_front(const _Tp& __x) { insert(begin(), __x); }
|
382
|
+
void push_front() {insert(begin());}
|
383
|
+
void push_back(const _Tp& __x) { insert(end(), __x); }
|
384
|
+
void push_back() {insert(end());}
|
385
|
+
|
386
|
+
iterator erase(iterator __position) {
|
387
|
+
_Node* __next_node = (_Node*) (__position._M_node->_M_next);
|
388
|
+
_Node* __prev_node = (_Node*) (__position._M_node->_M_prev);
|
389
|
+
__prev_node->_M_next = __next_node;
|
390
|
+
__next_node->_M_prev = __prev_node;
|
391
|
+
destroy(&__position._M_node->_M_data);
|
392
|
+
_M_put_node(__position._M_node);
|
393
|
+
return iterator(__next_node);
|
394
|
+
}
|
395
|
+
iterator erase(iterator __first, iterator __last);
|
396
|
+
void clear() { _Base::clear(); }
|
397
|
+
|
398
|
+
void resize(size_type __new_size, const _Tp& __x);
|
399
|
+
void resize(size_type __new_size) { resize(__new_size, _Tp()); }
|
400
|
+
|
401
|
+
void pop_front() { erase(begin()); }
|
402
|
+
void pop_back() {
|
403
|
+
iterator __tmp = end();
|
404
|
+
erase(--__tmp);
|
405
|
+
}
|
406
|
+
list(size_type __n, const _Tp& __value,
|
407
|
+
const allocator_type& __a = allocator_type())
|
408
|
+
: _Base(__a)
|
409
|
+
{ insert(begin(), __n, __value); }
|
410
|
+
explicit list(size_type __n)
|
411
|
+
: _Base(allocator_type())
|
412
|
+
{ insert(begin(), __n, _Tp()); }
|
413
|
+
|
414
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
415
|
+
|
416
|
+
// We don't need any dispatching tricks here, because insert does all of
|
417
|
+
// that anyway.
|
418
|
+
template <class _InputIterator>
|
419
|
+
list(_InputIterator __first, _InputIterator __last,
|
420
|
+
const allocator_type& __a = allocator_type())
|
421
|
+
: _Base(__a)
|
422
|
+
{ insert(begin(), __first, __last); }
|
423
|
+
|
424
|
+
#else /* __STL_MEMBER_TEMPLATES */
|
425
|
+
|
426
|
+
list(const _Tp* __first, const _Tp* __last,
|
427
|
+
const allocator_type& __a = allocator_type())
|
428
|
+
: _Base(__a)
|
429
|
+
{ insert(begin(), __first, __last); }
|
430
|
+
list(const_iterator __first, const_iterator __last,
|
431
|
+
const allocator_type& __a = allocator_type())
|
432
|
+
: _Base(__a)
|
433
|
+
{ insert(begin(), __first, __last); }
|
434
|
+
|
435
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
436
|
+
list(const list<_Tp, _Alloc>& __x) : _Base(__x.get_allocator())
|
437
|
+
{ insert(begin(), __x.begin(), __x.end()); }
|
438
|
+
|
439
|
+
~list() { }
|
440
|
+
|
441
|
+
list<_Tp, _Alloc>& operator=(const list<_Tp, _Alloc>& __x);
|
442
|
+
|
443
|
+
public:
|
444
|
+
// assign(), a generalized assignment member function. Two
|
445
|
+
// versions: one that takes a count, and one that takes a range.
|
446
|
+
// The range version is a member template, so we dispatch on whether
|
447
|
+
// or not the type is an integer.
|
448
|
+
|
449
|
+
void assign(size_type __n, const _Tp& __val);
|
450
|
+
|
451
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
452
|
+
|
453
|
+
template <class _InputIterator>
|
454
|
+
void assign(_InputIterator __first, _InputIterator __last) {
|
455
|
+
typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
|
456
|
+
_M_assign_dispatch(__first, __last, _Integral());
|
457
|
+
}
|
458
|
+
|
459
|
+
template <class _Integer>
|
460
|
+
void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
|
461
|
+
{ assign((size_type) __n, (_Tp) __val); }
|
462
|
+
|
463
|
+
template <class _InputIterator>
|
464
|
+
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
|
465
|
+
__false_type);
|
466
|
+
|
467
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
468
|
+
|
469
|
+
protected:
|
470
|
+
void transfer(iterator __position, iterator __first, iterator __last) {
|
471
|
+
if (__position != __last) {
|
472
|
+
// Remove [first, last) from its old position.
|
473
|
+
((_Node*) (__last._M_node->_M_prev))->_M_next = __position._M_node;
|
474
|
+
((_Node*) (__first._M_node->_M_prev))->_M_next = __last._M_node;
|
475
|
+
((_Node*) (__position._M_node->_M_prev))->_M_next = __first._M_node;
|
476
|
+
|
477
|
+
// Splice [first, last) into its new position.
|
478
|
+
_Node* __tmp = (_Node*) (__position._M_node->_M_prev);
|
479
|
+
__position._M_node->_M_prev = __last._M_node->_M_prev;
|
480
|
+
__last._M_node->_M_prev = __first._M_node->_M_prev;
|
481
|
+
__first._M_node->_M_prev = __tmp;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
public:
|
486
|
+
void splice(iterator __position, list& __x) {
|
487
|
+
if (!__x.empty())
|
488
|
+
transfer(__position, __x.begin(), __x.end());
|
489
|
+
}
|
490
|
+
void splice(iterator __position, list&, iterator __i) {
|
491
|
+
iterator __j = __i;
|
492
|
+
++__j;
|
493
|
+
if (__position == __i || __position == __j) return;
|
494
|
+
transfer(__position, __i, __j);
|
495
|
+
}
|
496
|
+
void splice(iterator __position, list&, iterator __first, iterator __last) {
|
497
|
+
if (__first != __last)
|
498
|
+
transfer(__position, __first, __last);
|
499
|
+
}
|
500
|
+
void remove(const _Tp& __value);
|
501
|
+
void unique();
|
502
|
+
void merge(list& __x);
|
503
|
+
void reverse();
|
504
|
+
void sort();
|
505
|
+
|
506
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
507
|
+
template <class _Predicate> void remove_if(_Predicate);
|
508
|
+
template <class _BinaryPredicate> void unique(_BinaryPredicate);
|
509
|
+
template <class _StrictWeakOrdering> void merge(list&, _StrictWeakOrdering);
|
510
|
+
template <class _StrictWeakOrdering> void sort(_StrictWeakOrdering);
|
511
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
512
|
+
|
513
|
+
friend bool operator== __STL_NULL_TMPL_ARGS (
|
514
|
+
const list& __x, const list& __y);
|
515
|
+
};
|
516
|
+
|
517
|
+
template <class _Tp, class _Alloc>
|
518
|
+
inline bool operator==(const list<_Tp,_Alloc>& __x,
|
519
|
+
const list<_Tp,_Alloc>& __y)
|
520
|
+
{
|
521
|
+
typedef typename list<_Tp,_Alloc>::_Node _Node;
|
522
|
+
_Node* __e1 = __x._M_node;
|
523
|
+
_Node* __e2 = __y._M_node;
|
524
|
+
_Node* __n1 = (_Node*) __e1->_M_next;
|
525
|
+
_Node* __n2 = (_Node*) __e2->_M_next;
|
526
|
+
for ( ; __n1 != __e1 && __n2 != __e2 ;
|
527
|
+
__n1 = (_Node*) __n1->_M_next, __n2 = (_Node*) __n2->_M_next)
|
528
|
+
if (__n1->_M_data != __n2->_M_data)
|
529
|
+
return false;
|
530
|
+
return __n1 == __e1 && __n2 == __e2;
|
531
|
+
}
|
532
|
+
|
533
|
+
template <class _Tp, class _Alloc>
|
534
|
+
inline bool operator<(const list<_Tp,_Alloc>& __x,
|
535
|
+
const list<_Tp,_Alloc>& __y)
|
536
|
+
{
|
537
|
+
return lexicographical_compare(__x.begin(), __x.end(),
|
538
|
+
__y.begin(), __y.end());
|
539
|
+
}
|
540
|
+
|
541
|
+
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
542
|
+
|
543
|
+
template <class _Tp, class _Alloc>
|
544
|
+
inline void
|
545
|
+
swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
|
546
|
+
{
|
547
|
+
__x.swap(__y);
|
548
|
+
}
|
549
|
+
|
550
|
+
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
|
551
|
+
|
552
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
553
|
+
|
554
|
+
template <class _Tp, class _Alloc> template <class _InputIter>
|
555
|
+
void
|
556
|
+
list<_Tp, _Alloc>::_M_insert_dispatch(iterator __position,
|
557
|
+
_InputIter __first, _InputIter __last,
|
558
|
+
__false_type)
|
559
|
+
{
|
560
|
+
for ( ; __first != __last; ++__first)
|
561
|
+
insert(__position, *__first);
|
562
|
+
}
|
563
|
+
|
564
|
+
#else /* __STL_MEMBER_TEMPLATES */
|
565
|
+
|
566
|
+
template <class _Tp, class _Alloc>
|
567
|
+
void
|
568
|
+
list<_Tp, _Alloc>::insert(iterator __position,
|
569
|
+
const _Tp* __first, const _Tp* __last)
|
570
|
+
{
|
571
|
+
for ( ; __first != __last; ++__first)
|
572
|
+
insert(__position, *__first);
|
573
|
+
}
|
574
|
+
|
575
|
+
template <class _Tp, class _Alloc>
|
576
|
+
void
|
577
|
+
list<_Tp, _Alloc>::insert(iterator __position,
|
578
|
+
const_iterator __first, const_iterator __last)
|
579
|
+
{
|
580
|
+
for ( ; __first != __last; ++__first)
|
581
|
+
insert(__position, *__first);
|
582
|
+
}
|
583
|
+
|
584
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
585
|
+
|
586
|
+
template <class _Tp, class _Alloc>
|
587
|
+
void
|
588
|
+
list<_Tp, _Alloc>::insert(iterator __position, size_type __n, const _Tp& __x)
|
589
|
+
{
|
590
|
+
for ( ; __n > 0; --__n)
|
591
|
+
insert(__position, __x);
|
592
|
+
}
|
593
|
+
|
594
|
+
template <class _Tp, class _Alloc>
|
595
|
+
typename
|
596
|
+
list<_Tp,_Alloc>::iterator list<_Tp, _Alloc>::erase(iterator __first,
|
597
|
+
iterator __last)
|
598
|
+
{
|
599
|
+
while (__first != __last)
|
600
|
+
erase(__first++);
|
601
|
+
return __last;
|
602
|
+
}
|
603
|
+
|
604
|
+
template <class _Tp, class _Alloc>
|
605
|
+
void list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x)
|
606
|
+
{
|
607
|
+
iterator __i = begin();
|
608
|
+
size_type __len = 0;
|
609
|
+
for ( ; __i != end() && __len < __new_size; ++__i, ++__len)
|
610
|
+
;
|
611
|
+
if (__len == __new_size)
|
612
|
+
erase(__i, end());
|
613
|
+
else // __i == end()
|
614
|
+
insert(end(), __new_size - __len, __x);
|
615
|
+
}
|
616
|
+
|
617
|
+
template <class _Tp, class _Alloc>
|
618
|
+
list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x)
|
619
|
+
{
|
620
|
+
if (this != &__x) {
|
621
|
+
iterator __first1 = begin();
|
622
|
+
iterator __last1 = end();
|
623
|
+
const_iterator __first2 = __x.begin();
|
624
|
+
const_iterator __last2 = __x.end();
|
625
|
+
while (__first1 != __last1 && __first2 != __last2)
|
626
|
+
*__first1++ = *__first2++;
|
627
|
+
if (__first2 == __last2)
|
628
|
+
erase(__first1, __last1);
|
629
|
+
else
|
630
|
+
insert(__last1, __first2, __last2);
|
631
|
+
}
|
632
|
+
return *this;
|
633
|
+
}
|
634
|
+
|
635
|
+
template <class _Tp, class _Alloc>
|
636
|
+
void list<_Tp, _Alloc>::assign(size_type __n, const _Tp& __val) {
|
637
|
+
iterator __i = begin();
|
638
|
+
for ( ; __i != end() && __n > 0; ++__i, --__n)
|
639
|
+
*__i = __val;
|
640
|
+
if (__n > 0)
|
641
|
+
insert(end(), __n, __val);
|
642
|
+
else
|
643
|
+
erase(__i, end());
|
644
|
+
}
|
645
|
+
|
646
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
647
|
+
|
648
|
+
template <class _Tp, class _Alloc> template <class _InputIter>
|
649
|
+
void
|
650
|
+
list<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first2, _InputIter __last2,
|
651
|
+
__false_type)
|
652
|
+
{
|
653
|
+
iterator __first1 = begin();
|
654
|
+
iterator __last1 = end();
|
655
|
+
for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
656
|
+
*__first1 = *__first2;
|
657
|
+
if (__first2 == __last2)
|
658
|
+
erase(__first1, __last1);
|
659
|
+
else
|
660
|
+
insert(__last1, __first2, __last2);
|
661
|
+
}
|
662
|
+
|
663
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
664
|
+
|
665
|
+
template <class _Tp, class _Alloc>
|
666
|
+
void list<_Tp, _Alloc>::remove(const _Tp& __value)
|
667
|
+
{
|
668
|
+
iterator __first = begin();
|
669
|
+
iterator __last = end();
|
670
|
+
while (__first != __last) {
|
671
|
+
iterator __next = __first;
|
672
|
+
++__next;
|
673
|
+
if (*__first == __value) erase(__first);
|
674
|
+
__first = __next;
|
675
|
+
}
|
676
|
+
}
|
677
|
+
|
678
|
+
template <class _Tp, class _Alloc>
|
679
|
+
void list<_Tp, _Alloc>::unique()
|
680
|
+
{
|
681
|
+
iterator __first = begin();
|
682
|
+
iterator __last = end();
|
683
|
+
if (__first == __last) return;
|
684
|
+
iterator __next = __first;
|
685
|
+
while (++__next != __last) {
|
686
|
+
if (*__first == *__next)
|
687
|
+
erase(__next);
|
688
|
+
else
|
689
|
+
__first = __next;
|
690
|
+
__next = __first;
|
691
|
+
}
|
692
|
+
}
|
693
|
+
|
694
|
+
template <class _Tp, class _Alloc>
|
695
|
+
void list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x)
|
696
|
+
{
|
697
|
+
iterator __first1 = begin();
|
698
|
+
iterator __last1 = end();
|
699
|
+
iterator __first2 = __x.begin();
|
700
|
+
iterator __last2 = __x.end();
|
701
|
+
while (__first1 != __last1 && __first2 != __last2)
|
702
|
+
if (*__first2 < *__first1) {
|
703
|
+
iterator __next = __first2;
|
704
|
+
transfer(__first1, __first2, ++__next);
|
705
|
+
__first2 = __next;
|
706
|
+
}
|
707
|
+
else
|
708
|
+
++__first1;
|
709
|
+
if (__first2 != __last2) transfer(__last1, __first2, __last2);
|
710
|
+
}
|
711
|
+
|
712
|
+
template <class _Tp, class _Alloc>
|
713
|
+
void list<_Tp, _Alloc>::reverse()
|
714
|
+
{
|
715
|
+
// Do nothing if the list has length 0 or 1.
|
716
|
+
if (_M_node->_M_next != _M_node &&
|
717
|
+
((_Node*) (_M_node->_M_next))->_M_next != _M_node) {
|
718
|
+
iterator __first = begin();
|
719
|
+
++__first;
|
720
|
+
while (__first != end()) {
|
721
|
+
iterator __old = __first;
|
722
|
+
++__first;
|
723
|
+
transfer(begin(), __old, __first);
|
724
|
+
}
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
template <class _Tp, class _Alloc>
|
729
|
+
void list<_Tp, _Alloc>::sort()
|
730
|
+
{
|
731
|
+
// Do nothing if the list has length 0 or 1.
|
732
|
+
if (_M_node->_M_next != _M_node &&
|
733
|
+
((_Node*) (_M_node->_M_next))->_M_next != _M_node) {
|
734
|
+
list<_Tp, _Alloc> __carry;
|
735
|
+
list<_Tp, _Alloc> __counter[64];
|
736
|
+
int __fill = 0;
|
737
|
+
while (!empty()) {
|
738
|
+
__carry.splice(__carry.begin(), *this, begin());
|
739
|
+
int __i = 0;
|
740
|
+
while(__i < __fill && !__counter[__i].empty()) {
|
741
|
+
__counter[__i].merge(__carry);
|
742
|
+
__carry.swap(__counter[__i++]);
|
743
|
+
}
|
744
|
+
__carry.swap(__counter[__i]);
|
745
|
+
if (__i == __fill) ++__fill;
|
746
|
+
}
|
747
|
+
|
748
|
+
for (int __i = 1; __i < __fill; ++__i)
|
749
|
+
__counter[__i].merge(__counter[__i-1]);
|
750
|
+
swap(__counter[__fill-1]);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
|
754
|
+
#ifdef __STL_MEMBER_TEMPLATES
|
755
|
+
|
756
|
+
template <class _Tp, class _Alloc> template <class _Predicate>
|
757
|
+
void list<_Tp, _Alloc>::remove_if(_Predicate __pred)
|
758
|
+
{
|
759
|
+
iterator __first = begin();
|
760
|
+
iterator __last = end();
|
761
|
+
while (__first != __last) {
|
762
|
+
iterator __next = __first;
|
763
|
+
++__next;
|
764
|
+
if (__pred(*__first)) erase(__first);
|
765
|
+
__first = __next;
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
template <class _Tp, class _Alloc> template <class _BinaryPredicate>
|
770
|
+
void list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
|
771
|
+
{
|
772
|
+
iterator __first = begin();
|
773
|
+
iterator __last = end();
|
774
|
+
if (__first == __last) return;
|
775
|
+
iterator __next = __first;
|
776
|
+
while (++__next != __last) {
|
777
|
+
if (__binary_pred(*__first, *__next))
|
778
|
+
erase(__next);
|
779
|
+
else
|
780
|
+
__first = __next;
|
781
|
+
__next = __first;
|
782
|
+
}
|
783
|
+
}
|
784
|
+
|
785
|
+
template <class _Tp, class _Alloc> template <class _StrictWeakOrdering>
|
786
|
+
void list<_Tp, _Alloc>::merge(list<_Tp, _Alloc>& __x,
|
787
|
+
_StrictWeakOrdering __comp)
|
788
|
+
{
|
789
|
+
iterator __first1 = begin();
|
790
|
+
iterator __last1 = end();
|
791
|
+
iterator __first2 = __x.begin();
|
792
|
+
iterator __last2 = __x.end();
|
793
|
+
while (__first1 != __last1 && __first2 != __last2)
|
794
|
+
if (__comp(*__first2, *__first1)) {
|
795
|
+
iterator __next = __first2;
|
796
|
+
transfer(__first1, __first2, ++__next);
|
797
|
+
__first2 = __next;
|
798
|
+
}
|
799
|
+
else
|
800
|
+
++__first1;
|
801
|
+
if (__first2 != __last2) transfer(__last1, __first2, __last2);
|
802
|
+
}
|
803
|
+
|
804
|
+
template <class _Tp, class _Alloc> template <class _StrictWeakOrdering>
|
805
|
+
void list<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp)
|
806
|
+
{
|
807
|
+
// Do nothing if the list has length 0 or 1.
|
808
|
+
if (_M_node->_M_next != _M_node &&
|
809
|
+
((_Node*) (_M_node->_M_next))->_M_next != _M_node) {
|
810
|
+
list<_Tp, _Alloc> __carry;
|
811
|
+
list<_Tp, _Alloc> __counter[64];
|
812
|
+
int __fill = 0;
|
813
|
+
while (!empty()) {
|
814
|
+
__carry.splice(__carry.begin(), *this, begin());
|
815
|
+
int __i = 0;
|
816
|
+
while(__i < __fill && !__counter[__i].empty()) {
|
817
|
+
__counter[__i].merge(__carry, __comp);
|
818
|
+
__carry.swap(__counter[__i++]);
|
819
|
+
}
|
820
|
+
__carry.swap(__counter[__i]);
|
821
|
+
if (__i == __fill) ++__fill;
|
822
|
+
}
|
823
|
+
|
824
|
+
for (int __i = 1; __i < __fill; ++__i)
|
825
|
+
__counter[__i].merge(__counter[__i-1], __comp);
|
826
|
+
swap(__counter[__fill-1]);
|
827
|
+
}
|
828
|
+
}
|
829
|
+
|
830
|
+
#endif /* __STL_MEMBER_TEMPLATES */
|
831
|
+
|
832
|
+
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
833
|
+
#pragma reset woff 1174
|
834
|
+
#pragma reset woff 1375
|
835
|
+
#endif
|
836
|
+
|
837
|
+
__STL_END_NAMESPACE
|
838
|
+
|
839
|
+
#endif /* __SGI_STL_INTERNAL_LIST_H */
|
840
|
+
|
841
|
+
// Local Variables:
|
842
|
+
// mode:C++
|
843
|
+
// End:
|