/* Bit array support
Copyright 2016 Molnár Károly
*/
#pragma once
#include "stdhdr.h"
#ifdef __cplusplus
#include <vector>
template<class T> struct Range{
T min,max;
Range(T a):min(a),max(a) {}
Range(T a, T e):min(a),max(e) {}
bool contains(T i) const {return min<=i && i<=max;}
char expand(T a, T e) {char r=0; if (min>a) {min=a; r|=1;} if (max<e) {max=e; r|=2;} return r;}
};
#endif
typedef struct gp_Ranges{
#ifdef __cplusplus
typedef Range<int> Range;
private:
std::vector<Range>list; // sorted array of ranges
public:
inline bool setrange(int i) {return setrange(i,i);}
MFUNC(bool) setrange(int a,int e);
inline bool setrange(const Range&r) {return setrange(r.min,r.max);}
inline bool clearrange(int i) {return clearrange(i,i);}
MFUNC(bool) clearrange(int a, int e);
inline bool clearrange(const Range&r) {return clearrange(r.min,r.max);}
MFUNC(void) clear() {list.clear();}
MFUNC(const Range*) operator[](int) const;
EXTERN gp_Ranges():list() {}
#else
int*rsv[3]; // reserve space, hoping having same size as std::vector
#endif
}gp_Ranges;
Detected encoding: UTF-8 | 0
|