/usr/include/blasr/tuples/TupleListImpl.hpp is in libblasr-dev 0~20151014+gitbe5d1bf-2.
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 | template<typename T>
TupleList<T>::TupleList() {
listLength = 0;
}
template<typename T>
void TupleList<T>::Reset() {
std::vector<T>().swap(tupleList);
}
template<typename T>
T& TupleList<T>::operator[](int index) {
return tupleList[index];
}
template<typename T>
void TupleList<T>::GetTupleMetrics(TupleMetrics &ptm) {
ptm = tm;
}
template<typename T>
void TupleList<T>::SetTupleMetrics(TupleMetrics &ptm) {
tm = ptm;
}
template<typename T>
int TupleList<T>::size() {
return tupleList.size();
}
template<typename T>
int TupleList<T>::GetLength() {
return tupleList.size();
}
template<typename T>
int TupleList<T>::InitFromFile(std::string &fileName) {
std::ifstream listIn;
listIn.open(fileName.c_str(), std::ios_base::binary);
if (!listIn)
return 0;
listIn.read((char*) &listLength, sizeof(int));
listIn.read((char*) &tm.tupleSize, sizeof(int));
tm.InitializeMask();
tupleList.resize(listLength);
listIn.read((char*) &tupleList[0], sizeof(T) * listLength);
return 1;
}
template<typename T>
void TupleList<T>::clear() {
tupleList.clear();
listLength = 0;
}
template<typename T>
int TupleList<T>::WriteToFile(std::string &fileName) {
std::ofstream listOut;
listOut.open(fileName.c_str(), std::ios_base::binary);
if (!listOut)
return 0;
listLength = tupleList.size();
std::cout << "writing tuple lis of length " << listLength << std::endl;
listOut.write((char*) &listLength, sizeof(int));
listOut.write((char*) &tm.tupleSize, sizeof(int));
listOut.write((char*) &tupleList[0], sizeof(T)*listLength);
return 1;
}
//
// Find one instance of a match.
//
template<typename T>
int TupleList<T>::Find( T& tuple) {
typename std::vector<T>::const_iterator begin, end, matchIt;
begin = tupleList.begin();
end = tupleList.end();
matchIt = lower_bound(begin, end, tuple);
if (*matchIt != tuple) {
return -1;
}
else {
return matchIt - tupleList.begin();
}
}
//
// Find the boundaries of all instances of a match.
//
template<typename T>
void TupleList<T>::FindAll(T &tuple,
typename std::vector<T>::const_iterator &firstPos,
typename std::vector<T>::const_iterator &endPos ) {
firstPos = lower_bound(tupleList.begin(), tupleList.end(), tuple);
typename std::vector<T>::const_iterator firstPos2;
endPos = tupleList.end();
endPos = upper_bound(firstPos, endPos, tuple);
while (endPos != tupleList.end()) {
if (*endPos != tuple) {
return;
}
else {
endPos++;
}
}
}
template<typename T>
void TupleList<T>::Append( T&tuple) {
tupleList.push_back(tuple);
}
template<typename T>
void TupleList<T>::Insert(T&tuple) {
// insert and maintain order.
typename std::vector<T>::iterator pos;
pos = std::lower_bound(tupleList.begin(), tupleList.end(), tuple);
tupleList.insert(pos, tuple);
}
template<typename T>
void TupleList<T>::Sort() {
sort(tupleList.begin(), tupleList.end());
}
template<typename T>
void TupleList<T>::Print() {
int i;
for (i = 0; i< tupleList.size(); i++) {
std::cout << tupleList[i].tuple << std::endl;
}
}
|