520
|
1 // idx-vector.h -*- C++ -*- |
1
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
1
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_idx_vector_h) |
|
25 #define octave_idx_vector_h 1 |
1
|
26 |
1297
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
164
|
31 class ostream; |
|
32 class Matrix; |
|
33 class Range; |
|
34 |
453
|
35 class |
|
36 idx_vector |
1
|
37 { |
|
38 public: |
1551
|
39 |
|
40 idx_vector::idx_vector (void) |
|
41 { |
|
42 len = 0; |
|
43 num_zeros = 0; |
|
44 num_ones = 0; |
|
45 one_zero = 0; |
|
46 initialized = 0; |
|
47 data = 0; |
|
48 } |
|
49 |
1
|
50 idx_vector (const idx_vector& a); |
|
51 |
164
|
52 idx_vector (const Matrix& m, int do_ftn_idx, |
526
|
53 const char *rc = 0, int z_len = 0); |
1
|
54 |
|
55 idx_vector (const Range& r); |
|
56 |
1551
|
57 idx_vector::~idx_vector (void) { delete [] data; } |
1
|
58 |
|
59 idx_vector& operator = (const idx_vector& a); |
|
60 |
1551
|
61 idx_vector::operator void * () const |
|
62 { |
|
63 return initialized ? (void *) 1 : (void *) 0; |
|
64 } |
|
65 |
|
66 int idx_vector::capacity (void) const { return len; } |
|
67 int idx_vector::length (void) const { return len; } |
191
|
68 |
1551
|
69 int idx_vector::elem (int n) const { return data[n]; } |
1552
|
70 int idx_vector::checkelem (int n) const; |
1551
|
71 int idx_vector::operator () (int n) const { return checkelem (n); } |
1
|
72 |
1551
|
73 int idx_vector::max (void) const { return max_val; } |
|
74 int idx_vector::min (void) const { return min_val; } |
|
75 |
|
76 int idx_vector::one_zero_only (void) const { return one_zero; } |
|
77 int idx_vector::zeros_count (void) const { return num_zeros; } |
|
78 int idx_vector::ones_count (void) const { return num_ones; } |
1
|
79 |
|
80 // other stuff |
|
81 |
208
|
82 void sort (void); |
416
|
83 void sort_uniq (void); |
208
|
84 |
434
|
85 void shorten (int n); // Unsafe. Avoid at all cost. |
|
86 |
1
|
87 // i/o |
|
88 |
|
89 friend ostream& operator << (ostream& os, const idx_vector& a); |
|
90 |
|
91 private: |
|
92 |
1553
|
93 int *data; |
1
|
94 int len; |
|
95 int num_zeros; |
|
96 int num_ones; |
|
97 int max_val; |
|
98 int min_val; |
1551
|
99 unsigned int one_zero : 1; |
|
100 unsigned int initialized : 1; |
1
|
101 |
526
|
102 void init_state (const char *rc = 0, int z_len = 0); |
1
|
103 void convert_one_zero_to_idx (void); |
|
104 }; |
|
105 |
|
106 #endif |
|
107 |
|
108 /* |
|
109 ;;; Local Variables: *** |
|
110 ;;; mode: C++ *** |
|
111 ;;; page-delimiter: "^/\\*" *** |
|
112 ;;; End: *** |
|
113 */ |