24 #if defined (HAVE_CONFIG_H)
62 return rep->find (field) !=
rep->end ();
68 fields_rep::iterator
p =
rep->find (field);
69 return (p !=
rep->end ()) ? p->second : -1;
75 fields_rep::iterator
p =
rep->find (field);
82 return (*
rep)[field] = n;
89 fields_rep::iterator
p =
rep->find (field);
97 for (fields_rep::iterator q =
rep->begin (); q !=
rep->end (); q++)
115 for (fields_rep::iterator q =
rep->begin (); q !=
rep->end (); q++)
131 for (; p !=
end () && q != other.
end (); p++, q++)
133 if (p->first == q->first)
134 perm[p->second] = q->second;
142 retval = (p ==
end () && q == other.
end ());
152 if (perm.
numel () != n)
165 retval.
xelem (
p->second) =
p->first;
181 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
184 xvals.push_back (val);
225 error (
"orderfields: structs must have same fields up to order");
245 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
246 xvals.resize (idx+1);
251 : xkeys (m.xkeys), xvals (), dimensions (1, 1)
266 return (idx >= 0) ?
xvals[idx] :
Cell ();
276 error (
"octave_map::setfield: internal error");
279 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
282 xvals.push_back (val);
323 error (
"orderfields: structs must have same fields up to order");
343 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
470 dummy = dummy.
permute (vec, inv);
489 assert (
ndims () == 2);
522 retval.
xvals.reserve (nf);
578 retval.
xvals.reserve (nf);
588 assert (retval.
xvals[j].numel () == n);
599 retval.
xvals.reserve (nf);
606 field_list[
i] = map_list[
i].
xvals[j];
633 template <
typename map>
639 new_map_list[idx] = map_list[idx];
651 new_map_list[i], perm);
654 catch (octave::execution_exception&
e)
656 error (e,
"cat: field names mismatch in concatenating structs");
666 if (dim == -1 || dim == -2)
669 error (
"cat: invalid dimension");
672 retval = map_list[0];
676 for (idx = 0; idx < n; idx++)
689 bool all_same =
true;
698 do_cat (dim, n, map_list, retval);
706 do_cat (dim, n, new_map_list, retval);
730 if (dim == -1 || dim == -2)
733 error (
"cat: invalid dimension");
736 retval = map_list[0];
741 for (idx = 0; idx < n; idx++)
752 bool all_same =
true;
765 if (all_same && nf > 0)
766 do_cat (dim, n, map_list, retval);
776 do_cat (dim, n, new_map_list, retval);
785 error (
"dimension mismatch in struct concatenation");
833 dummy = dummy.
index (i, resize_ok);
844 bool resize_ok)
const
858 dummy = dummy.
index (i, j, resize_ok);
882 dummy = dummy.
index (ia, resize_ok);
911 retval =
index (i, resize_ok);
922 retval =
index (i, j, resize_ok);
930 for (k = 0; k < n_idx; k++)
931 ia(k) = idx(k).index_vector ();
933 retval =
index (ia, resize_ok);
980 dummy.assign (i, rhs_dummy);;
1001 catch (octave::execution_exception&
e)
1003 error (e,
"incompatible fields in struct assignment");
1028 dummy.assign (i, j, rhs_dummy);;
1049 catch (octave::execution_exception&
e)
1051 error (e,
"incompatible fields in struct assignment");
1076 dummy.assign (ia, rhs_dummy);;
1097 catch (octave::execution_exception&
e)
1099 error (e,
"incompatible fields in struct assignment");
1145 for (k = 0; k < n_idx; k++)
1146 ia(k) = idx(k).index_vector ();
1270 ia(
i) = idx(
i).index_vector ();
1299 if (pb == rb.
end ())
1300 error (
"field name mismatch in structure concatenation");
1312 error (
"invalid structure concatenation");
1326 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
scalar structure containing the fields
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.
identity matrix If supplied two scalar respectively For allows like xample val
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
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
nd deftypefn *octave_map m
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
=val(i)}if ode{val(i)}occurs in table i
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
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
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
static fields_rep * nil_rep(void)