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


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

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


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

示例1: Randomized

JSDescription JSDescription::Randomized(
    bool makeGrothProof,
    ZCJoinSplit& params,
    const uint256& joinSplitPubKey,
    const uint256& anchor,
    std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
    std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
    std::array<size_t, ZC_NUM_JS_INPUTS>& inputMap,
    std::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap,
    CAmount vpub_old,
    CAmount vpub_new,
    bool computeProof,
    uint256 *esk, // payment disclosure
    std::function<int(int)> gen
)
{
    // Randomize the order of the inputs and outputs
    inputMap = {0, 1};
    outputMap = {0, 1};

    assert(gen);

    MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen);
    MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen);

    return JSDescription(
        makeGrothProof,
        params, joinSplitPubKey, anchor, inputs, outputs,
        vpub_old, vpub_new, computeProof,
        esk // payment disclosure
    );
}
开发者ID:Whiteblock,项目名称:zcash,代码行数:32,代码来源:transaction.cpp

示例2: run

  int run(std::array<int, PILES>& pile_heights, std::array<int, 5>& basket,
          int curr) {
    int& res = dp_[calc_dp_index(pile_heights)];
    if (res != -1)
      return res;

    res = curr;

    // Check if the basket is full.
    auto free_pos = std::find(basket.begin(), basket.end(), -1);
    if (free_pos == basket.end())
      return res;

    // Try which pile it's best to take a candy from.
    for (int i = 0; i < PILES; ++i) {
      if (pile_heights[i] > 0) {
        int candy = piles_[i][pile_heights[i] - 1];
        auto candy_pos = std::find(basket.begin(), basket.end(), candy);
        if (candy_pos != basket.end()) {
          pile_heights[i] -= 1;
          *candy_pos = -1;
          res = std::max(res, run(pile_heights, basket, curr+1));
          *candy_pos = candy;
          pile_heights[i] += 1;
        } else {
          pile_heights[i] -= 1;
          *free_pos = candy;
          res = std::max(res, run(pile_heights, basket, curr));
          *free_pos = -1;
          pile_heights[i] += 1;
        }
      }
    }
    return res;
  }
开发者ID:c-a,项目名称:Impa,代码行数:35,代码来源:uva-10118.cpp

示例3: cos

	Sphere(GLfloat radius)
	{
		using namespace Mathematics;
		GLfloat const R = 1.f/float(rings-1);
		GLfloat const S = 1.f/float(sectors-1);
		
		auto v = vertices.begin();
		auto i = indices.begin();
		for(GLuint r = 0; r < rings; ++r)
		{
			for(GLuint s = 0; s < sectors; ++s)
			{
				float const x = cos(tau * s * S) * sin((tau/2.f) * r * R);
				float const y = sin((-tau/4.f) + ((tau/2.f) * r * R));
				float const z = sin(tau * s * S) * sin((tau/2.f) * r * R);
				v->pos = {{ x * radius, y * radius, z * radius }};
				v->norm = {{ x, y, z }};
				v->text = {{ s * S, r * R }};
				++v;
				
				GLuint cur_row = r * sectors;
				GLuint next_row = (r+1) * sectors;
				i->triang = {{ cur_row + s, next_row + s, next_row + (s+1) }};
				++i;
				i->triang = {{ cur_row + s, next_row + (s+1), cur_row + (s+1) }};
				++i;
			}
		}
	}
开发者ID:fatto,项目名称:banana,代码行数:29,代码来源:geometry.hpp

示例4: slide_array

// because files take 8-bit chunks while huffman encoding can have many-lengths,
// sometimes we get an array with something like 5 bits left over, with room for 2 more bits.
// A naive implementation could just slide the array as soon as possible (essentially for every
// byte popped), but here we use first_data to avoid this big-copies too much.
void slide_array(std::array<bool,buffsize>& m, unsigned& first_data, unsigned& next_empty) {
    assert(first_data <= next_empty);
    //cerr << "Sliding buffer with first data: " << first_data << " and next_empty: " << next_empty << endl;
    copy(m.begin()+first_data, m.begin()+next_empty, m.begin());
    // subtract first_data from both indices.
    next_empty -= first_data;
    first_data = 0;
}
开发者ID:agorenst,项目名称:huffman,代码行数:12,代码来源:huffman_buffers.cpp

示例5: setSubMatrixGradient

