lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 56ad589 3/4: Reorder free functions


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 56ad589 3/4: Reorder free functions
Date: Sun, 26 Feb 2017 12:39:01 -0500 (EST)

branch: master
commit 56ad589588f2bef4e5aba4e6bb296e9bfe1757de
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Reorder free functions
    
    fill_interval_gaps() logically (and now physically) precedes
    assert_sane_and_ordered_partition(): the former establishes the
    invariants that the latter verifies.
---
 input_sequence.cpp | 94 +++++++++++++++++++++++++++---------------------------
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index e1c0783..4277d07 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -43,11 +43,6 @@ void assert_not_insane_or_disordered
     ,int                               years_to_maturity
     );
 
-void assert_sane_and_ordered_partition
-    (std::vector<ValueInterval> const& intervals
-    ,int                               years_to_maturity
-    );
-
 void fill_interval_gaps
     (std::vector<ValueInterval> const& in
     ,std::vector<ValueInterval>      & out
@@ -55,6 +50,11 @@ void fill_interval_gaps
     ,bool                              keywords_only
     ,std::string                const& default_keyword
     );
+
+void assert_sane_and_ordered_partition
+    (std::vector<ValueInterval> const& intervals
+    ,int                               years_to_maturity
+    );
 } // Unnamed namespace.
 
 InputSequence::InputSequence
@@ -549,48 +549,6 @@ void assert_not_insane_or_disordered
         }
 }
 
-/// Assert postconditions established by all ctors.
-///
-/// What is actually asserted here, for now at least, is only that the
-/// intervals are contiguous--not that they truly partition the range
-/// [0, years_to_maturity). Cf. fill_interval_gaps(), which similarly
-/// establishes only this weaker invariant, which also happens to be
-/// what InputSequenceEntry asserts.
-
-void assert_sane_and_ordered_partition
-    (std::vector<ValueInterval> const& intervals
-    ,int                               years_to_maturity
-    )
-{
-    assert_not_insane_or_disordered(intervals, years_to_maturity);
-
-    LMI_ASSERT(!intervals.empty());
-
-    LMI_ASSERT(0                 == intervals.front().begin_duration);
-    LMI_ASSERT(e_inception       == intervals.front().begin_mode    );
-
-    LMI_ASSERT(years_to_maturity == intervals.back().end_duration);
-    LMI_ASSERT(e_maturity        == intervals.back().end_mode    );
-
-    int prior_end_duration = 0;
-    for(auto const& i : intervals)
-        {
-        if(i.begin_duration != prior_end_duration)
-            {
-            fatal_error()
-                << "Interval "
-                << "[ " << i.begin_duration << ", "
-                << i.end_duration << " )"
-                << " should begin at duration "
-                << prior_end_duration
-                << ", where the previous interval ended."
-                << LMI_FLUSH
-                ;
-            }
-        prior_end_duration = i.end_duration;
-        }
-}
-
 /// Create a partition of [0, maturity) from parser output.
 ///
 /// The last interval's endpoint is extended to maturity, replicating
@@ -677,5 +635,47 @@ void fill_interval_gaps
     // may have been inserted.
     assert_sane_and_ordered_partition(out, years_to_maturity);
 }
+
+/// Assert postconditions established by all ctors.
+///
+/// What is actually asserted here, for now at least, is only that the
+/// intervals are contiguous--not that they truly partition the range
+/// [0, years_to_maturity). Cf. fill_interval_gaps(), which similarly
+/// establishes only this weaker invariant, which also happens to be
+/// what InputSequenceEntry asserts.
+
+void assert_sane_and_ordered_partition
+    (std::vector<ValueInterval> const& intervals
+    ,int                               years_to_maturity
+    )
+{
+    assert_not_insane_or_disordered(intervals, years_to_maturity);
+
+    LMI_ASSERT(!intervals.empty());
+
+    LMI_ASSERT(0                 == intervals.front().begin_duration);
+    LMI_ASSERT(e_inception       == intervals.front().begin_mode    );
+
+    LMI_ASSERT(years_to_maturity == intervals.back().end_duration);
+    LMI_ASSERT(e_maturity        == intervals.back().end_mode    );
+
+    int prior_end_duration = 0;
+    for(auto const& i : intervals)
+        {
+        if(i.begin_duration != prior_end_duration)
+            {
+            fatal_error()
+                << "Interval "
+                << "[ " << i.begin_duration << ", "
+                << i.end_duration << " )"
+                << " should begin at duration "
+                << prior_end_duration
+                << ", where the previous interval ended."
+                << LMI_FLUSH
+                ;
+            }
+        prior_end_duration = i.end_duration;
+        }
+}
 } // Unnamed namespace.
 



reply via email to

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