Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/include/StairFunc.h
00001 // Header file for data structure that maintains a staircase function.
00002 // Main operations include testing for the minimum value in a
00003 // specified range and increasing (or decreasing) the value
00004 // across all points in a specified range.
00005 // x values are required to be non-negative.
00006 
00007 #ifndef STAIRFUNC_H
00008 #define STAIRFUNC_H
00009 
00010 #include "DkBstSet.h"
00011 #include "List.h"
00012 
00013 namespace grafalgo {
00014 
00024 class StairFunc : public Adt {
00025 public:         StairFunc(int);
00026                 ~StairFunc();
00027 
00028         // common methods
00029         void    clear();
00030         void    resize(int);
00031         void    expand(int);
00032         void    copyFrom(const StairFunc&);
00033 
00034         static  const int MAXY = Util::BIGINT32-1; // max allowed key2 value
00035         int     value(int);                 // return y value for given x
00036         int     findmin(int,int);           // return min value in given range
00037         void    change(int,int,int);        // change values in range by delta
00038 
00039         string& toString(string&) const;
00040 protected:
00041         DkBstSet *points;               // data structure for "change points"
00042         List    *free;                  // list of unused items in points
00043 
00044         void    makeSpace(int);
00045         void    freeSpace();
00046 };
00047 
00048 } // ends namespace
00049 
00050 #endif
 All Classes Files Functions Variables Typedefs Friends