OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [include/] [profile/] [deque] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Profiling deque implementation -*- C++ -*-
2
 
3
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 3, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// Under Section 7 of GPL version 3, you are granted additional
17
// permissions described in the GCC Runtime Library Exception, version
18
// 3.1, as published by the Free Software Foundation.
19
 
20
// You should have received a copy of the GNU General Public License and
21
// a copy of the GCC Runtime Library Exception along with this program;
22
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
// .
24
 
25
/** @file profile/deque
26
 *  This file is a GNU profile extension to the Standard C++ Library.
27
 */
28
 
29
#ifndef _GLIBCXX_PROFILE_DEQUE
30
#define _GLIBCXX_PROFILE_DEQUE 1
31
 
32
#include 
33
 
34
namespace std
35
{
36
namespace __profile
37
{
38
  /// Class std::deque wrapper with performance instrumentation.
39
  template >
40
    class deque
41
    : public _GLIBCXX_STD_D::deque<_Tp, _Allocator>
42
    {
43
      typedef  _GLIBCXX_STD_D::deque<_Tp, _Allocator> _Base;
44
 
45
    public:
46
      typedef typename _Base::reference             reference;
47
      typedef typename _Base::const_reference       const_reference;
48
 
49
      typedef typename _Base::iterator             iterator;
50
      typedef typename _Base::const_iterator       const_iterator;
51
      typedef typename _Base::reverse_iterator     reverse_iterator;
52
      typedef typename _Base::const_reverse_iterator const_reverse_iterator;
53
 
54
      typedef typename _Base::size_type             size_type;
55
      typedef typename _Base::difference_type       difference_type;
56
 
57
      typedef _Tp                                   value_type;
58
      typedef _Allocator                            allocator_type;
59
      typedef typename _Base::pointer               pointer;
60
      typedef typename _Base::const_pointer         const_pointer;
61
 
62
      // 23.2.1.1 construct/copy/destroy:
63
      explicit deque(const _Allocator& __a = _Allocator())
64
      : _Base(__a) { }
65
 
66
      explicit deque(size_type __n, const _Tp& __value = _Tp(),
67
                     const _Allocator& __a = _Allocator())
68
      : _Base(__n, __value, __a) { }
69
 
70
      template
71
        deque(_InputIterator __first, _InputIterator __last,
72
              const _Allocator& __a = _Allocator())
73
        : _Base(__first, __last, __a)
74
        { }
75
 
76
      deque(const deque& __x)
77
      : _Base(__x) { }
78
 
79
      deque(const _Base& __x)
80
      : _Base(__x) { }
81
 
82
#ifdef __GXX_EXPERIMENTAL_CXX0X__
83
      deque(deque&& __x)
84
      : _Base(std::forward(__x))
85
      { }
86
 
87
      deque(initializer_list __l,
88
            const allocator_type& __a = allocator_type())
89
      : _Base(__l, __a) { }
90
#endif
91
 
92
      ~deque() { }
93
 
94
      deque&
95
      operator=(const deque& __x)
96
      {
97
        *static_cast<_Base*>(this) = __x;
98
        return *this;
99
      }
100
 
101
#ifdef __GXX_EXPERIMENTAL_CXX0X__
102
      deque&
103
      operator=(deque&& __x)
104
      {
105
        // NB: DR 1204.
106
        // NB: DR 675.
107
        this->clear();
108
        this->swap(__x);
109
        return *this;
110
      }
111
 
112
      deque&
113
      operator=(initializer_list __l)
114
      {
115
        *static_cast<_Base*>(this) = __l;
116
        return *this;
117
      }
118
#endif
119
 
120
      template
121
        void
122
        assign(_InputIterator __first, _InputIterator __last)
123
        {
124
          _Base::assign(__first, __last);
125
        }
126
 
127
      void
128
      assign(size_type __n, const _Tp& __t)
129
      {
130
        _Base::assign(__n, __t);
131
      }
132
 
133
#ifdef __GXX_EXPERIMENTAL_CXX0X__
134
      void
135
      assign(initializer_list __l)
136
      {
137
        _Base::assign(__l);
138
      }
139
#endif
140
 
141
      using _Base::get_allocator;
142
 
143
      // iterators:
144
      iterator
145
      begin()
146
      { return iterator(_Base::begin()); }
147
 
148
      const_iterator
149
      begin() const
150
      { return const_iterator(_Base::begin()); }
151
 
152
      iterator
153
      end()
154
      { return iterator(_Base::end()); }
155
 
156
      const_iterator
157
      end() const
158
      { return const_iterator(_Base::end()); }
159
 
160
      reverse_iterator
161
      rbegin()
162
      { return reverse_iterator(end()); }
163
 
164
      const_reverse_iterator
165
      rbegin() const
166
      { return const_reverse_iterator(end()); }
167
 
168
      reverse_iterator
169
      rend()
170
      { return reverse_iterator(begin()); }
171
 
172
      const_reverse_iterator
173
      rend() const
174
      { return const_reverse_iterator(begin()); }
175
 
176
#ifdef __GXX_EXPERIMENTAL_CXX0X__
177
      const_iterator
178
      cbegin() const
179
      { return const_iterator(_Base::begin()); }
180
 
181
      const_iterator
182
      cend() const
183
      { return const_iterator(_Base::end()); }
184
 
185
      const_reverse_iterator
186
      crbegin() const
187
      { return const_reverse_iterator(end()); }
188
 
189
      const_reverse_iterator
190
      crend() const
191
      { return const_reverse_iterator(begin()); }
192
#endif
193
 
194
      // 23.2.1.2 capacity:
195
      using _Base::size;
196
      using _Base::max_size;
197
 
198
      void
199
      resize(size_type __sz, _Tp __c = _Tp())
200
      {
201
        _Base::resize(__sz, __c);
202
      }
203
 
204
#ifdef __GXX_EXPERIMENTAL_CXX0X__
205
      using _Base::shrink_to_fit;
206
#endif
207
 
208
      using _Base::empty;
209
 
210
      // element access:
211
      reference
212
      operator[](size_type __n)
213
      {
214
        return _M_base()[__n];
215
      }
216
 
217
      const_reference
218
      operator[](size_type __n) const
219
      {
220
        return _M_base()[__n];
221
      }
222
 
223
      using _Base::at;
224
 
225
      reference
226
      front()
227
      {
228
        return _Base::front();
229
      }
230
 
231
      const_reference
232
      front() const
233
      {
234
        return _Base::front();
235
      }
236
 
237
      reference
238
      back()
239
      {
240
        return _Base::back();
241
      }
242
 
243
      const_reference
244
      back() const
245
      {
246
        return _Base::back();
247
      }
248
 
249
      // 23.2.1.3 modifiers:
250
      void
251
      push_front(const _Tp& __x)
252
      {
253
        _Base::push_front(__x);
254
      }
255
 
256
      void
257
      push_back(const _Tp& __x)
258
      {
259
        _Base::push_back(__x);
260
      }
261
 
262
#ifdef __GXX_EXPERIMENTAL_CXX0X__
263
      void
264
      push_front(_Tp&& __x)
265
      { emplace_front(std::move(__x)); }
266
 
267
      void
268
      push_back(_Tp&& __x)
269
      { emplace_back(std::move(__x)); }
270
 
271
      template
272
        void
273
        emplace_front(_Args&&... __args)
274
        {
275
          _Base::emplace_front(std::forward<_Args>(__args)...);
276
        }
277
 
278
      template
279
        void
280
        emplace_back(_Args&&... __args)
281
        {
282
          _Base::emplace_back(std::forward<_Args>(__args)...);
283
        }
284
 
285
      template
286
        iterator
287
        emplace(iterator __position, _Args&&... __args)
288
        {
289
          typename _Base::iterator __res = _Base::emplace(__position,
290
                                            std::forward<_Args>(__args)...);
291
          return iterator(__res);
292
        }
293
#endif
294
 
295
      iterator
296
      insert(iterator __position, const _Tp& __x)
297
      {
298
        typename _Base::iterator __res = _Base::insert(__position, __x);
299
        return iterator(__res);
300
      }
301
 
302
#ifdef __GXX_EXPERIMENTAL_CXX0X__
303
      iterator
304
      insert(iterator __position, _Tp&& __x)
305
      { return emplace(__position, std::move(__x)); }
306
 
307
      void
308
      insert(iterator __p, initializer_list __l)
309
      {
310
        _Base::insert(__p, __l);
311
      }
312
#endif
313
 
314
      void
315
      insert(iterator __position, size_type __n, const _Tp& __x)
316
      {
317
        _Base::insert(__position, __n, __x);
318
      }
319
 
320
      template
321
        void
322
        insert(iterator __position,
323
               _InputIterator __first, _InputIterator __last)
324
        {
325
          _Base::insert(__position, __first, __last);
326
        }
327
 
328
      void
329
      pop_front()
330
      {
331
        _Base::pop_front();
332
      }
333
 
334
      void
335
      pop_back()
336
      {
337
        _Base::pop_back();
338
      }
339
 
340
      iterator
341
      erase(iterator __position)
342
      {
343
        if (__position == begin() || __position == end()-1)
344
          {
345
            return iterator(_Base::erase(__position));
346
          }
347
        else
348
          {
349
            typename _Base::iterator __res = _Base::erase(__position);
350
            return iterator(__res);
351
          }
352
      }
353
 
354
      iterator
355
      erase(iterator __first, iterator __last)
356
      {
357
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
358
        // 151. can't currently clear() empty container
359
        return iterator(_Base::erase(__first, __last));
360
      }
361
 
362
      void
363
      swap(deque& __x)
364
      {
365
        _Base::swap(__x);
366
      }
367
 
368
      void
369
      clear()
370
      {
371
        _Base::clear();
372
      }
373
 
374
      _Base&
375
      _M_base()       { return *this; }
376
 
377
      const _Base&
378
      _M_base() const { return *this; }
379
    };
380
 
381
  template
382
    inline bool
383
    operator==(const deque<_Tp, _Alloc>& __lhs,
384
               const deque<_Tp, _Alloc>& __rhs)
385
    { return __lhs._M_base() == __rhs._M_base(); }
386
 
387
  template
388
    inline bool
389
    operator!=(const deque<_Tp, _Alloc>& __lhs,
390
               const deque<_Tp, _Alloc>& __rhs)
391
    { return __lhs._M_base() != __rhs._M_base(); }
392
 
393
  template
394
    inline bool
395
    operator<(const deque<_Tp, _Alloc>& __lhs,
396
              const deque<_Tp, _Alloc>& __rhs)
397
    { return __lhs._M_base() < __rhs._M_base(); }
398
 
399
  template
400
    inline bool
401
    operator<=(const deque<_Tp, _Alloc>& __lhs,
402
               const deque<_Tp, _Alloc>& __rhs)
403
    { return __lhs._M_base() <= __rhs._M_base(); }
404
 
405
  template
406
    inline bool
407
    operator>=(const deque<_Tp, _Alloc>& __lhs,
408
               const deque<_Tp, _Alloc>& __rhs)
409
    { return __lhs._M_base() >= __rhs._M_base(); }
410
 
411
  template
412
    inline bool
413
    operator>(const deque<_Tp, _Alloc>& __lhs,
414
              const deque<_Tp, _Alloc>& __rhs)
415
    { return __lhs._M_base() > __rhs._M_base(); }
416
 
417
  template
418
    inline void
419
    swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
420
    { __lhs.swap(__rhs); }
421
 
422
} // namespace __profile
423
} // namespace std
424
 
425
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.