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


C++ array_t::begin方法代码示例

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


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

示例1: fwrite

/// Write the buffer out directly.
///
/// @ntoe This function is intended to be used by dictionary::write and
/// must satisfy the following conditions.  There must be only one buffer,
/// and the raw_ must be ordered in that buffer.  Under these conditions,
/// we can write the buffer using a single sequential write operations,
/// which should reduce the I/O time.  The easiest way to satisfy these
/// conditions is to invoke mergeBuffers.
int ibis::dictionary::writeBuffer(FILE *fptr, uint32_t nkeys,
                                  array_t<uint64_t> &pos,
                                  array_t<uint32_t> &qos) const {
    size_t ierr;
    pos[0] = 24 + 8 * (nkeys+1) + 4 * nkeys;
    for (unsigned j = 0; j < nkeys; ++ j)
        pos[j+1] += pos[j];

    ierr = fwrite(pos.begin(), sizeof(uint64_t), nkeys+1, fptr);
    LOGGER(ierr != (int)(nkeys+1) && ibis::gVerbose > 1)
        << "Warning -- dictionary::writeBuffer failed to write the offsets, "
        "expected fwrite to return " << nkeys+1 << ", but got " << ierr;

    ierr = fwrite(qos.begin(), sizeof(uint32_t), nkeys, fptr);
    LOGGER(ierr != (int)(nkeys) && ibis::gVerbose > 1)
        << "Warning -- dictionary::writeBuffer failed to write the keys, "
        "expected fwrite to return " << nkeys << ", but got " << ierr;

    const char *buff = buffer_[0];
    size_t sz = pos[nkeys] - pos[0];
    while (sz > 0) {  // a large buffer may need multuple fwrite calls
        ierr = fwrite(buff, 1, sz, fptr);
        if (ierr > 0U && ierr <= sz) {
            buff += ierr;
            sz -= ierr;
        }
        else {
            LOGGER(ibis::gVerbose > 1)
                << "Warning -- dictionary::writeBuffer failed to write the "
                "buffer, fwrite retruned 0";
            return -6;
        }
    }
    return 0;
} // ibis::dictionary::writeBuffer
开发者ID:SecDorks-TorchSis,项目名称:libfastbit,代码行数:43,代码来源:dictionary.cpp

示例2: find_path

	void find_path(const std::string& from, const std::string& to)
	{
		auto first = std::find_if(words.begin(), words.end(), [&from](const std::shared_ptr<Item>& item)->bool { return dict[item->word_id] == from; });
		if (first == words.end()) {
			std::cout << "missing " << from << std::endl;
			return;
		}

		auto second = std::find_if(words.begin(), words.end(), [&to](const std::shared_ptr<Item>& item)->bool { return dict[item->word_id] == to; });
		if (second == words.end()){
			std::cout << "missing " << to << std::endl;
			return;
		}


		auto l = *first;
		auto r = *second;

		visited_t visited;
		array_t path;
		std::size_t lenmax = 11;
		find_item(lenmax, l, r, path, visited);

		std::cout << "hit_reached " << hit_reached << std::endl;
	}
开发者ID:svak,项目名称:ligaex,代码行数:25,代码来源:sample.cpp

示例3: find_item

	void find_item(std::size_t& lenmax, const array_t::value_type& from, const array_t::value_type& to, array_t& path = array_t(), visited_t& visited = visited_t())
	{
		if (path.size() > lenmax)
			return;

		path.push_back(from);
		if (from->word_id == to->word_id)
		{
			lenmax = path.size() - 2;
			dump(path);
			return;
		}

		visited.insert(std::make_pair(from->word_id, 1));

		for (auto& s : from->similar) {

			auto hit = visited.find(s->word_id);
			if (hit != visited.end() && hit->second > 12535000) {
				hit_reached++;
				continue;
			}

			if (hit != visited.end())
				hit->second++;

			// исключить зацикливание
			if (std::find(path.begin(), path.end(), s) != path.end())
				continue;

			array_t another;
			another = path;
			find_item(lenmax, s, to, another, visited);
		}
	}
开发者ID:svak,项目名称:ligaex,代码行数:35,代码来源:sample.cpp

示例4: replace_placeholder

void replace_placeholder(array_t& expression, name_t name, const any_regular_t& value)
{
    for (std::size_t i = 0; i < expression.size(); ++i) {
        name_t element_name;
        if (expression[i].cast<name_t>(element_name) && element_name == name) {
            expression[i] = value;
            expression.erase(expression.begin() + i + 1);
        }
    }
}
开发者ID:Syntaf,项目名称:GG,代码行数:10,代码来源:platform_widget_utils.cpp

示例5: fseek

