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


C++ Element函数代码示例

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


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

示例1: operator

  Space operator()( int color )
  {
    Space base, sub, margin;

    for ( typename Space::const_iterator it = base_.begin()
        ; it != base_.end(); ++it
        )
    {
      typename Space::const_point pt( it );

      if ( color_[ pt.index ] == color ) base.join( pt.element );
    }
    for ( typename Space::const_iterator it = base.begin()
        ; it != base.end(); ++it
        )
    {
      typename Space::const_point pt0( it );
#ifdef ELAI_USE_C11
      const Space&& adj = std::move( adjacent_( pt0.element ) );
#else
      const Space adj = adjacent_( pt0.element );
#endif

      sub.join( Element( pt0.element, color ) );
      for ( typename Space::const_iterator jt = adj.begin()
          ; jt != adj.end(); ++jt
          )
      {
        typename Space::const_point pt( jt );

        if ( base.contain( pt.element ) || margin.contain( Element( pt.element, color ) ) ) continue;

        int c = color_[ base_.index( pt.element ) ];

        margin.join( Element( pt.element, color ), Element( pt.element, c ) );
      }
    }

    return sub | margin;
  }
开发者ID:t-ikegami,项目名称:ELAI,代码行数:40,代码来源:subjugator.hpp

示例2: EnsureItemAt

NS_IMETHODIMP
DOMSVGPathSegList::RemoveItem(PRUint32 aIndex,
                              nsIDOMSVGPathSeg **_retval)
{
    *_retval = nsnull;
    if (IsAnimValList()) {
        return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
    }

    if (aIndex >= Length()) {
        return NS_ERROR_DOM_INDEX_SIZE_ERR;
    }
    // We have to return the removed item, so make sure it exists:
    EnsureItemAt(aIndex);

    // Notify the DOM item of removal *before* modifying the lists so that the
    // DOM item can copy its *old* value:
    ItemAt(aIndex)->RemovingFromList();
    NS_ADDREF(*_retval = ItemAt(aIndex));

    PRUint32 internalIndex = mItems[aIndex].mInternalDataIndex;
    PRUint32 segType = SVGPathSegUtils::DecodeType(InternalList().mData[internalIndex]);
    PRUint32 argCount = SVGPathSegUtils::ArgCountForType(segType);

    // Now that we know we're removing, keep animVal list in sync as necessary.
    // Do this *before* touching InternalList() so the removed item can get its
    // internal value.
    MaybeRemoveItemFromAnimValListAt(aIndex, argCount);

    InternalList().mData.RemoveElementsAt(internalIndex, 1 + argCount);
    mItems.RemoveElementAt(aIndex);

    UpdateListIndicesFromIndex(aIndex, -(argCount + 1));

    Element()->DidChangePathSegList(true);
    if (AttrIsAnimating()) {
        Element()->AnimationNeedsResample();
    }
    return NS_OK;
}
开发者ID:rfk,项目名称:services-central,代码行数:40,代码来源:DOMSVGPathSegList.cpp

示例3: SwapRows

// Reduces all elements in a column except the diagonal element
// Returns 0 on success, 1 if the column cannot be reduced
int Matrix::ReduceColumn(int column, Matrix &inverse)
{
	// loop variable for working down column
	int row, pivot = column;

	// find the first non-zero element in the column
	// that is not above the diagonal
	for (row = pivot; row < 4; row++)
		if (fabs(Element(row, pivot)) > ERROR_TOLERANCE)
			break;

	// if we didn't find one, return an error code
	if (row == 4) return 1;

	// if we did, but it wasn't on the diagonal, swap with the pivot row
	// this makes sure we never get divide by zero errors
	if (row != pivot)
	{
		SwapRows(pivot, row);
		inverse.SwapRows(pivot, row);
	}

	// now scale the pivot row so the pivot element is one
	float scaleFactor = 1.0 / Element(pivot, pivot);
	ScaleRow(pivot, scaleFactor);
	inverse.ScaleRow(pivot, scaleFactor);

	// for each row
	for (row = 0; row < 4; row++)
	{
		// skip the row we're pivoting on
		if (row == column) continue;
		scaleFactor = -Element(row, pivot);
		AddRows(row, scaleFactor, pivot);
		inverse.AddRows(row, scaleFactor, pivot);
	}

	// and we're done
	return 0;
}
开发者ID:timothyandrew,项目名称:minigolf,代码行数:42,代码来源:Matrix.cpp

示例4: Element

