本文整理汇总了C++中vector_fp::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_fp::clear方法的具体用法?C++ vector_fp::clear怎么用?C++ vector_fp::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_fp
的用法示例。
在下文中一共展示了vector_fp::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFloatArray
/*
* This function will read a child node to the current XML node, with the
* name "floatArray". It will have a title attribute, and the body
* of the XML node will be filled out with a comma separated list of
* doublereals.
* Get an array of floats from the XML Node. The argument field
* is assumed to consist of an arbitrary number of comma
* separated floats, with an arbitrary amount of white space
* separating each field.
* If the node array has an units attribute field, then
* the units are used to convert the floats, iff convert is true.
*
* Example:
*
* Code snipet:
* @verbatum
const XML_Node &State_XMLNode;
vector_fp v;
bool convert = true;
unitsString = "";
nodeName="floatArray";
getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
@endverbatum
*
* reads the corresponding XML file:
*
* @verbatum
<state>
<floatArray units="m3"> 32.4, 1, 100. <\floatArray>
<\state>
@endverbatum
*
* Will produce the vector
*
* v[0] = 32.4
* v[1] = 1.0
* v[2] = 100.
*
*
* @param node XML parent node of the floatArray
* @param v Output vector of floats containing the floatArray information.
* @param convert Conversion to SI is carried out if this boolean is
* True. The default is true.
* @param typeString String name of the type attribute. This is an optional
* parameter. The default is to have an empty string.
* The only string that is recognized is actEnergy.
* Anything else has no effect. This affects what
* units converter is used.
* @param nodeName XML Name of the XML node to read.
* The default value for the node name is floatArray
*/
void getFloatArray(const Cantera::XML_Node& node, vector_fp& v, const bool convert,
const std::string unitsString, const std::string nodeName) {
string::size_type icom;
string numstr;
doublereal dtmp;
string nn = node.name();
if (nn != nodeName)
throw CanteraError("getFloatArray",
"wrong xml element type/name: was expecting "
+ nodeName + "but accessed " + node.name());
v.clear();
doublereal vmin = Undef, vmax = Undef;
doublereal funit = 1.0;
/*
* Get the attributes field, units, from the XML node
*/
std::string units = node["units"];
if (units != "" && convert) {
if (unitsString == "actEnergy" && units != "") {
funit = actEnergyToSI(units);
} else if (unitsString != "" && units != "") {
funit = toSI(units);
}
}
if (node["min"] != "")
vmin = atofCheck(node["min"].c_str());
if (node["max"] != "")
vmax = atofCheck(node["max"].c_str());
doublereal vv;
std::string val = node.value();
while (1 > 0) {
icom = val.find(',');
if (icom != string::npos) {
numstr = val.substr(0,icom);
val = val.substr(icom+1,val.size());
dtmp = atofCheck(numstr.c_str());
v.push_back(dtmp);
}
else {
/*
* This little bit of code is to allow for the
* possibility of a comma being the last
* item in the value text. This was allowed in
* previous versions of Cantera, even though it
* would appear to be odd. So, we keep the
//.........这里部分代码省略.........