lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 7674fe7 6/6: Rename input-sequence accessors


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 7674fe7 6/6: Rename input-sequence accessors and the members they access
Date: Sun, 26 Feb 2017 19:04:54 -0500 (EST)

branch: master
commit 7674fe76b802f838ad0cb068401712b5bdda4c8f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Rename input-sequence accessors and the members they access
    
    'seriatim' is more evocative than 'linear', e.g.
    
    Also sorted these entities' declarations and definitions uniformly.
---
 gpt_input.cpp            |  2 +-
 input_realization.cpp    |  8 +++----
 input_sequence.cpp       | 58 ++++++++++++++++++++++++------------------------
 input_sequence.hpp       | 13 +++++------
 input_sequence_entry.cpp |  2 +-
 input_sequence_test.cpp  | 14 ++++++------
 mec_input.cpp            |  2 +-
 7 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/gpt_input.cpp b/gpt_input.cpp
index 57cfcb8..4174a76 100644
--- a/gpt_input.cpp
+++ b/gpt_input.cpp
@@ -62,7 +62,7 @@ std::string realize_sequence_string
             ,input.inforce_year     ()
             ,input.effective_year   ()
             );
-        detail::convert_vector(v, s.linear_number_representation());
+        detail::convert_vector(v, s.seriatim_numbers());
         }
     catch(std::exception const& e)
         {
diff --git a/input_realization.cpp b/input_realization.cpp
index dbf3bd1..275f7a9 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -60,7 +60,7 @@ std::string realize_sequence_string
             ,input.inforce_year     ()
             ,input.effective_year   ()
             );
-        detail::convert_vector(v, s.linear_number_representation());
+        detail::convert_vector(v, s.seriatim_numbers());
         }
     catch(std::exception const& e)
         {
@@ -95,7 +95,7 @@ std::string realize_sequence_string
             );
         detail::convert_vector
             (v
-            ,s.linear_keyword_representation()
+            ,s.seriatim_keywords()
             ,keyword_dictionary
             ,default_keyword
             );
@@ -132,10 +132,10 @@ std::string realize_sequence_string
             ,false
             ,default_keyword
             );
-        detail::convert_vector(vn, s.linear_number_representation());
+        detail::convert_vector(vn, s.seriatim_numbers());
         detail::convert_vector
             (ve
-            ,s.linear_keyword_representation()
+            ,s.seriatim_keywords()
             ,keyword_dictionary
             ,default_keyword
             );
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 5837933..1f27dd5 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -77,8 +77,8 @@ InputSequence::InputSequence
     )
     :years_to_maturity_ (a_years_to_maturity)
     ,issue_age_         (a_issue_age)
-    ,number_result_     (a_years_to_maturity)
-    ,keyword_result_    (a_years_to_maturity, a_default_keyword)
+    ,seriatim_keywords_ (a_years_to_maturity, a_default_keyword)
+    ,seriatim_numbers_  (a_years_to_maturity)
 {
     // A default keyword should be specified (i.e., nonempty) only for
     // keyword-only sequences (otherwise, the default is numeric), and
@@ -121,14 +121,30 @@ InputSequence::InputSequence
 
     realize_intervals
         (intervals_
-        ,keyword_result_
-        ,number_result_
+        ,seriatim_keywords_
+        ,seriatim_numbers_
         ,years_to_maturity_
         );
 
     assert_sane_and_ordered_partition(intervals_, a_years_to_maturity);
 }
 
+/// Construct from vector: e.g, a a a b b --> a[0,3); b[3,4).
+///
+/// Accessible only by unit test or through free function template
+/// canonicalized_input_sequence().
+///
+/// No actual need for this particular ctor has yet been found, but
+/// one might be, someday.
+
+InputSequence::InputSequence(std::vector<std::string> const& v)
+    :years_to_maturity_ (v.size())
+    ,seriatim_keywords_ (v)
+{
+    initialize_from_vector(v);
+    assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
+}
+
 /// Construct from vector: e.g, 1 1 1 2 2 --> 1[0,3); 2[3,4).
 ///
 /// Accessible only by unit test or through free function template
