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


C++ array_t类代码示例

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


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


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