/usr/include/mathic/StlSet.h is in libmathic-dev 1.0~git20160320-4.
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 | #ifndef MATHIC_STL_SET_GUARD
#define MATHIC_STL_SET_GUARD
#include "stdinc.h"
#include <set>
#include <string>
#include <ostream>
namespace mathic {
template<class C>
class StlSet {
public:
typedef C Configuration;
typedef typename Configuration::Entry Entry;
StlSet(const Configuration& configuration):
_conf(configuration), _set(Cmp(&_conf)) {}
Configuration& getConfiguration() {return _conf;}
const Configuration& getConfiguration() const {return _conf;}
std::string getName() const {return "stlset";}
void push(Entry entry) {_set.insert(entry);}
void push(const Entry* begin, const Entry* end) {
for (; begin != end; ++begin)
push(*begin);
}
Entry pop() {
Entry top = *_set.begin();
_set.erase(_set.begin());
return top;
}
Entry top() {
return *_set.begin();
}
bool empty() const {return _set.empty();}
void print(std::ostream& out) const {
out << getName() << ":\n";
for (typename std::multiset<Entry, Cmp>::const_iterator it = _set.begin();
it != _set.end(); ++it)
out << ' ' << *it;
out << '\n';
}
/** This is necessarily an estimate since there is no
way to tell how much memory a std::multiset is using. */
size_t getMemoryUse() const {
const size_t bytesPerItemEstimate =
2 * sizeof(void*) + // assume binary tree with left and right pointers
sizeof(void*) + // assume minimal overhead in the allocator behind new
sizeof(int) + // assume some overhead to maintain balance in tree
sizeof(Entry); // assume data payload
return _set.size() * bytesPerItemEstimate;
}
private:
Configuration _conf;
struct Cmp {
Cmp(const Configuration* conf): _conf(conf) {}
bool operator()(const Entry& a, const Entry& b) {
return _conf->cmpLessThan(_conf->compare(b, a));
}
const Configuration* _conf; // should be &, but gcc complains
};
std::multiset<Entry, Cmp> _set;
};
}
#endif
|