This file is indexed.

/usr/include/raul/Table.hpp is in libraul-dev 0.8.0+dfsg0-0.1.

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
/* This file is part of Raul.
 * Copyright (C) 2007-2009 David Robillard <http://drobilla.net>
 *
 * Raul 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 2 of the License, or (at your option) any later
 * version.
 *
 * Raul 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 details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef RAUL_TABLE_HPP
#define RAUL_TABLE_HPP

#include <algorithm>
#include <utility>
#include <vector>

#include <boost/utility.hpp>

#include "raul/SharedPtr.hpp"

//#define TABLE_SORT_DEBUG

namespace Raul {


/** Slow insertion, fast lookup, cache optimized, super fast sorted iteration.
 *
 * This has the advantage over std::map that iterating over the collection
 * is fast and sorted.  Possibly also faster in some situations due to all
 * data being in a single chunk of memory, cache optimized, etc.
 * \ingroup raul 
 */
template <typename K, typename T>
class Table : public boost::noncopyable {
public:
	Table<K, T>() : _entries() {}
	Table<K, T>(size_t capacity) : _entries(capacity) {}

	void clear() { _entries.clear(); }
	bool empty() const { return _entries.empty(); }
	void reserve(size_t n) { _entries.reserve(n); }

	struct const_iterator {
		const_iterator(const Table<K,T>& t, size_t i) : _table(&t), _index(i) {}
		inline const std::pair<const K, T> operator*() const { return _table->_entries[_index]; }
		inline const std::pair<const K, T>* operator->() const { return (std::pair<const K, T>*)&_table->_entries[_index]; }
		inline const_iterator& operator++() { ++_index; return *this; }
		inline const_iterator& operator--() { --_index; return *this; }
		inline bool operator==(const const_iterator& i) const { return _index == i._index; }
		inline bool operator!=(const const_iterator& i) const { return _index != i._index; }
		void operator=(const const_iterator& i) { _table = i._table; _index = i._index; }
	private:
		friend class Table<K,T>;
		const Table<K,T>* _table;
		size_t _index;
	};

	struct iterator {
		iterator(Table<K,T>& t, size_t i) : _table(&t), _index(i) {}
		inline std::pair<K, T>& operator*() const { return (std::pair<K, T>&)_table->_entries[_index]; }
		inline std::pair<K, T>* operator->() const { return (std::pair<K, T>*)&_table->_entries[_index]; }
		inline iterator& operator++() { ++_index; return *this; }
		inline iterator& operator--() { --_index; return *this; }
		inline bool operator==(const iterator& i) const { return _index == i._index; }
		inline bool operator!=(const iterator& i) const { return _index != i._index; }
		operator const_iterator() { return *(const_iterator*)this; }
		iterator& operator=(const iterator& i) { _table = i._table; _index = i._index; return *this; }
	private:
		friend class Table<K,T>;
		Table<K,T>* _table;
		size_t _index;
	};

	inline size_t size() const { return _entries.size(); }

	std::pair<iterator,bool> insert(const std::pair<K, T>& entry);

	void erase(const K& key);
	void erase(iterator i);
	void erase(iterator start, iterator end);
	void erase_by_index(size_t start, size_t end);

	SharedPtr< Table<K, T> > yank(iterator start, iterator end);

	std::pair<iterator, bool> cram(const Table<K, T>& range);

	const_iterator find(const_iterator start, const_iterator end, const K& key) const;
	const_iterator find(const K& key) const;

	iterator find(const_iterator start, const_iterator end, const K& key);
	iterator find(const K& key);

	const_iterator find_range_end(const_iterator left, bool (*comp)(const K&,const K&)) const;
	iterator find_range_end(iterator left, bool (*comp)(const K&,const K&));

	T& operator[](const K& key);

	const_iterator begin() const { return const_iterator(*this, 0); }
	const_iterator end()   const { return const_iterator(*this, size()); }
	iterator       begin()       { return iterator(*this, 0); }
	iterator       end()         { return iterator(*this, size()); }

private:
#ifdef TABLE_SORT_DEBUG
	bool is_sorted() const;
#endif

	friend class iterator;

	typedef std::pair<K, T> Entry;

	std::vector<Entry> _entries;
};


} // namespace Raul

#endif // RAUL_TABLE_HPP