/// Write the dictionary one keyword at a time.  This version requires on
/// write call on each keyword, which can be time consuming when there are
/// many keywords.
int ibis::dictionary::writeKeys(FILE *fptr, uint32_t nkeys,
                                array_t<uint64_t> &pos,
                                array_t<uint32_t> &qos) const {
    int ierr = fseek(fptr, 8*(nkeys+1)+4*nkeys, SEEK_CUR);
    long int tmp = ftell(fptr);
    pos.clear();
    qos.clear();
    pos.push_back(tmp);
    for (uint32_t j = 0; j < raw_.size(); ++ j) {
        if (raw_[j] != 0) {
            const int len = 1 + std::strlen(raw_[j]);
            ierr = fwrite(raw_[j], 1, len, fptr);
            LOGGER(ierr != len && ibis::gVerbose > 1)
                << "Warning -- dictionary::writeKeys failed to write key["
                << j << "]; expected fwrite to return " << len
                << ", but got " << ierr;

            tmp += len;
            qos.push_back(j);
            pos.push_back(tmp);
        }
    }

    tmp = 0;
    // go back to write the offsets/positions
    ierr = fseek(fptr, 24, SEEK_SET);
    LOGGER(ierr != 0 && ibis::gVerbose > 1)
        << "Warning -- dictionary::writeKeys failed to seek to offset 24 "
        "to write the offsets";

    ierr = fwrite(pos.begin(), sizeof(uint64_t), nkeys+1, fptr);
    LOGGER(ierr != (int)(nkeys+1) && ibis::gVerbose > 1)
        << "Warning -- dictionary::writeKeys failed to write the offsets, "
        "expected fwrite to return " << nkeys+1 << ", but got " << ierr;
    tmp -= 7 * (ierr != (int)(nkeys+1));

    ierr = fwrite(qos.begin(), sizeof(uint32_t), nkeys, fptr);
    LOGGER(ierr != (int)(nkeys) && ibis::gVerbose > 1)
        << "Warning -- dictionary::writeKeys failed to write the keys, "
        "expected fwrite to return " << nkeys << ", but got " << ierr;
    tmp -= 8 * (ierr != (int)(nkeys));
    return tmp;
} // ibis::dictionary::writeKeys
开发者ID:SecDorks-TorchSis,项目名称:libfastbit,代码行数:46,代码来源:dictionary.cpp

示例6: bad_alloc

amqp_field_value_t TableValueImpl::generate_field_value::operator()(const array_t &value) const
{
  amqp_field_value_t v;
  v.kind = AMQP_FIELD_KIND_ARRAY;
  v.value.array.num_entries = value.size();
  v.value.array.entries = (amqp_field_value_t*)amqp_pool_alloc(&pool,
                                                               sizeof(amqp_field_value_t)*value.size());
  if (NULL == v.value.array.entries)
  {
    throw std::bad_alloc();
  }
  
  amqp_field_value_t *output_iterator = v.value.array.entries;
  for (array_t::const_iterator it = value.begin();
       it != value.end(); ++it, ++output_iterator)
  {
    *output_iterator = boost::apply_visitor(generate_field_value(pool),
                                            it->m_impl->m_value);
  }
  return v;
}
开发者ID:MarioArias,项目名称:springone2gx2013,代码行数:21,代码来源:TableImpl.cpp

示例7: name_iter

static popup_t::menu_item_set_t array_to_menu_item_set(const array_t& value)
{
    popup_t::menu_item_set_t set;

    for (array_t::const_iterator iter(value.begin()), last(value.end());
         iter != last; ++iter)
    {
        if (iter->type_info() != typeid(dictionary_t))
            continue;

        const dictionary_t&          cur_new_item(iter->cast<dictionary_t>());
        dictionary_t::const_iterator name_iter(cur_new_item.find(key_name));
        dictionary_t::const_iterator value_iter(cur_new_item.find(key_value));

        if (name_iter == cur_new_item.end() ||
            name_iter->second.type_info() != typeid(std::string) ||
            value_iter == cur_new_item.end())
            continue;

        set.push_back(popup_t::menu_item_t(name_iter->second.cast<std::string>(), value_iter->second));
    }

    return set;
} 
开发者ID:ilelann,项目名称:adobe_platform_libraries,代码行数:24,代码来源:popup_common.hpp

示例8:

	void Phy2dWorld::sortActors(array_t<Phy2dActor*> &actors)
	{
		// sort actors by layer
		std::sort(actors.begin(), actors.end(), lessActorLayer);
	}
开发者ID:KerwinMa,项目名称:firstlight,代码行数:5,代码来源:phy2dWorld.cpp

示例9: begin

 iterator       begin()       { return buf_.begin(); }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:1,代码来源:render_surface.hpp

示例10: index_to_pos

 /** Convert an iterator to a coordinate index.
  * Chunks are conceptually a cube, but in memory they're a flat array.
  * This function converts between the two. */
 chunk_index index_to_pos(const_iterator i) const
 {
     return index_to_pos(size_type(std::distance(begin(), i)));
 }
开发者ID:Nocte-,项目名称:hexahedra,代码行数:7,代码来源:chunk_base.hpp

示例11: equal

 bool operator==(const chunk_base<Type>& compare) const
 {
     return std::equal(begin(), end(), compare.begin());
 }
开发者ID:Nocte-,项目名称:hexahedra,代码行数:4,代码来源:chunk_base.hpp

示例12: clear

 /** Fill this chunk with zeroes/air. */
 void clear(value_type v = 0)
 {
     std::fill(begin(), end(), v);
     is_dirty = true;
 }
开发者ID:Nocte-,项目名称:hexahedra,代码行数:6,代码来源:chunk_base.hpp


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