This file is indexed.

/usr/include/jellyfish/simple_circular_buffer.hpp is in libjellyfish-2.0-dev 2.2.8-3build1.

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
/* Jellyfish
 * Copyright (C) 2012  Genome group at University of Maryland.
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __SIMPLE_CIRCULAR_BUFFER_H__
#define __SIMPLE_CIRCULAR_BUFFER_H__

#include <memory>

namespace jellyfish {
  namespace simple_circular_buffer {

    // T: type of element in container. D: type of derived class for
    // CRTP. A: allocator type.
    template<typename T, typename D>
    class base {
    public:
      explicit base(T* data) :
        data_(data), front_(0), back_(0), full_(false)
      { }

      // Return true if empty
      bool empty() const {
        return front_ == back_ && !full();
      }
      // Return true if full
      bool full() const {
        return full_;
      }
      void clear() {
        front_ = back_;
        full_  = false;
      }

      // Valid only if empty() is false
      T& front() {
        return data_[front_];
      }
      // Valid only if empty() is false
      T& back() {
        return data_[prev_index(back_)];
      }

      // Unlike the corresponding method on list or deqeue, push_back may
      // fail if full() is true. Then false is returned.
      bool push_back(const T& x) {
        if(full())
          return false;
        data_[back_] = x;
        back_        = next_index(back_);
        full_        = back_ == front_;
        return true;
      }

      bool push_back() {
        if(full())
          return false;
        back_ = next_index(back_);
        full_ = back_ == front_;
        return true;
      }

      // Pop an element from the front. It has no effect if empty() is true
      void pop_front() {
        if(empty())
          return;
        front_ = next_index(front_);
        full_  = false;
      }

      int size() const {
        if(full())
          return static_cast<const D*>(this)->capacity();
        int s = back_ - front_;
        return s < 0 ? s + static_cast<const D*>(this)->capacity() : s;
      }

    protected:
      int next_index(int i) const {
        return (i + 1) % static_cast<const D*>(this)->capacity();
      }
      int prev_index(int i) const {
        return i ? i - 1 : static_cast<const D*>(this)->capacity() - 1;
      }
      T* data() const { return data_; }

      T*   data_;
      int  front_, back_;
      bool full_;
    };

    template<typename T, int capa>
    class pre_alloc : public base<T, pre_alloc<T, capa> > {
      typedef base<T, pre_alloc<T, capa> > super;
    public:
      static const int capacityConstant = capa;
      explicit pre_alloc(T* data) : super(data) { }
      static int capacity() { return capa; }
    };

    // template<typename T, int capa, typename A = std::allocator<T> >
    // class fixed : public base<T, fixed<T, capa, A>, A> {
    //   typedef base<T, fixed<T, capa, A>, A> super;
    // public:
    //   explicit fixed(const T v = T()) : super(capa, v) { }
    //   //    fixed(const int ignored_size, const T v = T()) : super(capa, v) { }

    //   int capacity() const { return capa; }
    // };

    // template<typename T, typename A = std::allocator<T> >
    // class dyn : public base<T, dyn<T, A>, A> {
    //   typedef base<T, dyn<T, A>, A> super;
    // public:
    //   explicit dyn(int size, const T v = T()) : super(size, v), capa_(size) { }

    //   int capacity() const { return capa_; }
    //   int capa_;
    // };
  }
}
#endif /* __SIMPLE_CIRCULAR_BUFFER_H__ */