/usr/share/shedskin/lib/bisect.hpp is in shedskin 0.9.1-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 | /* Copyright 2005-2011 Mark Dufour and contributors; License Expat (See LICENSE) */
#ifndef __BISECT_HPP
#define __BISECT_HPP
#include "builtin.hpp"
using namespace __shedskin__;
namespace __bisect__ {
extern str * __name__;
void __init();
void __pos_check(__ss_int lo, __ss_int hi);
template <class A> void *insort_right(list<A> *a, A x, __ss_int lo, __ss_int hi) {
__ss_int mid;
__pos_check(lo, hi);
while((lo<hi)) {
mid = (lo+hi)/2;
if (__cmp(x, a->units[mid])==-1) {
hi = mid;
}
else {
lo = (mid+1);
}
}
a->insert(lo, x);
return NULL;
}
template <class A> void *insort(list<A> *a, A x, __ss_int lo, __ss_int hi) {
insort_right(a, x, lo, hi);
return NULL;
}
template <class A> __ss_int bisect_right(list<A> *a, A x, __ss_int lo, __ss_int hi) {
__ss_int mid;
__pos_check(lo, hi);
while((lo<hi)) {
mid = (lo+hi)/2;
if (__cmp(x, a->units[mid])==-1) {
hi = mid;
}
else {
lo = (mid+1);
}
}
return lo;
}
template <class A> __ss_int bisect(list<A> *a, A x, __ss_int lo, __ss_int hi) {
return bisect_right(a, x, lo, hi);
}
template <class A> void *insort_left(list<A> *a, A x, __ss_int lo, __ss_int hi) {
__ss_int mid;
__pos_check(lo, hi);
while((lo<hi)) {
mid = (lo+hi)/2;
if (__cmp(a->units[mid], x)==-1) {
lo = (mid+1);
}
else {
hi = mid;
}
}
a->insert(lo, x);
return NULL;
}
template <class A> __ss_int bisect_left(list<A> *a, A x, __ss_int lo, __ss_int hi) {
__ss_int mid;
__pos_check(lo, hi);
while((lo<hi)) {
mid = (lo+hi)/2;
if (__cmp(a->units[mid], x)==-1) {
lo = (mid+1);
}
else {
hi = mid;
}
}
return lo;
}
template <class A> __ss_int bisect_left(list<A> *a, A x, __ss_int lo=0) {
return bisect_left(a, x, lo, len(a));
}
template <class A> __ss_int bisect_right(list<A> *a, A x, __ss_int lo=0) {
return bisect_right(a, x, lo, len(a));
}
template <class A> __ss_int bisect(list<A> *a, A x, __ss_int lo=0) {
return bisect_right(a, x, lo, len(a));
}
template <class A> void *insort_left(list<A> *a, A x, __ss_int lo=0) {
return insort_left(a, x, lo, len(a));
}
template <class A> void *insort_right(list<A> *a, A x, __ss_int lo=0) {
return insort_right(a, x, lo, len(a));
}
template <class A> void *insort(list<A> *a, A x, __ss_int lo=0) {
return insort_right(a, x, lo, len(a));
}
} // module namespace
#endif
|