comparison liboctave/idx-vector.cc @ 8680:a2bcd96b9344

use allocators for idx_vector_rep subclasses
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 05 Feb 2009 14:34:30 +0100
parents 095ae5e0a831
children eb63fbe60fab
comparison
equal deleted inserted replaced
8679:280fae940bb0 8680:a2bcd96b9344
58 { 58 {
59 (*current_liboctave_error_handler) 59 (*current_liboctave_error_handler)
60 ("internal error: idx_vector index out of range."); 60 ("internal error: idx_vector index out of range.");
61 } 61 }
62 62
63 DEFINE_OCTAVE_ALLOCATOR(idx_vector::idx_colon_rep);
64
63 idx_vector::idx_colon_rep::idx_colon_rep (char c) 65 idx_vector::idx_colon_rep::idx_colon_rep (char c)
64 { 66 {
65 if (c != ':') 67 if (c != ':')
66 { 68 {
67 (*current_liboctave_error_handler) 69 (*current_liboctave_error_handler)
85 std::ostream& 87 std::ostream&
86 idx_vector::idx_colon_rep::print (std::ostream& os) const 88 idx_vector::idx_colon_rep::print (std::ostream& os) const
87 { 89 {
88 return os << ":"; 90 return os << ":";
89 } 91 }
92
93 DEFINE_OCTAVE_ALLOCATOR(idx_vector::idx_range_rep);
90 94
91 idx_vector::idx_range_rep::idx_range_rep (octave_idx_type _start, octave_idx_type _limit, 95 idx_vector::idx_range_rep::idx_range_rep (octave_idx_type _start, octave_idx_type _limit,
92 octave_idx_type _step) 96 octave_idx_type _step)
93 : start(_start), len (_step ? (_limit - _start) / _step : -1), step (_step) 97 : start(_start), len (_step ? (_limit - _start) / _step : -1), step (_step)
94 { 98 {
207 { 211 {
208 octave_idx_type i = octave_int<octave_idx_type> (x).value (); 212 octave_idx_type i = octave_int<octave_idx_type> (x).value ();
209 return convert_index (i, conv_error, ext); 213 return convert_index (i, conv_error, ext);
210 } 214 }
211 215
216 DEFINE_OCTAVE_ALLOCATOR(idx_vector::idx_scalar_rep);
217
212 template <class T> 218 template <class T>
213 idx_vector::idx_scalar_rep::idx_scalar_rep (T x) 219 idx_vector::idx_scalar_rep::idx_scalar_rep (T x)
214 { 220 {
215 octave_idx_type dummy; 221 octave_idx_type dummy;
216 data = convert_index (x, err, dummy); 222 data = convert_index (x, err, dummy);
236 242
237 std::ostream& idx_vector::idx_scalar_rep::print (std::ostream& os) const 243 std::ostream& idx_vector::idx_scalar_rep::print (std::ostream& os) const
238 { 244 {
239 return os << data; 245 return os << data;
240 } 246 }
247
248 DEFINE_OCTAVE_ALLOCATOR(idx_vector::idx_vector_rep);
241 249
242 template <class T> 250 template <class T>
243 idx_vector::idx_vector_rep::idx_vector_rep (const Array<T>& nda) 251 idx_vector::idx_vector_rep::idx_vector_rep (const Array<T>& nda)
244 : data (0), len (nda.numel ()), ext (0), aowner (0), orig_dims (nda.dims ()) 252 : data (0), len (nda.numel ()), ext (0), aowner (0), orig_dims (nda.dims ())
245 { 253 {