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


C++ list::append方法代码示例

本文整理汇总了C++中boost::python::list::append方法的典型用法代码示例。如果您正苦于以下问题:C++ list::append方法的具体用法?C++ list::append怎么用?C++ list::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::python::list的用法示例。


在下文中一共展示了list::append方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

	ControllerData(const sixenseControllerData& data)
	{
		for(int i = 0; i < 3; ++i)
		{
			pos.append(data.pos[i]);
		}
		for(int y = 0; y < 3; ++y)
		{
			boost::python::list col;
			for(int x = 0; x < 3; ++x)
			{
				col.append(data.rot_mat[y][x]);
			}
			rot_mat.append(col);
		}
		joystick_x = data.joystick_x;
		joystick_y = data.joystick_y;
		trigger = data.trigger;
		buttons = data.buttons;
		sequence_number = data.sequence_number;
		for(int i = 0; i < 4; ++i)
		{
			rot_quat.append(data.rot_quat[i]);
		}
		firmware_revision = data.firmware_revision;
		hardware_revision = data.hardware_revision;
		packet_type = data.packet_type;
		magnetic_frequency = data.magnetic_frequency;
		enabled = data.enabled == 1;
		controller_index = data.controller_index;
		is_docked = data.is_docked == 1;
		which_hand = data.which_hand;
	}
开发者ID:mrwonko,项目名称:PySixense,代码行数:33,代码来源:dllmain.cpp

示例2: grid2utf

void grid2utf(T const& grid_type,
                     boost::python::list& l,
                     std::vector<typename T::lookup_type>& key_order)
{
    using keys_type = std::map< typename T::lookup_type, typename T::value_type>;
    using keys_iterator = typename keys_type::iterator;

    typename T::data_type const& data = grid_type.data();
    typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
    typename T::feature_key_type::const_iterator feature_pos;

    keys_type keys;
    // start counting at utf8 codepoint 32, aka space character
    std::uint16_t codepoint = 32;

    std::size_t array_size = data.width();
    for (std::size_t y = 0; y < data.height(); ++y)
    {
        std::uint16_t idx = 0;
        const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
        typename T::value_type const* row = data.get_row(y);
        for (std::size_t x = 0; x < data.width(); ++x)
        {
            typename T::value_type feature_id = row[x];
            feature_pos = feature_keys.find(feature_id);
            if (feature_pos != feature_keys.end())
            {
                mapnik::grid::lookup_type val = feature_pos->second;
                keys_iterator key_pos = keys.find(val);
                if (key_pos == keys.end())
                {
                    // Create a new entry for this key. Skip the codepoints that
                    // can't be encoded directly in JSON.
                    if (codepoint == 34) ++codepoint;      // Skip "
                    else if (codepoint == 92) ++codepoint; // Skip backslash
                    if (feature_id == mapnik::grid::base_mask)
                    {
                        keys[""] = codepoint;
                        key_order.push_back("");
                    }
                    else
                    {
                        keys[val] = codepoint;
                        key_order.push_back(val);
                    }
                    line[idx++] = static_cast<Py_UNICODE>(codepoint);
                    ++codepoint;
                }
                else
                {
                    line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
                }
            }
            // else, shouldn't get here...
        }
        l.append(boost::python::object(
                     boost::python::handle<>(
                         PyUnicode_FromUnicode(line.get(), array_size))));
    }
}
开发者ID:davenquinn,项目名称:python-mapnik,代码行数:60,代码来源:python_grid_utils.cpp

示例3: grid2utf2

void grid2utf2(T const& grid_type,
               boost::python::list& l,
               std::vector<typename T::lookup_type>& key_order,
               unsigned int resolution)
{
    using keys_type = std::map< typename T::lookup_type, typename T::value_type>;
    using keys_iterator = typename keys_type::const_iterator;

    typename T::data_type const& data = grid_type.data();
    typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
    typename T::feature_key_type::const_iterator feature_pos;

    keys_type keys;
    // start counting at utf8 codepoint 32, aka space character
    uint16_t codepoint = 32;

    mapnik::grid::data_type target(data.width()/resolution,data.height()/resolution);
    mapnik::scale_grid(target,grid_type.data(),0.0,0.0);

    unsigned array_size = target.width();
    for (unsigned y = 0; y < target.height(); ++y)
    {
        uint16_t idx = 0;
        const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
        mapnik::grid::value_type * row = target.getRow(y);
        unsigned x;
        for (x = 0; x < target.width(); ++x)
        {
            feature_pos = feature_keys.find(row[x]);
            if (feature_pos != feature_keys.end())
            {
                mapnik::grid::lookup_type val = feature_pos->second;
                keys_iterator key_pos = keys.find(val);
                if (key_pos == keys.end())
                {
                    // Create a new entry for this key. Skip the codepoints that
                    // can't be encoded directly in JSON.
                    if (codepoint == 34) ++codepoint;      // Skip "
                    else if (codepoint == 92) ++codepoint; // Skip backslash
                    keys[val] = codepoint;
                    key_order.push_back(val);
                    line[idx++] = static_cast<Py_UNICODE>(codepoint);
                    ++codepoint;
                }
                else
                {
                    line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
                }
            }
            // else, shouldn't get here...
        }
        l.append(boost::python::object(
                     boost::python::handle<>(
                         PyUnicode_FromUnicode(line.get(), array_size))));
    }
}
开发者ID:Jiangyangyang,项目名称:mapnik,代码行数:56,代码来源:python_grid_utils.cpp

