00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1991-1993, 1995, 2002, 2004-2006, 2008 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 00008 // (at 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 00013 // GNU 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 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef LIBAEGIS_INTERVAL_H 00021 #define LIBAEGIS_INTERVAL_H 00022 00023 #include <common/ac/stddef.h> 00024 00025 #include <common/main.h> 00026 00032 class interval 00033 { 00034 public: 00035 typedef long data_t; 00036 00043 ~interval(); 00044 00049 interval(); 00050 00054 interval(const interval &rhs); 00055 00065 interval(data_t first, data_t last); 00066 00070 interval &operator=(const interval &rhs); 00071 00076 bool valid() const; 00077 00082 void clear(); 00083 00093 interval operator+(const interval &rhs) const; 00094 void operator+=(const interval &rhs); 00095 00105 interval operator*(const interval &rhs) const; 00106 void operator*=(const interval &rhs); 00107 00117 interval operator-(const interval &rhs) const; 00118 void operator-=(const interval &rhs); 00119 00129 bool member(data_t datum) const; 00130 00131 void scan_begin(); 00132 00133 bool scan_next(data_t &datum); 00134 00135 void scan_end(); 00136 00144 bool empty() const { return (length == 0); } 00145 00154 data_t first() const; 00155 00164 data_t last() const; 00165 00174 data_t second_last() const; 00175 00176 private: 00177 size_t length; 00178 size_t size; 00179 size_t scan_index; 00180 data_t scan_next_datum; 00181 data_t *data; 00182 00188 void append(data_t datum); 00189 00195 void normalize(); 00196 }; 00197 00198 #endif // LIBAEGIS_INTERVAL_H