当前位置: 首页>>代码示例>>C++>>正文


C++ vector_fp::clear方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:ctml.cpp


注:本文中的vector_fp::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。