/usr/include/pbseq/alignment/algorithms/alignment/sdp/SDPSetImpl.hpp is in libblasr-dev 0~20161219-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 | #include <stdint.h>
#include <set>
#include "../../../../pbdata/Types.h"
#include "SDPSet.hpp"
template<typename T>
int SDPSet<T>::size() {
return tree.size();
}
/*
* Remove a fragment f if it exists.
*/
template<typename T>
int SDPSet<T>::Delete(T &f) {
typename std::set<T>::iterator it = tree.find(f);
if (it != tree.end() and (*it) == f) {
tree.erase(f);
return 1;
}
return 0;
}
/*
* Insert a fresh copy of f into the set. If a copy
* already exists, replace it with this one.
*/
template<typename T>
inline VectorIndex SDPSet<T>::Insert(T &f) {
typename SDPSet<T>::Tree::iterator it = tree.find(f);
if (it != tree.end())
tree.erase(it);
tree.insert(f);
return tree.size();
}
/*
Returns true if there is a value such that value == f
*/
template<typename T>
int SDPSet<T>::Member(T &f) {
typename SDPSet<T>::Tree::iterator it = tree.find(f);
if (it != tree.end()) {
f = *it;
return 1;
}
return 0;
}
template<typename T>
int SDPSet<T>::Min(T &f) {
if (tree.size() == 0) {
return 0;
}
else {
f = *(tree.begin());
}
}
/*
* Given f, set succ to be the first value greater than f.
* Return 1 if such a value exists, 0 otherwise.
*/
template<typename T>
int SDPSet<T>::Successor(T &f, T &succ) {
//
// Set succ to the first value > f, if such a value exists.
//
if (tree.size() < 2) {
return 0;
}
typename Tree::iterator it = tree.upper_bound(f);
if (it == tree.end())
return 0;
succ = *it;
return 1;
}
/*
* Given f, set pred to the first value less than f.
* Returns 1 if such a value exists, 0 otherwise.
*/
template<typename T>
int SDPSet<T>::Predecessor(T &f, T &pred) {
//
// Set pred equal to the largest value <= f.
// Return 1 if such a value exists, 0 otherwise.
//
if (tree.size() == 0)
return 0;
typename Tree::iterator it = tree.find(f);
if (it != tree.end()) {
pred = *it;
return 1;
}
it = tree.lower_bound(f);
if (it != tree.begin())
--it;
if (f < *it) {
// No elements less than f exist.
return 0;
}
else {
pred = *it;
return 1;
}
}
|