c2fa9913b1
regions. Currently, tracks regions, and is O(m log(n)) for each operation, where m is the number of transition points per range, and n is the number of transition points in the system. A transition point is a place in memory where the pincount changes.
34 lines
895 B
C
34 lines
895 B
C
typedef struct range {
|
|
long start;
|
|
long end;
|
|
} range;
|
|
|
|
typedef struct transition {
|
|
long pos;
|
|
// negative if end of range. Never zero
|
|
int delta;
|
|
// >= abs(delta). Number of times the range immediately less than
|
|
// this point is pinned.
|
|
int pins;
|
|
} transition;
|
|
|
|
typedef struct rangeTracker rangeTracker;
|
|
|
|
rangeTracker * rangeTrackerInit(int quantization);
|
|
void rangeTrackerDeinit(rangeTracker * rt);
|
|
|
|
/**
|
|
Add a new range
|
|
@return a null terminated array of newly-pinned, quantized ranges
|
|
*/
|
|
range ** rangeTrackerAdd(rangeTracker * rt, const range * r);
|
|
/**
|
|
Remove a range
|
|
@return a null terminated array of newly-unpinned, quantized ranges
|
|
*/
|
|
range ** rangeTrackerRemove(rangeTracker * rt, const range * r);
|
|
|
|
const transition ** enumTransitions(rangeTracker * rt);
|
|
char * rangeToString(const range * r);
|
|
char * transitionToString(const transition * t);
|
|
|