41 (*
rep)[fields(i)] = i;
49 (*rep)[std::string (*fields++)] = n++;
55 return rep->find (field) !=
rep->end ();
61 fields_rep::iterator p =
rep->find (field);
62 return (p !=
rep->end ()) ? p->second : -1;
68 fields_rep::iterator p =
rep->find (field);
75 return (*
rep)[field] = n;
82 fields_rep::iterator p =
rep->find (field);
90 for (fields_rep::iterator q =
rep->begin (); q !=
rep->end (); q++)
108 for (fields_rep::iterator q =
rep->begin (); q !=
rep->end (); q++)
124 for (; p !=
end () && q != other.
end (); p++, q++)
126 if (p->first == q->first)
127 perm[p->second] = q->second;
135 retval = (p ==
end () && q == other.
end ());
158 retval.
xelem (p->second) = p->first;
174 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
177 xvals.push_back (val);
224 error (
"orderfields: structs must have same fields up to order");
240 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
241 xvals.resize (idx+1);
246 : xkeys (m.xkeys), xvals (), dimensions (1, 1)
261 return (idx >= 0) ?
xvals[idx] :
Cell ();
273 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
276 xvals.push_back (val);
279 error (
"octave_map::setfield: internal error");
326 error (
"orderfields: structs must have same fields up to order");
342 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
458 retval.
xvals[i] =
xvals[i].permute (vec, inv);
469 dummy = dummy.
permute (vec, inv);
488 assert (
ndims () == 2);
521 retval.
xvals.reserve (nf);
556 xvals[i].resize (dv);
577 retval.
xvals.reserve (nf);
587 assert (retval.
xvals[j].numel () == n);
589 retval.
xvals[j].xelem (i) = map_list[i].
xvals[j];
598 retval.
xvals.reserve (nf);
605 field_list[i] = map_list[i].
xvals[j];
638 new_map_list[idx] = map_list[idx];
653 (*current_liboctave_error_handler)
654 (
"cat: field names mismatch in concatenating structs");
667 if (dim == -1 || dim == -2)
670 (*current_liboctave_error_handler)
671 (
"cat: invalid dimension");
674 retval = map_list[0];
678 for (idx = 0; idx < n; idx++)
691 bool all_same =
true;
700 do_cat (dim, n, map_list, retval);
708 do_cat (dim, n, new_map_list, retval);
732 if (dim == -1 || dim == -2)
735 (*current_liboctave_error_handler)
736 (
"cat: invalid dimension");
739 retval = map_list[0];
744 for (idx = 0; idx < n; idx++)
755 bool all_same =
true;
768 if (all_same && nf > 0)
769 do_cat (dim, n, map_list, retval);
779 do_cat (dim, n, new_map_list, retval);
789 error (
"dimension mismatch in struct concatenation");
831 retval.
xvals[k] =
xvals[k].index (i, resize_ok);
839 dummy = dummy.
index (i, resize_ok);
850 bool resize_ok)
const
856 retval.
xvals[k] =
xvals[k].index (i, j, resize_ok);
864 dummy = dummy.
index (i, j, resize_ok);
880 retval.
xvals[k] =
xvals[k].index (ia, resize_ok);
888 dummy = dummy.
index (ia, resize_ok);
910 retval =
index (i, resize_ok);
922 retval =
index (i, j, resize_ok);
933 ia(i) = idx(i).index_vector ();
940 retval =
index (ia, resize_ok);
980 dummy.assign (i, rhs_dummy);;
1002 error (
"incompatible fields in struct assignment");
1023 dummy.assign (i, j, rhs_dummy);;
1045 error (
"incompatible fields in struct assignment");
1066 dummy.assign (ia, rhs_dummy);;
1088 error (
"incompatible fields in struct assignment");
1127 ia(i) = idx(i).index_vector ();
1160 if (&
xvals[i] != &ref)
1247 ia(i) = idx(i).index_vector ();
1273 if (pb == rb.
end ())
1275 error (
"field name mismatch in structure concatenation");
1289 error (
"invalid structure concatenation");
1304 error (
"internal error: dimension mismatch across fields in struct");
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
string_vector keys(void) const
octave_map column(octave_idx_type k) const
const Cell & contents(const_iterator p) const
octave_map orderfields(void) const
octave_idx_type nfields(void) const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
void delete_elements(const idx_vector &i)
const octave_base_value const Array< octave_idx_type > & ra_idx
bool equal_up_to_order(const octave_fields &other, octave_idx_type *perm) const
void assign(const std::string &k, const Cell &val)
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
static const idx_vector colon
octave_map page(octave_idx_type k) const
octave_idx_type numel(void) const
Number of elements in the array.
void delete_elements(const idx_vector &i)
Deleting elements.
octave_idx_type length(void) const
const octave_value & contents(const_iterator p) const
bool is_same(const octave_fields &other) const
static void permute_to_correct_order(octave_idx_type n, octave_idx_type nf, octave_idx_type idx, const map *map_list, map *new_map_list)
void resize(int n, int fill_value=0)
void assign(const octave_value_list &idx, const Cell &rhs, const octave_value &fill_val=Matrix())
void error(const char *fmt,...)
bool isfield(const std::string &name) const
octave_scalar_map orderfields(void) const
void setfield(const std::string &key, const octave_value &val)
octave_map squeeze(void) const
const_iterator end(void) const
std::vector< Cell > xvals
Cell getfield(const std::string &key) const
octave_idx_type rmfield(const std::string &name)
const_iterator end(void) const
dim_vector squeeze(void) const
void permute_to_correct_order1(const octave_scalar_map &ref, const octave_scalar_map &src, octave_scalar_map &dest, Array< octave_idx_type > &perm)
void extract_scalar(octave_scalar_map &dest, octave_idx_type index) const
void orderfields(Array< octave_idx_type > &perm)
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
std::vector< octave_value > xvals
octave_idx_type nfields(void) const
string_vector fieldnames(void) const
void rmfield(const std::string &key)
octave_map permute(const Array< int > &vec, bool inv=false) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
void resize(const dim_vector &dv, const T &rfv)
dim_vector dims(void) const
void rmfield(const std::string &key)
std::string key(const_iterator p) const
octave_scalar_map fast_elem_extract(octave_idx_type n) const
Cell & insert(const Cell &a, octave_idx_type r, octave_idx_type c)
const_iterator begin(void) const
bool all_zero(void) const
void setfield(const std::string &key, const Cell &val)
T & xelem(octave_idx_type n)
octave_idx_type nfields(void) const
octave_idx_type length(void) const
Number of elements in the array.
const_iterator begin(void) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
const_iterator seek(const std::string &k) const
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
octave_map reshape(const dim_vector &dv) const
octave_scalar_map checkelem(octave_idx_type n) const
bool is_empty(void) const
octave_value getfield(const std::string &key) const
octave_idx_type index(const_iterator p) const
void resize(const dim_vector &dv, bool fill=false)
void optimize_dimensions(void)
octave_map concat(const octave_map &rb, const Array< octave_idx_type > &ra_idx)
const T * fortran_vec(void) const
octave_fields::const_iterator const_iterator
static void do_cat(int dim, octave_idx_type n, const octave_scalar_map *map_list, octave_map &retval)
octave_idx_type getfield(const std::string &name) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
octave_map transpose(void) const