[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4924] Reimplement product_database::Query(vector)
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4924] Reimplement product_database::Query(vector) |
Date: |
Sat, 08 May 2010 13:43:12 +0000 |
Revision: 4924
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4924
Author: chicares
Date: 2010-05-08 13:43:12 +0000 (Sat, 08 May 2010)
Log Message:
-----------
Reimplement product_database::Query(vector)
Modified Paths:
--------------
lmi/trunk/database.cpp
lmi/trunk/ihs_database.cpp
Modified: lmi/trunk/database.cpp
===================================================================
--- lmi/trunk/database.cpp 2010-05-08 12:05:34 UTC (rev 4923)
+++ lmi/trunk/database.cpp 2010-05-08 13:43:12 UTC (rev 4924)
@@ -97,6 +97,10 @@
{
index_ = database_index(Gender, Class, Smoker, IssueAge, UWBasis, State);
length_ = static_cast<int>(*GetEntry(DB_EndtAge)[index_]) - IssueAge;
+ if(length_ <= 0)
+ {
+ fatal_error() << "Maturity age precedes issue age." << LMI_FLUSH;
+ }
}
//===========================================================================
@@ -117,16 +121,9 @@
}
else
{
- dst.resize(length_);
- int s = std::min(length_, v.GetLength());
- for(int j = 0; j < s; ++j)
- {
- dst[j] = z[j];
- }
- for(int j = s; j < length_; ++j)
- {
- dst[j] = z[s - 1];
- }
+ dst.reserve(length_);
+ dst.assign(z, z + std::min(length_, v.GetLength()));
+ dst.resize(length_, dst.back());
}
}
Modified: lmi/trunk/ihs_database.cpp
===================================================================
--- lmi/trunk/ihs_database.cpp 2010-05-08 12:05:34 UTC (rev 4923)
+++ lmi/trunk/ihs_database.cpp 2010-05-08 13:43:12 UTC (rev 4924)
@@ -156,7 +156,7 @@
length_ = static_cast<int>(*GetEntry(DB_EndtAge)[index_]) - IssueAge;
if(length_ <= 0)
{
- fatal_error() << "Endowment age precedes issue age." << LMI_FLUSH;
+ fatal_error() << "Maturity age precedes issue age." << LMI_FLUSH;
}
constrain_scalar(DB_EndtAge);
}
@@ -179,33 +179,9 @@
}
else
{
- LMI_ASSERT(0 <= length_); // TODO ?? KLUDGE
- LMI_ASSERT(0 <= v.GetLength()); // TODO ?? KLUDGE
- int s = std::min(length_, v.GetLength());
-// int t = std::max(0, length_ - v.GetLength());
- int t = std::max(0, length_ - s);
- dst.resize(0);
-
- for(int j = 0; j < s; j++)
- {
- dst.push_back(z[j]);
- }
-
- if(0 == t)
- {
- return;
- }
- for(int j = 0; j < t; j++)
- {
- dst.push_back(z[s - 1]);
- }
-
-/*
-// dst.assign(s, *z);
-// copy_n(z, v.GetLength(), dst);
-// copy(&z[0], &z[v.GetLength()], dst.begin());
-// fill(dst.begin() + v.GetLength(), dst.end(), z[v.GetLength() - 1]);
-*/
+ dst.reserve(length_);
+ dst.assign(z, z + std::min(length_, v.GetLength()));
+ dst.resize(length_, dst.back());
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4924] Reimplement product_database::Query(vector),
Greg Chicares <=