This file is indexed.

/usr/include/stxxl/bits/containers/deque.h is in libstxxl-dev 1.3.1-5ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
/***************************************************************************
 *  include/stxxl/bits/containers/deque.h
 *
 *  Part of the STXXL. See http://stxxl.sourceforge.net
 *
 *  Copyright (C) 2006 Roman Dementiev <dementiev@ira.uka.de>
 *  Copyright (C) 2008, 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
 *
 *  Distributed under the Boost Software License, Version 1.0.
 *  (See accompanying file LICENSE_1_0.txt or copy at
 *  http://www.boost.org/LICENSE_1_0.txt)
 **************************************************************************/

#ifndef _STXXL_DEQUE_H
#define _STXXL_DEQUE_H

#include <limits>
#include <stxxl/vector>


__STXXL_BEGIN_NAMESPACE

template <class T, class VectorType>
class deque;

template <class DequeType>
class const_deque_iterator;

template <class DequeType>
class deque_iterator
{
    typedef typename DequeType::size_type size_type;
    typedef typename DequeType::vector_type vector_type;
    typedef deque_iterator<DequeType> _Self;
    DequeType * Deque;
    size_type Offset;

    deque_iterator(DequeType * Deque_, size_type Offset_) :
        Deque(Deque_), Offset(Offset_)
    { }

    friend class const_deque_iterator<DequeType>;

public:
    typedef typename DequeType::value_type value_type;
    typedef typename DequeType::pointer pointer;
    typedef typename DequeType::const_pointer const_pointer;
    typedef typename DequeType::reference reference;
    typedef typename DequeType::const_reference const_reference;
    typedef deque_iterator<DequeType> iterator;
    typedef const_deque_iterator<DequeType> const_iterator;
    friend class deque<value_type, vector_type>;
    typedef std::random_access_iterator_tag iterator_category;
    typedef typename DequeType::difference_type difference_type;

    deque_iterator() : Deque(NULL), Offset(0) { }

    difference_type operator - (const _Self & a) const
    {
        size_type SelfAbsOffset = (Offset >= Deque->begin_o) ?
                                  Offset : (Deque->Vector.size() + Offset);
        size_type aAbsOffset = (a.Offset >= Deque->begin_o) ?
                               a.Offset : (Deque->Vector.size() + a.Offset);

        return SelfAbsOffset - aAbsOffset;
    }

    difference_type operator - (const const_iterator & a) const
    {
        size_type SelfAbsOffset = (Offset >= Deque->begin_o) ?
                                  Offset : (Deque->Vector.size() + Offset);
        size_type aAbsOffset = (a.Offset >= Deque->begin_o) ?
                               a.Offset : (Deque->Vector.size() + a.Offset);

        return SelfAbsOffset - aAbsOffset;
    }

    _Self operator - (size_type op) const
    {
        return _Self(Deque, (Offset + Deque->Vector.size() - op) % Deque->Vector.size());
    }

    _Self operator + (size_type op) const
    {
        return _Self(Deque, (Offset + op) % Deque->Vector.size());
    }

    _Self & operator -= (size_type op)
    {
        Offset = (Offset + Deque->Vector.size() - op) % Deque->Vector.size();
        return *this;
    }

    _Self & operator += (size_type op)
    {
        Offset = (Offset + op) % Deque->Vector.size();
        return *this;
    }

    reference operator * ()
    {
        return Deque->Vector[Offset];
    }

    pointer operator -> ()
    {
        return &(Deque->Vector[Offset]);
    }

    const_reference operator * () const
    {
        return Deque->Vector[Offset];
    }

    const_pointer operator -> () const
    {
        return &(Deque->Vector[Offset]);
    }

    reference operator [] (size_type op)
    {
        return Deque->Vector[(Offset + op) % Deque->Vector.size()];
    }

    const_reference operator [] (size_type op) const
    {
        return Deque->Vector[(Offset + op) % Deque->Vector.size()];
    }

