メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

Range.h

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #if !defined (octave_Range_h)
00024 #define octave_Range_h 1
00025 
00026 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00027 #pragma interface
00028 #endif
00029 
00030 #include <iostream>
00031 #include "dMatrix.h"
00032 
00033 class
00034 Range
00035 {
00036  public:
00037 
00038   Range (void)
00039     : rng_base (-1), rng_limit (-1), rng_inc (-1), rng_nelem (-1), cache () { }
00040 
00041   Range (const Range& r)
00042     : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc),
00043       rng_nelem (r.rng_nelem), cache () { }
00044 
00045   Range (double b, double l)
00046     : rng_base (b), rng_limit (l), rng_inc (1),
00047       rng_nelem (nelem_internal ()), cache () { }
00048 
00049   Range (double b, double l, double i)
00050     : rng_base (b), rng_limit (l), rng_inc (i),
00051       rng_nelem (nelem_internal ()), cache () { }
00052 
00053   double base (void) const { return rng_base; }
00054   double limit (void) const { return rng_limit; }
00055   double inc (void) const { return rng_inc; }
00056   int nelem (void) const { return rng_nelem; }
00057 
00058   bool all_elements_are_ints (void) const;
00059 
00060   Matrix matrix_value (void) const;
00061 
00062   double min (void) const;
00063   double max (void) const;
00064 
00065   void sort (void);
00066 
00067   void set_base (double b)
00068   {
00069     if (rng_base != b)
00070       {
00071         rng_base = b;
00072         clear_cache ();
00073       }
00074   }
00075 
00076   void set_limit (double l)
00077   {
00078     if (rng_limit != l)
00079       {
00080         rng_limit = l;
00081         clear_cache ();
00082       }
00083   }
00084 
00085   void set_inc (double i)
00086   {
00087     if (rng_inc != i)
00088       {
00089         rng_inc = i;
00090         clear_cache ();
00091       }
00092   }
00093 
00094   friend std::ostream& operator << (std::ostream& os, const Range& r);
00095   friend std::istream& operator >> (std::istream& is, Range& r);
00096 
00097   void print_range (void);
00098 
00099  private:
00100 
00101   double rng_base;
00102   double rng_limit;
00103   double rng_inc;
00104 
00105   int rng_nelem;
00106 
00107   mutable Matrix cache;
00108 
00109   int nelem_internal (void) const;
00110 
00111   void clear_cache (void) const { cache.resize (0, 0); }
00112 };
00113 
00114 extern Range operator - (const Range& r);
00115 
00116 #endif
00117 
00118 /*
00119 ;;; Local Variables: ***
00120 ;;; mode: C++ ***
00121 ;;; End: ***
00122 */

Wed Dec 29 11:52:18 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送