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


C++ elements函数代码示例

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


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

示例1: getRndMode_cf

Value*
getRndMode_cf(Value** arg_list, int count)
{
	check_arg_count(getRndMode, 0, count);
	def_render_types();
	one_typed_value_local(Array* result);
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	DWORD			mode	= gw->getRndMode();

	vl.result = new Array(3);
	for (int i=0; i < elements(renderTypes); i++)
		if ((renderTypes[i].id) & mode) 
			vl.result->append(renderTypes[i].val);		
	return_value (vl.result); // LAM - 5/18/01 - was return vl.result
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:21,代码来源:GraphicsWindow.cpp

示例2: setRndLimits_cf

Value*
setRndLimits_cf(Value** arg_list, int count)
{
	check_arg_count(setRndLimits, 1, count);
	def_render_types();
	GraphicsWindow	*gw		= MAXScript_interface->GetActiveViewExp().getGW();
	
	if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0)
	{
		return &undefined;
	}

	Array			*arr	= (Array*)arg_list[0];
	DWORD			lim		=0;

	type_check(arr, Array, _T("setRndLimits"));
	for (int i=0; i < arr->size; i++)
		lim |= GetID(renderTypes, elements(renderTypes), arr->data[i]);
	gw->setRndLimits(lim);
	return &ok;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:21,代码来源:GraphicsWindow.cpp

示例3: owner

cell factor_vm::code_block_owner(code_block *compiled)
{
	tagged<object> owner(compiled->owner);

	/* Cold generic word call sites point to quotations that call the
	inline-cache-miss and inline-cache-miss-tail primitives. */
	if(owner.type_p(QUOTATION_TYPE))
	{
		tagged<quotation> quot(owner.as<quotation>());
		tagged<array> elements(quot->array);
#ifdef FACTOR_DEBUG
		assert(array_capacity(elements.untagged()) == 5);
		assert(array_nth(elements.untagged(),4) == special_objects[PIC_MISS_WORD]
			|| array_nth(elements.untagged(),4) == special_objects[PIC_MISS_TAIL_WORD]);
#endif
		tagged<wrapper> word_wrapper(array_nth(elements.untagged(),0));
		return word_wrapper->object;
	}
	else
		return compiled->owner;
}
开发者ID:8byte-jose,项目名称:factor,代码行数:21,代码来源:code_blocks.cpp

示例4: elements

/*******************************************************************
* Function Name: externalFunction
* Description: 
********************************************************************/
Model &cola::externalFunction( const ExternalMessage &msg )
{
	if( msg.port() == in )
	{
		elements().push_back( msg.value() ) ;
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == done )
	{
		ocupado (0);
		this->holdIn( AtomicState::active, preparationTime );
	}

	if( msg.port() == stop )
	{ 
		ocupado (1);
		this->passivate();
	}

	return *this;
}
开发者ID:melkyades,项目名称:cdpp,代码行数:26,代码来源:cola.cpp

示例5: tic

//template< typename Expr_convection, typename Expr_bc >
void
PreconditionerAS<space_type,coef_space_type>::update( sparse_matrix_ptrtype Pm,   // A + g M
                                                      sparse_matrix_ptrtype L,    // e_r * grad grad
                                                      sparse_matrix_ptrtype hatL, // 1/mu * grad grad
                                                      sparse_matrix_ptrtype Q     // e_r * id id
                                                      )
{
    tic();
    if(this->type() == AS)
    {
        // A = Pm
        backend()->diag(Pm,M_diagPm);
        M_diagPm->close();

        /*
         * hat(L) = 1/mu * grad grad = 1/(mu*e_r) * L
         * bar(L) = diag( hat(L), hat(L), hat(L) )
         * bar(Q) = diag( er*Q, er*Q, er*Q ) with Q = mass matrix on Qh3
         * blockms.11.1 <=> bar(L) + g*bar(Q) y = s = Pt*r
         * blockms.11.2 <=> L z = t = trans(C)*r
         */

        // Operator hat(L) + g Q
        sparse_matrix_ptrtype Lgq = hatL;
        Lgq->addMatrix(M_g,Q);
        M_lgqOp = op( Lgq, "blockms.11.1");
        // Operator L
        M_lOp = op(L,"blockms.11.2");
    }
    else if(this->type() == SIMPLE)
    {
        auto uu = M_Vh->element("uu");
        auto f22 = form2(M_Vh, M_Vh);
        f22 = integrate(_range=elements(M_Vh->mesh()),
                        _expr=inner(id(uu),idt(uu)));
        SimpleOp = op( f22.matrixPtr(),"blockms.11.1");
    }
    toc( "PreconditionerAS::update", FLAGS_v > 0 );
}
开发者ID:feelpp,项目名称:feelpp,代码行数:40,代码来源:preconditioneras.hpp

示例6: work

void PeriodogramDisplay::work(void)
{
    for (auto inPort : this->inputs())
    {
        if (not inPort->hasMessage()) continue;
        const auto msg = inPort->popMessage();

        //label-based messages have in-line commands
        if (msg.type() == typeid(Pothos::Label))
        {
            const auto &label = msg.convert<Pothos::Label>();
            if (label.id == _freqLabelId and label.data.canConvert(typeid(double)))
            {
                this->setCenterFrequency(label.data.convert<double>());
            }
            if (label.id == _rateLabelId and label.data.canConvert(typeid(double)))
            {
                this->setSampleRate(label.data.convert<double>());
            }
        }

        //packet-based messages have payloads to FFT
        if (msg.type() == typeid(Pothos::Packet))
        {
            const auto &buff = msg.convert<Pothos::Packet>().payload;
            auto floatBuff = buff.convert(Pothos::DType(typeid(std::complex<float>)), buff.elements());

            //safe guard against FFT size changes, old buffers could still be in-flight
            if (floatBuff.elements() != this->numFFTBins()) continue;

            //power bins to points on the curve
            CArray fftBins(floatBuff.as<const std::complex<float> *>(), this->numFFTBins());
            const auto powerBins = fftPowerSpectrum(fftBins, _window.call<std::vector<double>>("window"), _window.call<double>("power"));
            if (not _queueDepth[inPort->index()]) _queueDepth[inPort->index()].reset(new std::atomic<size_t>(0));
            _queueDepth[inPort->index()]->fetch_add(1);
            QMetaObject::invokeMethod(this, "handlePowerBins", Qt::QueuedConnection, Q_ARG(int, inPort->index()), Q_ARG(std::valarray<float>, powerBins));
        }
    }
}
开发者ID:m0x72,项目名称:pothos,代码行数:39,代码来源:PeriodogramWork.cpp

示例7: extensions

std::vector<IIntroDescriptor::Pointer> IntroRegistry::GetIntros() const
{
  const IExtensionPoint* point =
      Platform::GetExtensionPointService()->GetExtensionPoint(
          PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_INTRO);
  if (!point)
  {
    return std::vector<IIntroDescriptor::Pointer>();
  }

  std::vector<const IExtension*> extensions(point->GetExtensions());
  extensions = RegistryReader::OrderExtensions(extensions);

  std::vector<IIntroDescriptor::Pointer> list;
  for (std::size_t i = 0; i < extensions.size(); i++)
  {
    std::vector<IConfigurationElement::Pointer> elements(
        extensions[i] ->GetConfigurationElements());
    for (std::size_t j = 0; j < elements.size(); j++)
    {
      if (elements[j]->GetName() == TAG_INTRO)
      {
        try
        {
          IIntroDescriptor::Pointer
              descriptor(new IntroDescriptor(elements[j]));
          list.push_back(descriptor);
        } catch (CoreException& e)
        {
          // log an error since its not safe to open a dialog here
          //TODO IStatus
          WorkbenchPlugin::Log("Unable to create intro descriptor", e); // e.getStatus());
        }
      }
    }
  }

  return list;
}
开发者ID:test-fd301,项目名称:MITK,代码行数:39,代码来源:berryIntroRegistry.cpp

示例8: enumeration_element_list

ProcessParameter::enumeration_element_list ProcessParameter::EnumerationElements() const
{
   if ( !IsEnumeration() )
      return enumeration_element_list();

   size_type count = (*API->Process->GetParameterElementCount)( m_data->handle );
   if ( count == 0 )
      throw APIFunctionError( "GetParameterElementCount" );

   enumeration_element_list elements( count );

   for ( size_type i = 0; i < count; ++i )
   {
      size_type len = 0;
      (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, 0, &len );
      if ( len == 0 )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.SetLength( len );
      if ( (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, elements[i].id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.ResizeToNullTerminated();

      len = 0;
      (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, 0, &len );
      if ( len > 0 )
      {
         IsoString aliases;
         aliases.SetLength( len );
         if ( (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, aliases.c_str(), &len ) == api_false )
            throw APIFunctionError( "GetParameterElementAliasIdentifiers" );
         aliases.ResizeToNullTerminated();
         aliases.Break( elements[i].aliases, ',' );
      }

      elements[i].value = (*API->Process->GetParameterElementValue)( m_data->handle, i );
   }

   return elements;
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:39,代码来源:ProcessParameter.cpp

示例9: operator

      void operator()( viennagrid::detail::tag<ElementT> )
      {
        typedef typename viennagrid::result_of::element_range<MeshViewT, ElementT>::type ToEraseElementRangeType;
        typedef typename viennagrid::result_of::iterator<ToEraseElementRangeType>::type ToEraseElementRangeIterator;

        typedef typename viennagrid::result_of::handle<MeshT, ElementT>::type ElementHandle;
        typedef typename viennagrid::result_of::element_range<MeshT, ElementT>::type ElementRangeType;
        typedef typename viennagrid::result_of::iterator<ElementRangeType>::type ElementRangeIterator;

        typedef typename viennagrid::result_of::id<ElementT>::type id_type;

  //             std::vector< std::pair<element_range_iterator, element_range_iterator> > swtiching_map;

        std::deque<id_type> ids_to_erase;

        ToEraseElementRangeType elements_to_erase(view_to_erase_);
        for (ToEraseElementRangeIterator it = elements_to_erase.begin(); it != elements_to_erase.end(); ++it)
          ids_to_erase.push_back( it->id() );

        ElementRangeType elements(mesh_obj_);

        for (typename std::deque<id_type>::iterator it = ids_to_erase.begin(); it != ids_to_erase.end(); ++it)
        {
          ElementRangeIterator to_erase_it = find( mesh_obj_, *it );
          ElementRangeIterator back_it = --elements.end();

          if (back_it != to_erase_it)
          {
            ElementHandle old_handle = back_it.handle();
            std::swap( *back_it, *to_erase_it );
            ElementHandle new_handle = to_erase_it.handle();

            switch_handle( mesh_obj_, old_handle, new_handle );
          }

          elements.erase( back_it );
        }
      }
开发者ID:masteroftime,项目名称:viennagrid-dev,代码行数:38,代码来源:element_deletion.hpp

示例10: copy

      void copy(viennashe::math::sparse_matrix<NumericT> const & assembled_matrix,
                viennacl::compressed_matrix<NumericT>          &       vcl_matrix)
      {
        std::size_t nonzeros = assembled_matrix.nnz();
        viennacl::backend::typesafe_host_array<unsigned int> row_buffer(vcl_matrix.handle1(), assembled_matrix.size1() + 1);
        viennacl::backend::typesafe_host_array<unsigned int> col_buffer(vcl_matrix.handle2(), nonzeros);
        std::vector<NumericT> elements(nonzeros);

        std::size_t data_index = 0;

        for (std::size_t i  = 0;
                         i != assembled_matrix.size1();
                       ++i)
        {
          typedef typename viennashe::math::sparse_matrix<NumericT>::const_iterator2   AlongRowIterator;
          typedef typename viennashe::math::sparse_matrix<NumericT>::row_type          RowType;

          row_buffer.set(i, data_index);
          RowType const & row_i = assembled_matrix.row(i);

          for (AlongRowIterator col_it  = row_i.begin();
                                col_it != row_i.end();
                              ++col_it)
          {
            col_buffer.set(data_index, col_it->first);
            elements[data_index] = col_it->second;
            ++data_index;
          }
        }
        row_buffer.set(assembled_matrix.size1(), data_index);

        vcl_matrix.set(row_buffer.get(),
                       col_buffer.get(),
                       &elements[0],
                       assembled_matrix.size1(),
                       assembled_matrix.size2(),
                       nonzeros);
      }
开发者ID:viennashe,项目名称:viennashe-dev,代码行数:38,代码来源:serial_linear_solver.hpp

示例11: mapNodeFace

void FaceCellConnectivity::build_connectivity()
{

  if (used().size() == 0 )
  {
    CFwarn << "No elements are given to build faces of" << CFendl;
    return;
  }

  // sanity check
//  CFinfo << "building face_cell connectivity using " << CFendl;
//  boost_foreach(Handle< Component > cells, used() )
//  {
//    CFinfo << "  " << cells->uri().path() << CFendl;
//  }

  // declartions
  m_connectivity->resize(0);
  common::Table<Entity>::Buffer f2c = m_connectivity->create_buffer();
  common::Table<Uint>::Buffer face_number = m_face_nb_in_elem->create_buffer();
  common::List<bool>::Buffer is_bdry_face = m_is_bdry_face->create_buffer();
  Dictionary& geometry_fields = find_parent_component<Mesh>(*used()[0]).geometry_fields();
  Uint tot_nb_nodes = geometry_fields.size();
  std::vector < std::vector<Uint> > mapNodeFace(tot_nb_nodes);
  std::vector<Uint> face_nodes;  face_nodes.reserve(100);
  std::vector<Entity> dummy_element_row(2);
  std::vector<Uint> dummy_idx_row(2);
  Uint max_nb_faces(0);

  // calculate max_nb_faces
  boost_foreach ( Handle< Component > elements_comp, used() )
  {
    Handle<Elements> elements(elements_comp);
    if (elements->element_type().dimensionality() != elements->element_type().dimension() )
      continue;
    const Uint nb_faces = elements->element_type().nb_faces();
    max_nb_faces += nb_faces * elements->size() ;
  }
开发者ID:jaswi,项目名称:coolfluid3,代码行数:38,代码来源:FaceCellConnectivity.cpp

示例12: work

    void work(void)
    {
        auto inputPort = this->input(0);
        auto outputPort = this->output(0);

        while (inputPort->hasMessage() and _elementsLeft != 0)
        {
            auto m = inputPort->popMessage();
            outputPort->postMessage(m);
            _elementsLeft -= 1;
        }

        auto buffer = inputPort->buffer();
        //input port type unspecified, inspect buffer for actual element count
        const size_t elems = std::min(_elementsLeft, buffer.elements());
        if (elems != 0)
        {
            buffer.length = elems*buffer.dtype.size();
            outputPort->postBuffer(buffer);
            inputPort->consume(buffer.length);
            _elementsLeft -= elems;
        }
    }
开发者ID:arunlodhi,项目名称:pothos,代码行数:23,代码来源:FiniteRelease.cpp

示例13: strides

void Array<T>::eval()
{
    if (isReady()) return;

    this->setId(getActiveDeviceId());
    data = std::shared_ptr<T>(memAlloc<T>(elements()), memFree<T>);
    T *ptr = data.get();

    dim4 ostrs = strides();
    dim4 odims = dims();

    for (int w = 0; w < (int)odims[3]; w++) {
        dim_t offw = w * ostrs[3];

        for (int z = 0; z < (int)odims[2]; z++) {
            dim_t offz = z * ostrs[2] + offw;

            for (int y = 0; y < (int)odims[1]; y++) {
                dim_t offy = y * ostrs[1] + offz;

                for (int x = 0; x < (int)odims[0]; x++) {
                    dim_t id = x + offy;

                    ptr[id] = *(T *)node->calc(x, y, z, w);
                }
            }
        }
    }


    ready = true;

    Node_ptr prev = node;
    prev->reset();
    // FIXME: Replace the current node in any JIT possible trees with the new BufferNode
    node.reset();
}
开发者ID:klemmster,项目名称:arrayfire,代码行数:37,代码来源:Array.cpp

示例14: assert

void LogicAnalyzerDisplay::populateChannel(const int channel, const Pothos::Packet &packet)
{
    //convert buffer (does not convert when type matches)
    const auto numericBuff = packet.payload.convert(typeid(T));
    assert(_chData.size() > channel);
    _chData[channel] = packet;
    _chData[channel].payload = numericBuff;

    //load element data into table
    for (size_t i = 0; i < numericBuff.elements(); i++)
    {
        const auto num = numericBuff.as<const T *>()[i];
        const auto s = toStr(num, _chBase.at(channel));
        auto item = new QTableWidgetItem(s);
        auto flags = item->flags();
        flags &= ~Qt::ItemIsEditable;
        item->setFlags(flags);
        item->setTextAlignment(Qt::AlignRight);
        _tableView->setItem(channel, i, item);
    }

    //inspect labels to decorate table
    for (const auto &label : packet.labels)
    {
        const int column = label.index;
        assert(column < _tableView->columnCount());
        auto item = _tableView->item(channel, column);

        //highlight and display label id
        item->setBackground(Qt::yellow);
        item->setText(QString("%1\n%2")
            .arg(item->text())
            .arg(QString::fromStdString(label.id)));
        _tableView->resizeColumnToContents(column);
    }
}
开发者ID:m0x72,项目名称:pothos,代码行数:36,代码来源:LogicAnalyzerDisplay.cpp

示例15: permute_sign

int permute_sign(int n, ...){
	int sign=1;
	va_list ap;
	va_start(ap,n);
	vector<int> elements(n,0);
	
	for(int j=0; j<n; j++){
		elements[j]=va_arg(ap,int);
	}
	va_end(ap);
	
	int temp;
	for(int j=n;j>0;j--){
		for(int i=0;i<j-1;i++){
			if(elements[i]>elements[i+1]){
				 temp=elements[i];
				 elements[i]=elements[i+1];
				 elements[i+1]=temp;
				 sign*=-1;
			}
		}
	}
	return sign;
}		
开发者ID:scottgeraedts,项目名称:myClibrary,代码行数:24,代码来源:utils.cpp


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