    _Self & operator ++ ()
    {
        Offset = (Offset + 1) % Deque->Vector.size();
        return *this;
    }
    _Self operator ++ (int)
    {
        _Self __tmp = *this;
        Offset = (Offset + 1) % Deque->Vector.size();
        return __tmp;
    }
    _Self & operator -- ()
    {
        Offset = (Offset + Deque->Vector.size() - 1) % Deque->Vector.size();
        return *this;
    }
    _Self operator -- (int)
    {
        _Self __tmp = *this;
        Offset = (Offset + Deque->Vector.size() - 1) % Deque->Vector.size();
        return __tmp;
    }
    bool operator == (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return Offset == a.Offset;
    }
    bool operator != (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return Offset != a.Offset;
    }

    bool operator < (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return (a - (*this)) > 0;
    }

    bool operator > (const _Self & a) const
    {
        return a < (*this);
    }

    bool operator <= (const _Self & a) const
    {
        return !((*this) > a);
    }

    bool operator >= (const _Self & a) const
    {
        return !((*this) < a);
    }

    bool operator == (const const_iterator & a) const
    {
        assert(Deque == a.Deque);
        return Offset == a.Offset;
    }
    bool operator != (const const_iterator & a) const
    {
        assert(Deque == a.Deque);
        return Offset != a.Offset;
    }

    bool operator < (const const_iterator & a) const
    {
        assert(Deque == a.Deque);
        return (a - (*this)) > 0;
    }

    bool operator > (const const_iterator & a) const
    {
        return a < (*this);
    }

    bool operator <= (const const_iterator & a) const
    {
        return !((*this) > a);
    }

    bool operator >= (const const_iterator & a) const
    {
        return !((*this) < a);
    }
};

template <class DequeType>
class const_deque_iterator
{
    typedef const_deque_iterator<DequeType> _Self;
    typedef typename DequeType::size_type size_type;
    typedef typename DequeType::vector_type vector_type;
    const DequeType * Deque;
    size_type Offset;

    const_deque_iterator(const DequeType * Deque_, size_type Offset_) :
        Deque(Deque_), Offset(Offset_)
    { }

public:
    typedef typename DequeType::value_type value_type;
    typedef typename DequeType::const_pointer pointer;
    typedef typename DequeType::const_pointer const_pointer;
    typedef typename DequeType::const_reference reference;
    typedef typename DequeType::const_reference const_reference;
    typedef deque_iterator<DequeType> iterator;
    typedef const_deque_iterator<DequeType> const_iterator;
    friend class deque<value_type, vector_type>;
    friend class deque_iterator<DequeType>;

    typedef std::random_access_iterator_tag iterator_category;
    typedef typename DequeType::difference_type difference_type;

    const_deque_iterator() : Deque(NULL), Offset(0) { }
    const_deque_iterator(const deque_iterator<DequeType> & it) :
        Deque(it.Deque), Offset(it.Offset)
    { }

    difference_type operator - (const _Self & a) const
    {
        size_type SelfAbsOffset = (Offset >= Deque->begin_o) ?
                                  Offset : (Deque->Vector.size() + Offset);
        size_type aAbsOffset = (a.Offset >= Deque->begin_o) ?
                               a.Offset : (Deque->Vector.size() + a.Offset);

        return SelfAbsOffset - aAbsOffset;
    }

    difference_type operator - (const iterator & a) const
    {
        size_type SelfAbsOffset = (Offset >= Deque->begin_o) ?
                                  Offset : (Deque->Vector.size() + Offset);
        size_type aAbsOffset = (a.Offset >= Deque->begin_o) ?
                               a.Offset : (Deque->Vector.size() + a.Offset);

        return SelfAbsOffset - aAbsOffset;
    }

    _Self operator - (size_type op) const
    {
        return _Self(Deque, (Offset + Deque->Vector.size() - op) % Deque->Vector.size());
    }

    _Self operator + (size_type op) const
    {
        return _Self(Deque, (Offset + op) % Deque->Vector.size());
    }

    _Self & operator -= (size_type op)
    {
        Offset = (Offset + Deque->Vector.size() - op) % Deque->Vector.size();
        return *this;
    }

    _Self & operator += (size_type op)
    {
        Offset = (Offset + op) % Deque->Vector.size();
        return *this;
    }