示例4: if

static void grid2utf(T const& grid_type,
                     boost::python::list& l,
                     std::vector<typename T::lookup_type>& key_order,
                     unsigned int resolution)
{
    //typename T::data_type const& data = grid_type.data();
    typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
    typename T::key_type keys;
    typename T::key_type::const_iterator key_pos;
    typename T::feature_key_type::const_iterator feature_pos;
    // start counting at utf8 codepoint 32, aka space character
    boost::uint16_t codepoint = 32;

    // TODO - use double?
    unsigned array_size = static_cast<unsigned int>(grid_type.width()/resolution);
    for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
    {
        boost::uint16_t idx = 0;
        boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
        mapnik::grid::value_type const* row = grid_type.getRow(y);
        for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
        {
            feature_pos = feature_keys.find(row[x]);
            if (feature_pos != feature_keys.end())
            {
                mapnik::grid::lookup_type val = feature_pos->second;
                key_pos = keys.find(val);
                if (key_pos == keys.end())
                {
                    // Create a new entry for this key. Skip the codepoints that
                    // can't be encoded directly in JSON.
                    if (codepoint == 34) ++codepoint;      // Skip "
                    else if (codepoint == 92) ++codepoint; // Skip backslash
                    keys[val] = codepoint;
                    key_order.push_back(val);
                    line[idx++] = static_cast<Py_UNICODE>(codepoint);
                    ++codepoint;
                }
                else
                {
                    line[idx++] = static_cast<Py_UNICODE>(key_pos->second);
                }
            }
            // else, shouldn't get here...
        }
        l.append(boost::python::object(
                     boost::python::handle<>(
                         PyUnicode_FromUnicode(line.get(), array_size))));
    }
}
开发者ID:novldp,项目名称:mapnik,代码行数:50,代码来源:python_grid_utils.hpp

示例5: mpi_init

bool mpi_init(boost::python::list python_argv)
{
  using boost::python::extract;
  using boost::python::object;

  // If already initialized, do nothing but note that initialization
  // is done.
  int flag = 0;
  int result = MPI_Initialized(&flag);
  assert(result == MPI_SUCCESS);
  if (flag) return false;

  // Convert Python argv into C-style argc/argv. Ewwwww!
  int my_argc = extract<int>(python_argv.attr("__len__")());
  char** my_argv = new char*[my_argc];
  for (int arg = 0; arg < my_argc; ++arg)
    my_argv[arg] = strdup(extract<const char*>(python_argv[arg]));

  // Initialize MPI
  int mpi_argc = my_argc;
  char** mpi_argv = my_argv;
  result = MPI_Init(&mpi_argc, &mpi_argv);
  assert(result == MPI_SUCCESS);

  // If anything changed, convert C-style argc/argv into Python argv
  if (mpi_argv != my_argv) {
    // Tear down Python argv
    while (int(extract<int>(python_argv.attr("__len__")())) > 0)
      python_argv.pop();

    // Build up new Python argv
    for (int arg = 0; arg < mpi_argc; ++arg)
      python_argv.append(object(mpi_argv[arg]));
  }

  for (int arg = 0; arg < my_argc; ++arg)
    free(my_argv[arg]);
  delete [] my_argv;

  return true;
}
开发者ID:erwinvaneijk,项目名称:bgl-python,代码行数:41,代码来源:mpi.cpp

示例6: operator

 void operator ()(boost::python::list mylist, const T& value) const
 {
   mylist.append( value );
 }
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:4,代码来源:shared_types_ext.cpp


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