本文整理汇总了C++中Aggregate::elements方法的典型用法代码示例。如果您正苦于以下问题:C++ Aggregate::elements方法的具体用法?C++ Aggregate::elements怎么用?C++ Aggregate::elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aggregate
的用法示例。
在下文中一共展示了Aggregate::elements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: match
AggregateOrdered ET::match(const Aggregate s,AggregateOrdered positions, Obj pat,AggregateOrdered r){
SWITCHstart
CASEIF(pat.isInstanceOf(classInt))
uWord sn=s.elements();
// looping on the positions
// if a position is between start and end and the pattern equals
// the value at pos then add the next position to the results.
for(auto p:positions){
if(0<=p && p<sn && pat.w==s[p])
r&=p+1; //&= adds a single object to an ordered aggregate (if it doesn't exists already)
}
CASEIF(pat.isInstanceOf(classDouble))
uWord sn=s.elements();
for(auto p:positions){
if(0<=p && p<sn && compare(pat,s[p])==0)
r&=p+1; //&= adds a single object to an ordered aggregate (if it doesn't exists already)
}
CASEIF(pat.isInstanceOf(classPatternAll))
AggregateOrdered r1=positions;
for(auto pat1:(Aggregate)pat)
r1=match(s,r1,pat1);
if(r.elements()==0) r=r1;else r+=r1;
CASEIF(pat.isInstanceOf(classPatternAny))
for(auto pat1:(Aggregate)pat)
match(s,positions,pat1,r);
CASEIF(pat.isInstanceOf(classAggregate))
stack().push(positions);
execute(pat,true); // should execute independently from the execution status ? should be explained !
r=stack().pop();
DEFAULT
assert0(false,"unexpected in matchAll");
endSWITCH
return r;
}
示例2: insertSlice
// appends to the current aggregate a slice from a given aggregate from position i1 to position i2
void Aggregate::insertSlice(Aggregate a,Word pos,Word i1,Word i2){
ADJUSTOFFSET(elements(),pos);ADJUSTOFFSET2(a.elements(),i1,i2);assert0(i1<=i2,"appendSlice");
Word sz=i2-i1;checkResize(sz);
elements(elements()+sz);
WordMove(dataP()+pos+sz,dataP()+pos,elements()-pos);
WordCpy(dataP()+pos,a.dataP()+i1,sz);
}
示例3: match
AggregateOrdered match(const Aggregate s,AggregateOrdered positions, Obj pat,AggregateOrdered r=0,Word pn=1){
// p holds the positions array that may have 1 or 2 columns per raw
#define loop(aa,step) for(Word i=0,i1=aa.elements(),p;i<i1 && (p=aa[i],true);i+=step)
switch(pat.Class().w){
case _classInt:{
if(!r)
r=AggregateOrdered();
uWord sn=s.elements();
loop(positions,pn){
if(0<=p && p+1<=sn && s[p]==pat.w) r.keyExists((Obj)(p+1));
}
};
break;
case _classAggregate:
stack.push(positions);
execute(pat,true);
r=stack.pop();
break;
case _classString:
case _classPatternAll:{
AggregateOrdered r1=positions;
for(auto pat1:(Aggregate)pat)
r1=match(s,r1,pat1);
if(!r) r=r1;else r+=r1;
break;
}
case _classPatternAny:
if(!r)
r=AggregateOrdered();
for(auto pat1:(Aggregate)pat)
match(s,positions,pat1,r);
break;
default:
assert0(false,"unexpected in matchAll");
break;
}
return r;
}
示例4: matchEnd
AggregateOrdered ET::matchEnd(Aggregate s,AggregateOrdered positions){
AggregateOrdered r;
if(positions.keyExists(s.elements(),false))
r.push(s.elements());
return r;
}
示例5: allPos
Aggregate ET::allPos(Aggregate s,Word startPos){
uWord sn=s.elements(),n=(startPos<=sn?sn-startPos:0);
Aggregate r(n,n);
for(uWord i=0,j=startPos;i<n;i++,j++) r[i]=j;
return r;
}
示例6: allPos
Aggregate allPos(Aggregate s){
uWord sn=s.elements();Aggregate r(sn,sn);
for(uWord i=0;i<s.elements();i++) r[i]=i;
return r;
}