void IceLiveRange::addSegment(int Start, int End) {
#ifdef USE_SET
  RangeElementType Element(Start, End);
  RangeType::iterator Next = Range.lower_bound(Element);
  assert(Next == Range.upper_bound(Element)); // Element not already present

  // Beginning of code that merges contiguous segments.  TODO: change
  // "if(true)" to "if(false)" to see if this extra optimization code
  // gives any performance gain, or is just destabilizing.
  if (true) {
    RangeType::iterator FirstDelete = Next;
    RangeType::iterator Prev = Next;
    bool hasPrev = (Next != Range.begin());
    bool hasNext = (Next != Range.end());
    if (hasPrev)
      --Prev;
    // See if Element and Next should be joined.
    if (hasNext && End == Next->first) {
      Element.second = Next->second;
      ++Next;
    }
    // See if Prev and Element should be joined.
    if (hasPrev && Prev->second == Start) {
      Element.first = Prev->first;
      FirstDelete = Prev;
    }
    Range.erase(FirstDelete, Next);
  }
  // End of code that merges contiguous segments.

  Range.insert(Next, Element);
#else
  if (Range.empty()) {
    Range.push_back(RangeElementType(Start, End));
    return;
  }
  // Special case for faking in-arg liveness.
  if (End < Range.front().first) {
    assert(Start < 0);
    Range.push_front(RangeElementType(Start, End));
    return;
  }
  int CurrentEnd = Range.back().second;
  assert(Start >= CurrentEnd);
  // Check for merge opportunity.
  if (Start == CurrentEnd) {
    Range.back().second = End;
    return;
  }
  Range.push_back(RangeElementType(Start, End));
#endif
}
开发者ID:c0d1f1ed,项目名称:subzero,代码行数:52,代码来源:IceOperand.cpp

示例5: Element

void SparseMatrix::set_element_at(int i, int j, double n){
    Element temp = Element(j,n);
    bool exist = false;
    DListNode<Element> *trav = row(i).getFirst();
    while(trav != NULL && trav != row(i).getAfterLast()){
        if(trav->getElem().col == j){
            exist = true;
            trav->getElemRef()->setVal(n);
        }
        trav = trav->getNext();
    }
    if(!exist) row(i).insertLast(temp);
}
开发者ID:sandanzuki,项目名称:sophomore-code-dump,代码行数:13,代码来源:sparsematrix.cpp

示例6: Train

    void Train(InputType& data, OutputType& target)
    {
      // Reset the training error.
      trainingError = 0;

      for (size_t i = 0; i < index.n_elem; i++)
      {
        net.FeedForward(Element(data, index(i)),
            Element(target, index(i)), error);

        trainingError += net.Error();
        net.FeedBackward(error);

        if (((i + 1) % batchSize) == 0)
          net.ApplyGradients();
      }

      if ((index.n_elem % batchSize) != 0)
        net.ApplyGradients();

      trainingError /= index.n_elem;
    }
开发者ID:0x0all,项目名称:mlpack,代码行数:22,代码来源:trainer.hpp

示例7: Element

already_AddRefed<SVGTransform>
DOMSVGTransformList::IndexedGetter(uint32_t index, bool& found,
                                   ErrorResult& error)
{
  if (IsAnimValList()) {
    Element()->FlushAnimations();
  }
  found = index < LengthNoFlush();
  if (found) {
    return GetItemAt(index);
  }
  return nullptr;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:13,代码来源:DOMSVGTransformList.cpp

示例8: assert

int CUtlVector<T, A>::InsertBefore(int elem, const T& src)
{
    // Can't insert something that's in the list... reallocation may hose us
    assert((Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count())));

    // Can insert at the end
    assert((elem == Count()) || IsValidIndex(elem));

    GrowVector();
    ShiftElementsRight(elem);
    CopyConstruct(&Element(elem), src);
    return elem;
}
开发者ID:GodLS,项目名称:math-homework,代码行数:13,代码来源:UtlVector.hpp

示例9: Write_Node

void Write_Node(TreeNode Node)
{
   int i;

   for (i=1; i <= Rank(Node); i++)
      Write_Node(Child(Node, i));

   Write_String(Tree_File, NodeName(Node));
   fprintf(Tree_File,"\n");
   Write_String(Tree_File, SourceLocation(Node));
   fprintf(Tree_File,"\n");
   fprintf(Tree_File,"%1d\n", Element(Tree,Node+2));
}
开发者ID:MARFMS,项目名称:chiquitico,代码行数:13,代码来源:Tree.c