    const_reference operator * () const
    {
        return Deque->Vector[Offset];
    }

    const_pointer operator -> () const
    {
        return &(Deque->Vector[Offset]);
    }

    const_reference operator [] (size_type op) const
    {
        return Deque->Vector[(Offset + op) % Deque->Vector.size()];
    }

    _Self & operator ++ ()
    {
        Offset = (Offset + 1) % Deque->Vector.size();
        return *this;
    }
    _Self operator ++ (int)
    {
        _Self __tmp = *this;
        Offset = (Offset + 1) % Deque->Vector.size();
        return __tmp;
    }
    _Self & operator -- ()
    {
        Offset = (Offset + Deque->Vector.size() - 1) % Deque->Vector.size();
        return *this;
    }
    _Self operator -- (int)
    {
        _Self __tmp = *this;
        Offset = (Offset + Deque->Vector.size() - 1) % Deque->Vector.size();
        return __tmp;
    }
    bool operator == (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return Offset == a.Offset;
    }
    bool operator != (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return Offset != a.Offset;
    }

    bool operator < (const _Self & a) const
    {
        assert(Deque == a.Deque);
        return (a - (*this)) > 0;
    }

    bool operator > (const _Self & a) const
    {
        return a < (*this);
    }

    bool operator <= (const _Self & a) const
    {
        return !((*this) > a);
    }

    bool operator >= (const _Self & a) const
    {
        return !((*this) < a);
    }

    bool operator == (const iterator & a) const
    {
        assert(Deque == a.Deque);
        return Offset == a.Offset;
    }
    bool operator != (const iterator & a) const
    {
        assert(Deque == a.Deque);
        return Offset != a.Offset;
    }

    bool operator < (const iterator & a) const
    {
        assert(Deque == a.Deque);
        return (a - (*this)) > 0;
    }

    bool operator > (const iterator & a) const
    {
        return a < (*this);
    }

    bool operator <= (const iterator & a) const
    {
        return !((*this) > a);
    }

    bool operator >= (const iterator & a) const
    {
        return !((*this) < a);
    }
};

//! \addtogroup stlcont
//! \{

//! \brief A deque container
//!
//! It is an adaptor of the \c VectorType.
//! The implementation wraps the elements around
//! the end of the \c VectorType circularly.
//! \tparam T type of the contained objects (POD with no references to internal memory)
//! \tparam VectorType the type of the underlying vector container,
//! the default is \c stxxl::vector<T>
template <class T, class VectorType = stxxl::vector<T> >
class deque : private noncopyable
{
    typedef deque<T, VectorType> Self_;

public:
    typedef typename VectorType::size_type size_type;
    typedef typename VectorType::difference_type difference_type;
    typedef VectorType vector_type;
    typedef T value_type;
    typedef T * pointer;
    typedef const value_type * const_pointer;
    typedef T & reference;
    typedef const T & const_reference;
    typedef deque_iterator<Self_> iterator;
    typedef const_deque_iterator<Self_> const_iterator;
    typedef std::reverse_iterator<iterator> reverse_iterator;
    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

    friend class deque_iterator<Self_>;
    friend class const_deque_iterator<Self_>;

private:
    VectorType Vector;
    size_type begin_o, end_o, size_;

    void double_array()
    {
        const size_type old_size = Vector.size();
        Vector.resize(2 * old_size);
        if (begin_o > end_o)
        {                         // copy data to the new end of the vector
            const size_type new_begin_o = old_size + begin_o;
            std::copy(Vector.begin() + begin_o,
                      Vector.begin() + old_size,
                      Vector.begin() + new_begin_o);
            begin_o = new_begin_o;
        }
    }

public:
    deque() : Vector((STXXL_DEFAULT_BLOCK_SIZE(T)) / sizeof(T)), begin_o(0), end_o(0), size_(0)
    { }

    deque(size_type n)
        : Vector(STXXL_MAX<size_type>(STXXL_DEFAULT_BLOCK_SIZE(T) / sizeof(T), 2 * n)),
          begin_o(0), end_o(n), size_(n)
    { }