void setSubMatrixGradient(Eigen::MatrixBase<DerivedA>& dM, const Eigen::MatrixBase<DerivedB>& dM_submatrix,
    const std::array<int, NRows>& rows, const std::array<int, NCols>& cols, typename DerivedA::Index M_rows, typename DerivedA::Index q_start, typename DerivedA::Index q_subvector_size) {
  if (q_subvector_size == Eigen::Dynamic) {
    q_subvector_size = dM.cols() - q_start;
  }
  int index = 0;
  for (typename std::array<int, NCols>::const_iterator col = cols.begin(); col != cols.end(); ++col) {
    for (typename std::array<int, NRows>::const_iterator row = rows.begin(); row != rows.end(); ++row) {
      dM.template block<1, QSubvectorSize> ((*row) + (*col) * M_rows, q_start, 1, q_subvector_size) = dM_submatrix.row(index++);
    }
  }
}
开发者ID:DArpinoRobotics,项目名称:drake,代码行数:12,代码来源:drakeGradientUtil.cpp

示例6: onFloatEdited

void DialogEditSIMDRegister::onFloatEdited(QObject* sender,const std::array<NumberEdit*,numBytes/sizeof(Float)>& elements)
{
	const auto changedFloatEdit=dynamic_cast<NumberEdit*>(sender);
	std::size_t floatIndex=std::find(elements.begin(),elements.end(),changedFloatEdit)-elements.begin();
	bool ok=false;
	auto value=readFloat<Float>(elements[floatIndex]->text(),ok);
	if(ok)
	{
		std::memcpy(&value_[floatIndex*sizeof(value)],&value,sizeof(value));
		updateAllEntriesExcept(elements[floatIndex]);
	}
}
开发者ID:Northern-Lights,项目名称:edb-debugger,代码行数:12,代码来源:DialogEditSIMDRegister.cpp

示例7:

BoolTagFilter::BoolTagFilter(const std::string & key, bool value) :
KeyMultiValueTagFilter(key),
m_Value(value)
{
	if (m_Value)
	{
		const std::array<std::string, 5> s{ { "True", "true", "Yes", "yes", "1" } };
		KeyMultiValueTagFilter::setValues(s.begin(), s.end());
	}
	else
	{
		const std::array<std::string, 5> s{ { "False", "false", "No", "no", "0" } };
		KeyMultiValueTagFilter::setValues(s.begin(), s.end());
	}
}
开发者ID:inphos42,项目名称:osmpbf,代码行数:15,代码来源:filter.cpp

示例8: max_element

static
inline
T
max(const std::array<T, DIM>& arr)
{
    return std::max_element(arr.begin(), arr.end());
}
开发者ID:jwscook,项目名称:solver,代码行数:7,代码来源:MathsUtilities.hpp

示例9: find

static inline bool is_reserved (const char chr) noexcept {
  static const std::array<char,18> reserved
  {{':' , '/' , '?' , '#' , '[' , ']' , '@',
        '!' , '$' , '&' , '\'' , '(' , ')' , '*' , '+' , ',' , ';' , '='}};

  return std::find(reserved.begin(), reserved.end(), chr) not_eq reserved.end();
}
开发者ID:includeos,项目名称:uri,代码行数:7,代码来源:percent_encoding.cpp

示例10: NCRScore

// NCRScore defined inside each feature namespace so it can use the specific array<> datatype
static float NCRScore(std::array<unsigned char,DATASIZE> &I, std::array<unsigned char,DATASIZE> &M, int N, float m, float i, float K1, float K2)
{
	// some components are precalculated in the model or knowledge data
	// Precalculated lines are commented out but left here or understanding
//	float i = std::accumulate(I.begin(),I.end(),0.0F);
//	float i2 = std::inner_product(I.begin(),I.end(),I.begin(),0.0F);
	float im = std::inner_product(I.begin(),I.end(),M.begin(),0.0F);

	float K0 = N*im - i*m;
//	float K1 = N*i2 - i*i;
//	int N = (int)M.size();
//	float K2 = 1.0F / (N*m2 - m*m);

	float score = (K1> 0.0) ? (K0*K0*K2/K1) : 0.0F;
	return score;
}
开发者ID:evansf,项目名称:SWPhase2,代码行数:17,代码来源:InspectPrivateColorHist.cpp

示例11: mManager

	OpenALStream(AudioManagerImpl *manager, MidiSong *song)
		: mManager(manager), mSong(song), mQuit(false), mSource(0)
		, mBufferIdx(0), mSampleRate(0)
	{
		// Using std::fill for mBuffers since VS2013 doesn't support mBuffers{0}.
		std::fill(mBuffers.begin(), mBuffers.end(), 0);
	}
