• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ array_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: size

void ibis::array_t<T>::sort(array_t<uint32_t>& ind) const {
    const size_t na = size();
    size_t ni = ind.size();
    bool keepind = (ni > 0);
    for (size_t j = 0; keepind && j < ni; ++ j)
	keepind = (ind[j] < na);
    if (! keepind) { // initalize ind to [0:na-1]
	ni = na;
	ind.resize(na);
	for (size_t i = 0; i < na; ++i)
	    ind[i] = i;
    }
    if (ni < 2) { // no need to sort
	return;
    }
    if (ni > 0xFFFFFFFFUL) { // do not support arrays of this size?
	ind.clear();
	return;
    }

    // call qsort to do the actual work
    qsort(ind, 0, ni);
#if DEBUG+0 > 1 || _DEBUG+0 > 1
    ibis::util::logger lg(4);
    lg.buffer() << "DEBUG -- sort(ind[" << ni << "])";
    for (size_t i = 0; i < ni; ++i)
	lg.buffer() << "\nind[" << i << "]=" << ind[i] << "\t"
		    << m_begin[ind[i]];
#endif
} // sort
开发者ID:asankaf,项目名称:scalable-data-mining-framework,代码行数:30,代码来源:array_t.cpp


示例2: if

void ibis::array_t<T>::stableSort(array_t<uint32_t>& ind) const {
    if (size() > 2) {
	if (size() > 0xFFFFFFFFUL) {
	    ind.clear();
	    return;
	}

	array_t<T> tmp1, tmp2;
	array_t<uint32_t> itmp;
	tmp1.deepCopy(*this);
	ibis::array_t<T>::stableSort(tmp1, ind, tmp2, itmp);
    }
    else if (size() == 2) {
	ind.resize(2);
	if (m_begin[1] < m_begin[0]) {
	    const T tmp = m_begin[1];
	    m_begin[1] = m_begin[0];
	    m_begin[0] = tmp;
	    ind[0] = 1;
	    ind[1] = 0;
	}
	else {
	    ind[0] = 0;
	    ind[1] = 1;
	}
    }
    else if (size() == 1) {
	ind.resize(1);
	ind[0] = 0;
    }
    else {
	ind.clear();
    }
} // stableSort
开发者ID:asankaf,项目名称:scalable-data-mining-framework,代码行数:34,代码来源:array_t.cpp


示例3: 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


示例4: const_array_ref_t

    explicit const_array_ref_t( const array_t& array) : array_( const_cast<array_t*>( &array))
    {
        // preconditions
        assert( core::type_traits<value_type>::type() == array.type());

        if( core::type_traits<value_type>::type() != array.type())
            throw core::bad_type_cast( array.type(), core::type_traits<value_type>::type());
    }
开发者ID:elanifegnirf,项目名称:ramenlibs,代码行数:8,代码来源:array_ref.hpp


示例5: permutate

array_t permutate(array_t &p, array_t &d) {
	array_t r;
	r.reserve(d.size());
	
	for (unsigned i = 0; i < p.size(); i += 1) {
		r.push_back(d[p[i]-1]);
	}
	
	return r;
}
开发者ID:ioquatix,项目名称:www.codeotaku.com,代码行数:10,代码来源:sort.c


示例6: Eval

 double Eval(double h, const array_t &a)
 {
     assert(a.size()>0);
     double v = S0 - a[1] * h;
     if(a.size()>1)
     {
         v -= a[2] * h*h;
     }
     return v;
 }
开发者ID:ybouret,项目名称:capillarity,代码行数:10,代码来源:abacus8.cpp


示例7: 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


示例8: is_argument_list

//  argument_list = expression { "," expression }.
bool expression_parser::is_argument_list(array_t& expression_stack) {
    if (!is_expression(expression_stack))
        return false;

    std::size_t count = 1;

    while (is_token(comma_k)) {
        require_expression(expression_stack);
        ++count;
    }

    expression_stack.push_back(any_regular_t(double(count)));
    expression_stack.push_back(any_regular_t(array_k));

    return true;
}
开发者ID:NextGenIntelligence,项目名称:adobe_source_libraries,代码行数:17,代码来源:expression_parser.cpp


示例9: dump

	void dump(array_t path)
	{
		std::cout << "== length " << path.size() << std::endl;
		for (auto& item : path){
			std::cout << "->" << dict[item->word_id];
		}
		std::cout << std::endl;
	}
开发者ID:svak,项目名称:ligaex,代码行数:8,代码来源:sample.cpp


示例10: is_named_argument_list

//  named_argument_list = named_argument { "," named_argument }.
bool expression_parser::is_named_argument_list(array_t& expression_stack) {
    if (!is_named_argument(expression_stack))
        return false;

    std::size_t count = 1;

    while (is_token(comma_k)) {
        if (!is_named_argument(expression_stack))
            throw_exception("Named argument required.");

        ++count;
    }

    expression_stack.push_back(any_regular_t(double(count)));
    expression_stack.push_back(any_regular_t(dictionary_k));

    return true;
}
开发者ID:NextGenIntelligence,项目名称:adobe_source_libraries,代码行数:19,代码来源:expression_parser.cpp


示例11: operator

    /** Indexing operator. */
    inline value_type operator()(uint8_t x, uint8_t y, uint8_t z) const
    {
        assert(size() == volume());
        assert(x < length());
        assert(y < length());
        assert(z < length());

        return array_t::operator[](x + y * length() + z * area());
    }
开发者ID:Nocte-,项目名称:hexahedra,代码行数:10,代码来源:chunk_base.hpp


示例12: sizeof