@@ -145,24 +161,8 @@ InputSequence::InputSequence
 /// RLE representation would work correctly.
 
 InputSequence::InputSequence(std::vector<double> const& v)
-    :years_to_maturity_(v.size())
-    ,number_result_    (v)
-{
-    initialize_from_vector(v);
-    assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
-}
-
-/// Construct from vector: e.g, a a a b b --> a[0,3); b[3,4).
-///
-/// Accessible only by unit test or through free function template
-/// canonicalized_input_sequence().
-///
-/// No actual need for this particular ctor has yet been found, but
-/// one might be, someday.
-
-InputSequence::InputSequence(std::vector<std::string> const& v)
-    :years_to_maturity_(v.size())
-    ,keyword_result_   (v)
+    :years_to_maturity_ (v.size())
+    ,seriatim_numbers_  (v)
 {
     initialize_from_vector(v);
     assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
@@ -194,7 +194,7 @@ void set_value(ValueInterval& v, std::string const& s)
 /// template to convert vectors (with one value per year) to input
 /// sequences (compacted with RLE).
 ///
-/// Sets only one of {keyword_result_, number_result_}. The other
+/// Sets only one of {seriatim_keywords_,seriatim_numbers_}. The other
 /// defaults to an empty vector (the calling ctor doesn't necessarily
 /// know an appropriate default for its elements, so it can't have any
 /// other size than zero).
@@ -376,19 +376,19 @@ std::string InputSequence::canonical_form() const
     return oss.str();
 }
 
-std::vector<double> const& InputSequence::linear_number_representation() const
+std::vector<ValueInterval> const& InputSequence::intervals() const
 {
-    return number_result_;
+    return intervals_;
 }
 
-std::vector<std::string> const& InputSequence::linear_keyword_representation() 
const
+std::vector<std::string> const& InputSequence::seriatim_keywords() const
 {
-    return keyword_result_;
+    return seriatim_keywords_;
 }
 
-std::vector<ValueInterval> const& InputSequence::interval_representation() 
const
+std::vector<double> const& InputSequence::seriatim_numbers() const
 {
-    return intervals_;
+    return seriatim_numbers_;
 }
 
 namespace
diff --git a/input_sequence.hpp b/input_sequence.hpp
index 27ae666..5fe62a5 100644
--- a/input_sequence.hpp
+++ b/input_sequence.hpp
@@ -165,14 +165,13 @@ class LMI_SO InputSequence
 
     std::string canonical_form() const;
 
-    std::vector<double>      const& linear_number_representation()  const;
-    std::vector<std::string> const& linear_keyword_representation() const;
-
-    std::vector<ValueInterval> const& interval_representation() const;
+    std::vector<ValueInterval> const& intervals() const;
+    std::vector<std::string>   const& seriatim_keywords() const;
+    std::vector<double>        const& seriatim_numbers()  const;
 
   private:
-    explicit InputSequence(std::vector<double> const&);
     explicit InputSequence(std::vector<std::string> const&);
+    explicit InputSequence(std::vector<double> const&);
 
     template<typename T>
     void initialize_from_vector(std::vector<T> const&);
@@ -181,8 +180,8 @@ class LMI_SO InputSequence
     int issue_age_;
 
     std::vector<ValueInterval> intervals_;
-    std::vector<double> number_result_;
-    std::vector<std::string> keyword_result_;
+    std::vector<std::string>   seriatim_keywords_;
+    std::vector<double>        seriatim_numbers_;
 };
 
 template<typename T>
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 071c1fd..f9684f4 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -425,7 +425,7 @@ void InputSequenceEditor::sequence(InputSequence const& s)
         remove_row(0);
         }
 