开发者ID:kcat,项目名称:OpenTESArena,代码行数:7,代码来源:AudioManager.cpp

示例12:

inline bp::list v_to_l(std::array<T, dim> vector) {
    bp::list list;
    for (auto iter = vector.begin(); iter != vector.end(); ++iter) {
        list.append(*iter);
    }
    return list;
}
开发者ID:darioizzo,项目名称:audi,代码行数:7,代码来源:common_utils.hpp

示例13: AddSorted

char* AddSorted(unsigned int priority, char value)
{
    auto vit = find_venue_value(value);
    if (priority == 0)
    {
        if (vit != venues.end())
            remove_venue(*vit);
    }
    else
    {
        auto pit = find_venue_priority(priority);
        if (pit != venues.end())
        {
            pit->m_value = value;
            if (vit != venues.end())
                remove_venue(*vit);
        }
        else if (pos < 6)
            venues[pos++] = Venue(priority, value);
        else
            return result;
    }
    // sort from greatest priority to least
    std::sort(venues.begin(), venues.end(), std::greater<Venue>());
    
    for (int i = 0; i < venues.size(); ++i)
        result[i] = venues[i].m_value;
    return result;
}
开发者ID:CCJY,项目名称:coliru,代码行数:29,代码来源:main.cpp

示例14: TiledRange

TArray4s::trange_type
InputData::trange(const Spin s1, const Spin s2, const RangeOV ov1, const RangeOV ov2, const RangeOV ov3, const RangeOV ov4) const {

    const obs_mosym& spin1 = (s1 == alpha ? obs_mosym_alpha_ : obs_mosym_beta_);
    const std::size_t& nocc1 = (s1 == alpha ? nocc_act_alpha_ : nocc_act_beta_);
    const obs_mosym& spin2 = (s2 == alpha ? obs_mosym_alpha_ : obs_mosym_beta_);
    const std::size_t& nocc2 = (s2 == alpha ? nocc_act_alpha_ : nocc_act_beta_);
    const std::size_t first1 = (ov1 == occ ? 0 : nocc1);
    const std::size_t last1 = (ov1 == occ ? nocc1 : nmo_);
    const std::size_t first2 = (ov2 == occ ? 0 : nocc2);
    const std::size_t last2 = (ov2 == occ ? nocc2 : nmo_);
    const std::size_t first3 = (ov3 == occ ? 0 : nocc1);
    const std::size_t last3 = (ov3 == occ ? nocc1 : nmo_);
    const std::size_t first4 = (ov4 == occ ? 0 : nocc2);
    const std::size_t last4 = (ov4 == occ ? nocc2 : nmo_);

    const std::array<TiledArray::TiledRange1, 4> tr_list = {{
            make_trange1(spin1.begin(), spin1.begin() + first1, spin1.begin() + last1),
            make_trange1(spin2.begin(), spin2.begin() + first2, spin2.begin() + last2),
            make_trange1(spin1.begin(), spin1.begin() + first3, spin1.begin() + last3),
            make_trange1(spin2.begin(), spin2.begin() + first4, spin2.begin() + last4)
        }
    };

    return TiledArray::TiledRange(tr_list.begin(), tr_list.end());
}
开发者ID:xichuang,项目名称:tiledarray,代码行数:26,代码来源:input_data.cpp

示例15: AddSorted

char* AddSorted(unsigned int priority, char value)
{
    auto vit = find_venue_value(value);
    if (vit != venues.end()) // if we found the element then we are either changing its priority or deleting it:
    {
        auto pit = find_venue_priority(priority);
        if (priority == 0)
            remove_venue(*vit);
        else if (pit != venues.end()) // if we found an element with the same priority,
        {                             
            pit->m_value = value; // then change the element's m_value to value and
            remove_venue(*vit);   // delete old element
        }
        else // if priority != 0 and there was no duplicate, then just change the priority
            vit->m_priority = priority;
    }
    else if (pos < 6) // if the venue was not found, we are adding a new one
        venues[pos++] = Venue(priority, value);
    else
        return result; // if the element was not found and the array is full, then there is nothing to do
        
    // sort from greatest priority to least
    std::sort(venues.begin(), venues.end(), std::greater<Venue>());
    
    for (int i = 0; i < venues.size(); ++i)
        result[i] = venues[i].m_value;
    return result;
}
开发者ID:CCJY,项目名称:coliru,代码行数:28,代码来源:main.cpp


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