void ibis::array_t<T>::deepCopy(const array_t<T>& rhs) {
    if (rhs.actual != 0 && rhs.m_begin != 0 && rhs.m_end != 0) {
	if (actual != 0 && actual->inUse() < 2U &&
	    actual->end() >= rhs.size() * sizeof(T) + actual->begin()) {
	    // already has enough memory allocated, stay with it
	    const size_t n = rhs.size();
	    m_begin = (T*)(actual->begin());
	    m_end = m_begin + n;
	    for (size_t i = 0; i < n; ++ i)
		m_begin[i] = rhs[i];
	}
	else {
	    array_t<T> tmp(rhs.size()); // allocate memory
	    for (size_t i = 0; i < rhs.size(); ++ i)
		tmp[i] = rhs[i];
	    swap(tmp);
	}
    }
} // ibis::array_t<T>::deepCopy
开发者ID:asankaf,项目名称:scalable-data-mining-framework,代码行数:19,代码来源:array_t.cpp


示例13: is_postfix_expression

bool expression_parser::is_postfix_expression(array_t& expression_stack) {
    if (!is_primary_expression(expression_stack))
        return false;

    while (true) {
        if (is_token(open_bracket_k)) {
            require_expression(expression_stack);
            require_token(close_bracket_k);
        } else if (is_token(dot_k)) {
            any_regular_t result;
            require_token(identifier_k, result);
            expression_stack.push_back(result);
        } else
            break;

        expression_stack.push_back(any_regular_t(index_k));
    }

    return true;
}
开发者ID:NextGenIntelligence,项目名称:adobe_source_libraries,代码行数:20,代码来源:expression_parser.cpp


示例14: is_variable_or_function

//  variable_or_function = identifier ["(" [argument_expression_list] ")"].
bool expression_parser::is_variable_or_function(array_t& expression_stack) {
    any_regular_t result;

    if (!is_token(identifier_k, result))
        return false;

    if (is_token(open_parenthesis_k)) {
        // If there are no parameters then set the parameters to an empty array.
        if (!is_argument_expression_list(expression_stack))
            expression_stack.push_back(any_regular_t(adobe::array_t()));

        require_token(close_parenthesis_k);
        expression_stack.push_back(result);
        expression_stack.push_back(any_regular_t(function_k));
    } else {
        expression_stack.push_back(result);
        expression_stack.push_back(any_regular_t(variable_k));
    }

    return true;
}
开发者ID:NextGenIntelligence,项目名称:adobe_source_libraries,代码行数:22,代码来源:expression_parser.cpp


示例15: sizeof

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


示例16: locate

/*
 * Find an object in the array
 * @parm1 comparable_t: the object
 * @parm2 array_t: the array
 * @return int:
 *      true if the comparable item is in the array
 *      false if the comparable item is not in the array
 */
int locate(comparable_t obj, array_t arr)
{
	int low;
	int mid;
	int high;

	low = 0;
	high = arr->get_count(arr)-1;
	
	while (low <= high) {
		mid = low + (high - low) / 2;
		if (!(arr->compare(obj, arr->lookup(mid, arr))))
			return 1;
		else if (arr->compare(obj, arr->lookup(mid, arr)) < 0)
			high = mid - 1;
		else
			low = mid + 1;
	}

	return 0;
}
开发者ID:salma-rodriguez,项目名称:algorithms,代码行数:29,代码来源:search.c


示例17: sorted

bool sorted (array_t &v) {
	int prev = v[0];
	
	for (unsigned i = 1; i < v.size(); i += 1) {
		if (v[i] < prev)
			return false;
		
		prev = v[i];
	}
	
	return true;
}
开发者ID:ioquatix,项目名称:www.codeotaku.com,代码行数:12,代码来源:sort.c


示例18: 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


示例19: 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


示例20: test_expression

    bool test_expression(const lexer_t& lexer,
                         const expression_parser_rules_t& parser_rules,
                         array_t& new_parsed_expression,
                         adobe_parser_t adobe_parse,
                         const std::string& expression)
    {
        std::cout << "expression: \"" << expression << "\"\n";
        array_t original_parsed_expression;
        bool original_parse_failed = false;
        try {
            original_parsed_expression = adobe_parse(expression);
        } catch (const stream_error_t&) {
            original_parse_failed = true;
        }
        if (original_parse_failed)
            std::cout << "original: <parse failure>\n";
        else
            std::cout << "original: " << original_parsed_expression << "\n";
        using boost::spirit::qi::phrase_parse;
        text_iterator_t it(expression.begin());
        detail::s_text_it = &it;
        detail::s_begin = it;
        detail::s_end = text_iterator_t(expression.end());
        detail::s_filename = "test_expression";
        token_iterator_t iter = lexer.begin(it, detail::s_end);
        token_iterator_t end = lexer.end();
        bool new_parse_failed =
            !phrase_parse(iter,
                          end,
                          parser_rules.expression(boost::phoenix::ref(new_parsed_expression)),
                          boost::spirit::qi::in_state("WS")[lexer.self]);
        if (new_parse_failed)
            std::cout << "new:      <parse failure>\n";
        else
            std::cout << "new:      " << new_parsed_expression << "\n";
        bool pass =
            original_parse_failed && new_parse_failed ||
            new_parsed_expression == original_parsed_expression;
        std::cout << (pass ? "PASS" : "FAIL") << "\n";

        if (!pass) {
            std::cout << "original (verbose):\n";
            verbose_dump(original_parsed_expression);
            std::cout << "new (verbose):\n";
            verbose_dump(new_parsed_expression);
        }

        std::cout << "\n";
        new_parsed_expression.clear();

        return pass;
    }
开发者ID:tzlaine,项目名称:adobe_source_libraries,代码行数:52,代码来源:expr_parser_test.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ array_type类代码示例发布时间:2022-05-31
下一篇:
C++ array2d类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap