interval.h revision 63267518b4ce196caab66ef8cbdcfc0921206b3d
/*
* interval.h - Simple closed interval class
*
* Copyright 2007 Michael Sloan <mgsloan@gmail.com>
*
* Lauris Kaplinski <lauris@kaplinski.com>
* Nathan Hurst <njh@mail.csse.monash.edu.au>
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, output to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
#ifndef SEEN_INTERVAL_H
#define SEEN_INTERVAL_H
#include <assert.h>
#include "coord.h"
//
//TODO: I just know this'll pop up somewhere, starting off someone's interval at 0... I can't see how to avoid this.
if(u < v) {
} else {
}
}
double operator[](unsigned i) const {
assert(i < 2);
return _b[i];
}
}
//IMPL: OffsetableConcept
//TODO: rename output_type to something else in the concept
typedef Coord output_type;
}
}
return *this;
}
return *this;
}
//IMPL: ScalableConcept
if(s < 0) {
} else {
_b[0] *= s;
_b[1] *= s;
}
return *this;
}
//TODO: what about s=0?
if(s < 0) {
} else {
_b[0] /= s;
_b[1] /= s;
}
return *this;
}
//TODO: NaN handleage for the next two?
//TODO: Evaluate if wrap behaviour is proper.
//If val > max, then rather than becoming a min==max range, it 'wraps' over
} else {
}
}
//If val < min, then rather than becoming a min==max range, it 'wraps' over
} else {
}
}
}
assert(n > 0);
return result;
}
}
}
};
//IMPL: AddableConcept
}
}
//There might be impls of this based off sign checks
return res;
}
/* reinstate if useful (doesn't do the proper thing for 0 inclusion)
inline Interval operator/(const Interval & a, const Interval & b) {
Interval res(a.min() / b.min());
res.extendTo(a.min() / b.max());
res.extendTo(a.max() / b.min());
res.extendTo(a.max() / b.max());
return res;
}
inline Interval operator/=(Interval & a, const Interval & b) { a = a / b; return a; }
*/
// 'union' conflicts with C keyword
}
//technically >= might be incorrect, but singulars suck
}
}
#endif //SEEN_INTERVAL_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :