3
|
1 // Range.h -*- C++ -*- |
|
2 /* |
|
3 |
382
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_Range_h) |
|
25 #define octave_Range_h 1 |
|
26 |
|
27 extern "C++" { |
3
|
28 |
238
|
29 class istream; |
|
30 class ostream; |
3
|
31 |
|
32 class Range |
|
33 { |
|
34 public: |
|
35 Range (void); |
|
36 Range (const Range& r); |
|
37 Range (double b, double l); |
|
38 Range (double b, double l, double i); |
|
39 |
|
40 double base (void) const; |
|
41 double limit (void) const; |
|
42 double inc (void) const; |
|
43 int nelem (void) const; |
|
44 |
|
45 double min (void) const; |
|
46 double max (void) const; |
|
47 |
208
|
48 void sort (void); |
|
49 |
3
|
50 void set_base (double b); |
|
51 void set_limit (double l); |
|
52 void set_inc (double i); |
|
53 |
|
54 friend ostream& operator << (ostream& os, const Range& r); |
|
55 friend istream& operator >> (istream& is, Range& r); |
|
56 |
|
57 void print_range (void); |
|
58 |
|
59 private: |
208
|
60 double rng_base; |
|
61 double rng_limit; |
|
62 double rng_inc; |
|
63 int rng_nelem; |
3
|
64 |
|
65 int nelem_internal (void) const; |
|
66 }; |
|
67 |
208
|
68 inline |
|
69 Range::Range (void) |
|
70 { |
|
71 rng_base = -1; |
|
72 rng_limit = -1; |
|
73 rng_inc = -1; |
|
74 rng_nelem = -1; |
|
75 } |
3
|
76 |
208
|
77 inline |
|
78 Range::Range (const Range& r) |
|
79 { |
|
80 rng_base = r.rng_base; |
|
81 rng_limit = r.rng_limit; |
|
82 rng_inc = r.rng_inc; |
|
83 rng_nelem = r.rng_nelem; |
|
84 } |
3
|
85 |
208
|
86 inline |
|
87 Range::Range (double b, double l) |
|
88 { |
|
89 rng_base = b; |
|
90 rng_limit = l; |
|
91 rng_inc = 1; |
|
92 rng_nelem = nelem_internal (); |
|
93 } |
3
|
94 |
208
|
95 inline |
|
96 Range::Range (double b, double l, double i) |
|
97 { |
|
98 rng_base = b; |
|
99 rng_limit = l; |
|
100 rng_inc = i; |
|
101 rng_nelem = nelem_internal (); |
|
102 } |
3
|
103 |
208
|
104 inline double Range::base (void) const { return rng_base; } |
|
105 inline double Range::limit (void) const { return rng_limit; } |
|
106 inline double Range::inc (void) const { return rng_inc; } |
|
107 inline int Range::nelem (void) const { return rng_nelem; } |
3
|
108 |
208
|
109 inline void Range::set_base (double b) { rng_base = b; } |
|
110 inline void Range::set_limit (double l) { rng_limit = l; } |
|
111 inline void Range::set_inc (double i) { rng_inc = i; } |
3
|
112 |
382
|
113 } // extern "C++" |
|
114 |
3
|
115 #endif |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; page-delimiter: "^/\\*" *** |
|
121 ;;; End: *** |
|
122 */ |