    ~deque()      // empty so far
    { }

    iterator begin()
    {
        return iterator(this, begin_o);
    }
    iterator end()
    {
        return iterator(this, end_o);
    }
    const_iterator begin() const
    {
        return const_iterator(this, begin_o);
    }
    const_iterator cbegin() const
    {
        return begin();
    }
    const_iterator end() const
    {
        return const_iterator(this, end_o);
    }
    const_iterator cend() const
    {
        return end();
    }

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

    size_type size() const
    {
        return size_;
    }

    size_type max_size() const
    {
        return (std::numeric_limits<size_type>::max)() / 2 - 1;
    }

    bool empty() const
    {
        return size_ == 0;
    }

    reference operator [] (size_type n)
    {
        assert(n < size());
        return Vector[(begin_o + n) % Vector.size()];
    }

    const_reference operator [] (size_type n) const
    {
        assert(n < size());
        return Vector[(begin_o + n) % Vector.size()];
    }

    reference front()
    {
        assert(!empty());
        return Vector[begin_o];
    }

    const_reference front() const
    {
        assert(!empty());
        return Vector[begin_o];
    }

    reference back()
    {
        assert(!empty());
        return Vector[(end_o + Vector.size() - 1) % Vector.size()];
    }

    const_reference back() const
    {
        assert(!empty());
        return Vector[(end_o + Vector.size() - 1) % Vector.size()];
    }

    void push_front(const T & el)
    {
        if ((begin_o + Vector.size() - 1) % Vector.size() == end_o)
        {
            // an overflow will occur: resize the array
            double_array();
        }

        begin_o = (begin_o + Vector.size() - 1) % Vector.size();
        Vector[begin_o] = el;
        ++size_;
    }

    void push_back(const T & el)
    {
        if ((end_o + 1) % Vector.size() == begin_o)
        {
            // an overflow will occur: resize the array
            double_array();
        }
        Vector[end_o] = el;
        end_o = (end_o + 1) % Vector.size();
        ++size_;
    }

    void pop_front()
    {
        assert(!empty());
        begin_o = (begin_o + 1) % Vector.size();
        --size_;
    }

    void pop_back()
    {
        assert(!empty());
        end_o = (end_o + Vector.size() - 1) % Vector.size();
        --size_;
    }

    void swap(deque & obj)
    {
        std::swap(Vector, obj.Vector);
        std::swap(begin_o, obj.begin_o);
        std::swap(end_o, obj.end_o);
        std::swap(size_, obj.size_);
    }

    void clear()
    {
        Vector.clear();
        Vector.resize((STXXL_DEFAULT_BLOCK_SIZE(T)) / sizeof(T));
        begin_o = 0;
        end_o = 0;
        size_ = 0;
    }

    void resize(size_type n)
    {
        if (n < size())
        {
            do
            {
                pop_back();
            } while (n < size());
        }
        else
        {
            if (n + 1 > Vector.size())
            {                             // need to resize
                const size_type old_size = Vector.size();
                Vector.resize(2 * n);
                if (begin_o > end_o)
                {                         // copy data to the new end of the vector
                    const size_type new_begin_o = Vector.size() - old_size + begin_o;
                    std::copy(Vector.begin() + begin_o,
                              Vector.begin() + old_size,
                              Vector.begin() + new_begin_o);
                    begin_o = new_begin_o;
                }
            }
            end_o = (end_o + n - size()) % Vector.size();
            size_ = n;
        }
    }
};

template <class T, class VectorType>
bool operator == (const deque<T, VectorType> & a, const deque<T, VectorType> & b)
{
    return std::equal(a.begin(), a.end(), b.begin());
}

template <class T, class VectorType>
bool operator < (const deque<T, VectorType> & a, const deque<T, VectorType> & b)
{
    return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
}

//! \}

__STXXL_END_NAMESPACE

namespace std
{
    template <typename T, typename VT>
    void swap(stxxl::deque<T, VT> & a,
              stxxl::deque<T, VT> & b)
    {
        a.swap(b);
    }
}

#endif /* _STXXL_DEQUE_H */