示例10: Decoration

TreeNode Decoration(TreeNode T)
{
   int Neg;
   int Value;

   Value = Element(Tree,T+2);
   Neg = Value < 0;

   if (Neg) 
      return -(abs(Value) / 1000);
   else 
      return Value / 1000;
}
开发者ID:MARFMS,项目名称:chiquitico,代码行数:13,代码来源:Tree.c

示例11: Decorate

void Decorate(TreeNode T1, TreeNode T2)
{
   int Neg;
   int NewValue;

   Neg = (T2 < 0);
   NewValue = abs(Element(Tree, T1+2)) % 1000 + abs(T2) * 1000;

   if (Neg) 
      Assign(Tree, T1 + 2, -NewValue);
   else 
      Assign(Tree, T1 + 2, NewValue);
}
开发者ID:MARFMS,项目名称:chiquitico,代码行数:13,代码来源:Tree.c

示例12: AddToTail

void CAI_InterestTarget::Add( CAI_InterestTarget_t::CAI_InterestTarget_e type, CBaseEntity *pTarget, const Vector &vecPosition, float flImportance, float flDuration, float flRamp )
{
	int i = AddToTail();
	CAI_InterestTarget_t &target = Element( i );

	target.m_eType = type;
	target.m_hTarget = pTarget;
	target.m_vecPosition = vecPosition;
	target.m_flInterest = flImportance;
	target.m_flStartTime = gpGlobals->curtime;
	target.m_flEndTime = gpGlobals->curtime + flDuration;
	target.m_flRamp = flRamp / flDuration;
}
开发者ID:KissLick,项目名称:sourcemod-npc-in-css,代码行数:13,代码来源:CAI_Interest_Target.cpp

示例13: SelectSamples

void DESolver::Rand2Bin(int candidate)
{
	int r1, r2, r3, r4, r5;
	int n;

	SelectSamples(candidate,&r1,&r2,&r3,&r4,&r5);
	n = (int)RandomUniform(0.0,(double)nDim);

	CopyVector(trialSolution,RowVector(population,candidate));
	for (int i=0; i < nDim; i++) 
	{
		if ((RandomUniform(0.0,1.0) < probability) || (i  == (nDim - 1)))
			trialSolution[n] = Element(population,r1,n)
								+ scale * (Element(population,r2,n)
											+ Element(population,r3,n)
											- Element(population,r4,n)
											- Element(population,r5,n));
		n = (n + 1) % nDim;
	}

	return;
}
开发者ID:hamiltonkibbe,项目名称:Capstone-BCI-Flight-Simulator,代码行数:22,代码来源:DESolver.cpp

示例14: InternalItem

void DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) {
  if (mIsAnimValItem) {
    aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
    return;
  }

  if (mVal) {
    aRv = mVal->SetBaseValue(aUserUnitValue, mSVGElement, true);
    return;
  }

  // Although the value passed in is in user units, this method does not turn
  // this length into a user unit length. Instead it converts the user unit
  // value to this length's current unit and sets that, leaving this length's
  // unit as it is.

  if (HasOwner()) {
    if (InternalItem().GetValueInUserUnits(Element(), Axis()) ==
        aUserUnitValue) {
      return;
    }
    float uuPerUnit = InternalItem().GetUserUnitsPerUnit(Element(), Axis());
    if (uuPerUnit > 0) {
      float newValue = aUserUnitValue / uuPerUnit;
      if (IsFinite(newValue)) {
        AutoChangeLengthNotifier notifier(this);
        InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit());
        return;
      }
    }
  } else if (mUnit == SVGLength_Binding::SVG_LENGTHTYPE_NUMBER ||
             mUnit == SVGLength_Binding::SVG_LENGTHTYPE_PX) {
    mValue = aUserUnitValue;
    return;
  }
  // else [SVGWG issue] Can't convert user unit value to this length's unit
  // ReportToConsole
  aRv.Throw(NS_ERROR_FAILURE);
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:39,代码来源:DOMSVGLength.cpp

示例15: Element

uint16_t DOMSVGLength::UnitType() {
  if (mVal) {
    if (mIsAnimValItem) {
      mSVGElement->FlushAnimations();
    }
    return mVal->mSpecifiedUnitType;
  }

  if (mIsAnimValItem && HasOwner()) {
    Element()->FlushAnimations();  // May make HasOwner() == false
  }
  return HasOwner() ? InternalItem().GetUnit() : mUnit;
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:13,代码来源:DOMSVGLength.cpp


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