X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=flower%2Finterval.cc;h=04b141159d6c6c14d2a9245e0d73c0c40c38e458;hb=77831141fb83d0a046b0c78f06f8e58bef19ee68;hp=46b4fc7e1603f2bb7346f5af0d6ec3e857eb5404;hpb=b9de385139e4607b126f150d76db7905c75a6d89;p=lilypond.git diff --git a/flower/interval.cc b/flower/interval.cc index 46b4fc7e16..04b141159d 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -1,93 +1,53 @@ -#include -#include -#include "interval.hh" -#include "string.hh" - +/* + This file is part of LilyPond, the GNU music typesetter. + Copyright (C) 1997--2012 Han-Wen Nienhuys -template -int -Interval__compare(const Interval_t&a,Interval_t const&b) -{ - if (a.left == b.left && a.right == b.right) - return 0; - - if (a.left <= b.left && a.right >= b.right) - return 1; + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - if (a.left >= b.left && a.right <= b.right) - return -1; - - assert(false); // not comparable - - return 0; -} + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -const Real INFTY = HUGE; + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ -template -void -Interval_t::set_empty() { - left = INFTY; - right = -INFTY; -} +#include "interval.hh" -template -T -Interval_t::length() const { - assert(right >= left); - return right-left; -} +#include "interval.tcc" -template -void -Interval_t::unite(Interval_t h) +template<> +Real +Interval_t::infinity () { - if (h.leftright) - right = h.right; + return HUGE_VAL; } -/** - smallest Interval which includes *this and #h# - */ - -template -void -Interval_t::intersect(Interval_t h) +template<> +string +Interval_t::T_to_string (Real r) { -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - left = h.left >? left; - right = h.right -Interval_t -intersect(Interval_t x, Interval_t const &y) +template<> +int +Interval_t::infinity () { - x.intersect(y); - return x; + return INT_MAX; } -template -String -Interval_t::str() const +template<> +string +Interval_t::T_to_string (int i) { - if (empty()) - return "[empty]"; - String s("["); - - return s + left + "," + right +"]"; + return ::to_string (i); } -template -bool -Interval_t::elt_q(T r) -{ - return r >= left && r <= right; -} +template INTERVAL__INSTANTIATE (int); +template INTERVAL__INSTANTIATE (Real);