lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 132e2ac 7/8: Simplify: only one ctor needs to


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 132e2ac 7/8: Simplify: only one ctor needs to call realize_intervals()
Date: Thu, 23 Feb 2017 05:29:07 -0500 (EST)

branch: master
commit 132e2acc120a9f4f15a5ae9d833a112636012bb3
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Simplify: only one ctor needs to call realize_intervals()
    
    The preceding commit explains why this simplification is possible.
    For a discussion of style, see:
      http://lists.nongnu.org/archive/html/lmi/2017-02/msg00059.html
---
 input_sequence.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index 923925c..40fd2b8 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -126,17 +126,18 @@ InputSequence::InputSequence
 /// source vary from one year to the next, and it is desired to use
 /// them as lmi input. It might seem that inserting semicolons between
 /// elements would produce acceptable input, and that the only benefit
-/// is run-length encoding. However, if the imported vector is of
-/// length 20, with the last 19 elements the same, then pasting it
+/// is saving space because of RLE. However, if the imported vector is
+/// of length 20, with the last 19 elements the same, then pasting it
 /// into lmi with semicolon delimiters would be an input error if
-/// there are only 15 years until retirement.
+/// there are only 15 years until retirement, whereas the two-element
+/// RLE representation would work correctly.
 
 InputSequence::InputSequence(std::vector<double> const& v)
     :years_to_maturity_(v.size())
+    ,number_result_    {v}
+    ,keyword_result_   {}
 {
     initialize_from_vector(v);
-    realize_intervals();
-    LMI_ASSERT(v == number_result_);
     assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
 }
 
@@ -147,10 +148,10 @@ InputSequence::InputSequence(std::vector<double> const& v)
 
 InputSequence::InputSequence(std::vector<std::string> const& v)
     :years_to_maturity_(v.size())
+    ,number_result_    {}
+    ,keyword_result_   {v}
 {
     initialize_from_vector(v);
-    realize_intervals();
-    LMI_ASSERT(v == keyword_result_);
     assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]