本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}