[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
null assignments for structs
From: |
Jaroslav Hajek |
Subject: |
null assignments for structs |
Date: |
Thu, 2 Oct 2008 22:57:21 +0200 |
hi,
thanks to Octave_map relying on the (now removed) handling of null
assignments in liboctave,
null assignments to structs (like `a.x = 1; a(1) = []') were not
working. I checked in the following change.
regards
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
# HG changeset patch
# User Jaroslav Hajek <address@hidden>
# Date 1222980644 -7200
# Node ID 977d5204cf67e5cd19c911023fac707f8d972a33
# Parent ea9b5f31bfac5167cf87a6a4a784deb21f0e1209
fix null assignment for structs
diff --git a/src/Cell.cc b/src/Cell.cc
--- a/src/Cell.cc
+++ b/src/Cell.cc
@@ -172,6 +172,19 @@
return *this;
}
+Cell&
+Cell::delete_elements (const octave_value_list& idx_arg)
+
+{
+ Array<idx_vector> ra_idx (idx_arg.length ());
+ for (octave_idx_type i = 0; i < idx_arg.length (); i++)
+ ra_idx.xelem (i) = idx_arg(i).index_vector ();
+
+ maybe_delete_elements (ra_idx, octave_value ());
+
+ return *this;
+}
+
octave_idx_type
Cell::nnz (void) const
{
diff --git a/src/Cell.h b/src/Cell.h
--- a/src/Cell.h
+++ b/src/Cell.h
@@ -89,6 +89,8 @@
const octave_value& rfv = resize_fill_value ()) const
{ return Cell (ArrayN<octave_value>::index (ra_idx, resize_ok, rfv)); }
+ Cell& delete_elements (const octave_value_list& idx);
+
Cell& assign (const octave_value_list& idx, const Cell& rhs,
const octave_value& fill_val = octave_value ());
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -0,0 +1,7 @@
+2008-10-02 Jaroslav Hajek <address@hidden>
+
+ * Cell.h (Cell::delete_elements): Declare new member function.
+ * Cell.h (Cell::delete_elements): Define it.
+ * oct-map.cc (Octave_map::maybe_delete_elements): Call delete_elements
+ instead of assign with empty Cell.
+
diff --git a/src/oct-map.cc b/src/oct-map.cc
--- a/src/oct-map.cc
+++ b/src/oct-map.cc
@@ -290,7 +290,7 @@
{
std::string k = t_keys[i];
- map[k] = contents(k).assign (idx, Cell());
+ map[k] = contents(k).delete_elements (idx);
if (error_state)
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- null assignments for structs,
Jaroslav Hajek <=