Aegis  4.25.D505
/home/archives/aegis/branch.4/branch.25/delta28933.505/libaegis/interval.h
Go to the documentation of this file.
00001 //
00002 // aegis - project change supervisor
00003 // Copyright (C) 1991-1993, 1995, 2002, 2004-2006, 2008, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIBAEGIS_INTERVAL_H
00020 #define LIBAEGIS_INTERVAL_H
00021 
00022 #include <common/ac/stddef.h>
00023 
00024 
00030 class interval
00031 {
00032 public:
00033     typedef long data_t;
00034 
00041     ~interval();
00042 
00047     interval();
00048 
00052     interval(const interval &rhs);
00053 
00063     interval(data_t first, data_t last);
00064 
00068     interval &operator=(const interval &rhs);
00069 
00074     bool valid() const;
00075 
00080     void clear();
00081 
00091     interval operator+(const interval &rhs) const;
00092     void operator+=(const interval &rhs);
00093 
00103     interval operator*(const interval &rhs) const;
00104     void operator*=(const interval &rhs);
00105 
00115     interval operator-(const interval &rhs) const;
00116     void operator-=(const interval &rhs);
00117 
00127     bool member(data_t datum) const;
00128 
00129     void scan_begin();
00130 
00131     bool scan_next(data_t &datum);
00132 
00133     void scan_end();
00134 
00142     bool empty() const { return (length == 0); }
00143 
00152     data_t first() const;
00153 
00162     data_t last() const;
00163 
00172     data_t second_last() const;
00173 
00174 private:
00175     size_t length;
00176     size_t size;
00177     size_t scan_index;
00178     data_t scan_next_datum;
00179     data_t *data;
00180 
00186     void append(data_t datum);
00187 
00193     void normalize();
00194 };
00195 
00196 #endif // LIBAEGIS_INTERVAL_H
00197 // vim: set ts=8 sw=4 et :