-    std::vector<ValueInterval> const& intervals = s.interval_representation();
+    std::vector<ValueInterval> const& intervals = s.intervals();
     int const num_intervals = intervals.size();
 
     // Reaffirm InputSequence invariants that are relied upon here:
diff --git a/input_sequence_test.cpp b/input_sequence_test.cpp
index 282d54f..2bcfaf6 100644
--- a/input_sequence_test.cpp
+++ b/input_sequence_test.cpp
@@ -67,7 +67,7 @@ void input_sequence_test::check
         {
         InputSequence const seq(e, n, 90, 95, 0, 2002, k, o, w);
 
-        std::vector<double> const& v(seq.linear_number_representation());
+        std::vector<double> const& v(seq.seriatim_numbers());
         bool const bv = v == std::vector<double>(d, d + n);
         if(!bv)
             {
@@ -80,7 +80,7 @@ void input_sequence_test::check
             std::cout << std::endl;
             }
 
-        std::vector<std::string> const& s(seq.linear_keyword_representation());
+        std::vector<std::string> const& s(seq.seriatim_keywords());
         std::vector<std::string> const t =
             ( std::vector<std::string>() == c)
             ? std::vector<std::string>(n)
@@ -394,7 +394,7 @@ void input_sequence_test::test()
     {
     std::vector<double> const v{1, 1, 1, 2, 2};
     InputSequence const seq(v);
-    BOOST_TEST(v == seq.linear_number_representation());
+    BOOST_TEST(v == seq.seriatim_numbers());
     BOOST_TEST_EQUAL("1 3; 2", canonicalized_input_sequence(v));
     }
 
@@ -402,7 +402,7 @@ void input_sequence_test::test()
     {
     std::vector<std::string> const v{"alpha", "beta", "beta", "gamma", "eta"};
     InputSequence const seq(v);
-    BOOST_TEST(v == seq.linear_keyword_representation());
+    BOOST_TEST(v == seq.seriatim_keywords());
     BOOST_TEST_EQUAL
         ("alpha 1; beta 3; gamma 4; eta"
         ,canonicalized_input_sequence(v)
@@ -413,7 +413,7 @@ void input_sequence_test::test()
     {
     std::vector<double> const v{3};
     InputSequence const seq(v);
-    BOOST_TEST(v == seq.linear_number_representation());
+    BOOST_TEST(v == seq.seriatim_numbers());
     BOOST_TEST_EQUAL("3", canonicalized_input_sequence(v));
     }
 
@@ -421,7 +421,7 @@ void input_sequence_test::test()
     {
     std::vector<double> const v;
     InputSequence const seq(v);
-    BOOST_TEST(v == seq.linear_number_representation());
+    BOOST_TEST(v == seq.seriatim_numbers());
     BOOST_TEST_EQUAL("0", canonicalized_input_sequence(v));
     }
 
@@ -587,7 +587,7 @@ void input_sequence_test::test()
     std::string const g("7 retirement; 4");
     check(__FILE__, __LINE__, n, d, e, g);
     InputSequence const seq(e, 10, 90, 95, 0, 2002);
-    std::vector<ValueInterval> const& i(seq.interval_representation());
+    std::vector<ValueInterval> const& i(seq.intervals());
     BOOST_TEST_EQUAL(e_inception , i[0].begin_mode);
     BOOST_TEST_EQUAL(e_retirement, i[0].end_mode  );
     BOOST_TEST_EQUAL(e_retirement, i[1].begin_mode);
diff --git a/mec_input.cpp b/mec_input.cpp
index ad63ff3..09d2db7 100644
--- a/mec_input.cpp
+++ b/mec_input.cpp
@@ -62,7 +62,7 @@ std::string realize_sequence_string
             ,input.inforce_year     ()
             ,input.effective_year   ()
             );
-        detail::convert_vector(v, s.linear_number_representation());
+        detail::convert_vector(v, s.seriatim_numbers());
         }
     catch(std::exception const& e)
         {



reply via email to

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