本文整理汇总了C++中equal函数的典型用法代码示例。如果您正苦于以下问题:C++ equal函数的具体用法?C++ equal怎么用?C++ equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wWinMain
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdParamarg, int cmdShow) {
openLog();
#ifdef _NEED_WIN_GENERATE_DUMP
_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
#endif
writeLog(L"Updaters started..");
LPWSTR *args;
int argsCount;
bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false, testmode = false;
args = CommandLineToArgvW(GetCommandLine(), &argsCount);
if (args) {
for (int i = 1; i < argsCount; ++i) {
if (equal(args[i], L"-update")) {
needupdate = true;
} else if (equal(args[i], L"-autostart")) {
autostart = true;
} else if (equal(args[i], L"-debug")) {
debug = _debug = true;
openLog();
} else if (equal(args[i], L"-startintray")) {
startintray = true;
} else if (equal(args[i], L"-testmode")) {
testmode = true;
} else if (equal(args[i], L"-writeprotected") && ++i < argsCount) {
writeprotected = true;
updateTo = args[i];
for (int i = 0, l = updateTo.size(); i < l; ++i) {
if (updateTo[i] == L'/') {
updateTo[i] = L'\\';
}
}
}
}
if (needupdate) writeLog(L"Need to update!");
if (autostart) writeLog(L"From autostart!");
if (writeprotected) writeLog(L"Write Protected folder!");
exeName = args[0];
writeLog(L"Exe name is: " + exeName);
if (exeName.size() > 11) {
if (equal(exeName.substr(exeName.size() - 11), L"Updater.exe")) {
exeDir = exeName.substr(0, exeName.size() - 11);
writeLog(L"Exe dir is: " + exeDir);
if (!writeprotected) {
updateTo = exeDir;
}
writeLog(L"Update to: " + updateTo);
if (needupdate && update()) {
updateRegistry();
}
if (writeprotected) { // if we can't clear all tupdates\ready (Updater.exe is there) - clear only version
if (DeleteFile(L"tupdates\\temp\\tdata\\version") || DeleteFile(L"tupdates\\ready\\tdata\\version")) {
writeLog(L"Version file deleted!");
} else {
writeLog(L"Error: could not delete version file");
}
}
} else {
writeLog(L"Error: bad exe name!");
}
} else {
writeLog(L"Error: short exe name!");
}
LocalFree(args);
} else {
writeLog(L"Error: No command line arguments!");
}
wstring targs;
if (autostart) targs += L" -autostart";
if (debug) targs += L" -debug";
if (startintray) targs += L" -startintray";
if (testmode) targs += L" -testmode";
bool executed = false;
if (writeprotected) { // run un-elevated
writeLog(L"Trying to run un-elevated by temp.lnk");
HRESULT hres = CoInitialize(0);
if (SUCCEEDED(hres)) {
IShellLink* psl;
HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres)) {
IPersistFile* ppf;
wstring exe = updateTo + L"Telegram.exe", dir = updateTo;
psl->SetArguments((targs.size() ? targs.substr(1) : targs).c_str());
psl->SetPath(exe.c_str());
psl->SetWorkingDirectory(dir.c_str());
psl->SetDescription(L"");
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres)) {
wstring lnk = L"tupdates\\temp\\temp.lnk";
hres = ppf->Save(lnk.c_str(), TRUE);
//.........这里部分代码省略.........
示例2: equal
bool operator ==(const read_t& r1, const read_t& r2) {
if (r1.size() != r2.size())
return false;
return equal(r1.begin(), r1.end(), r2.begin());
}
示例3: mStart
//ntlTree::ntlTree(int depth, int objnum, vector<ntlVec3Gfx> *vertices, vector<ntlVec3Gfx> *normals, vector<ntlTriangle> *trilist) :
ntlTree::ntlTree(int depth, int objnum, ntlScene *scene, int triFlagMask) :
mStart(0.0), mEnd(0.0), mMaxDepth( depth ), mMaxListLength( objnum ), mpRoot( NULL) ,
mpNodeStack( NULL), mpTBB( NULL ),
mTriangleMask( 0xFFFF ),
mCurrentDepth(0), mCurrentNodes(0), mTriDoubles(0)
{
// init scene data pointers
mpVertices = scene->getVertexPointer();
mpVertNormals = scene->getVertexNormalPointer();
mpTriangles = scene->getTrianglePointer();
mTriangleMask = triFlagMask;
if(mpTriangles == NULL) {
errFatal( "ntlTree Cons","no triangle list!\n",SIMWORLD_INITERROR);
return;
}
if(mpTriangles->size() == 0) {
warnMsg( "ntlTree::ntlTree","No triangles ("<< mpTriangles->size() <<")!\n");
mStart = mEnd = ntlVec3Gfx(0,0,0);
return;
}
if(depth>=BSP_STACK_SIZE) {
errFatal( "ntlTree::ntlTree","Depth to high ("<< mMaxDepth <<")!\n", SIMWORLD_INITERROR );
return;
}
/* check triangles (a bit inefficient, but we dont know which vertices belong
to this tree), and generate bounding boxes */
mppTriangles = new vector<ntlTriangle *>;
int noOfTriangles = mpTriangles->size();
mpTBB = new TriangleBBox[ noOfTriangles ];
int bbCount = 0;
mStart = mEnd = (*mpVertices)[ mpTriangles->front().getPoints()[0] ];
//errMsg("TreeDebug","Start");
for (vector<ntlTriangle>::iterator iter = mpTriangles->begin();
iter != mpTriangles->end();
iter++ ) {
//errorOut(" d "<< convertFlags2String((int)(*iter).getFlags()) <<" "<< convertFlags2String( (int)mTriangleMask)<<" add? "<<( ((int)(*iter).getFlags() & (int)mTriangleMask) != 0 ) );
// discard triangles that dont match mask
if( ((int)(*iter).getFlags() & (int)mTriangleMask) == 0 ) {
continue;
}
// test? TODO
ntlVec3Gfx tnormal = (*mpVertNormals)[ (*iter).getPoints()[0] ]+
(*mpVertNormals)[ (*iter).getPoints()[1] ]+
(*mpVertNormals)[ (*iter).getPoints()[2] ];
ntlVec3Gfx triangleNormal = (*iter).getNormal();
if( equal(triangleNormal, ntlVec3Gfx(0.0)) ) continue;
if( equal( tnormal, ntlVec3Gfx(0.0)) ) continue;
// */
ntlVec3Gfx bbs, bbe;
//errMsg("TreeDebug","Triangle");
for(int i=0;i<3;i++) {
int index = (*iter).getPoints()[i];
ntlVec3Gfx tp = (*mpVertices)[ index ];
//errMsg("TreeDebug"," Point "<<i<<" = "<<tp<<" ");
if(tp[0] < mStart[0]) mStart[0]= tp[0];
if(tp[0] > mEnd[0]) mEnd[0]= tp[0];
if(tp[1] < mStart[1]) mStart[1]= tp[1];
if(tp[1] > mEnd[1]) mEnd[1]= tp[1];
if(tp[2] < mStart[2]) mStart[2]= tp[2];
if(tp[2] > mEnd[2]) mEnd[2]= tp[2];
if(i==0) {
bbs = bbe = tp;
} else {
if( tp[0] < bbs[0] ) bbs[0] = tp[0];
if( tp[0] > bbe[0] ) bbe[0] = tp[0];
if( tp[1] < bbs[1] ) bbs[1] = tp[1];
if( tp[1] > bbe[1] ) bbe[1] = tp[1];
if( tp[2] < bbs[2] ) bbs[2] = tp[2];
if( tp[2] > bbe[2] ) bbe[2] = tp[2];
}
}
mppTriangles->push_back( &(*iter) );
//errMsg("TreeDebug","Triangle "<<(*mpVertices)[(*iter).getPoints()[0]]<<" "<<(*mpVertices)[(*iter).getPoints()[1]]<<" "<<(*mpVertices)[(*iter).getPoints()[2]]<<" ");
// add BB
mpTBB[ bbCount ].start = bbs;
mpTBB[ bbCount ].end = bbe;
(*iter).setBBoxId( bbCount );
bbCount++;
}
/* slighlty enlarge bounding tolerance for tree
to avoid problems with triangles paralell to slabs */
mStart -= ntlVec3Gfx( getVecEpsilon() );
mEnd += ntlVec3Gfx( getVecEpsilon() );
/* init root node and stack */
mpNodeStack = new BSPStack;
mpRoot = new BSPNode;
mpRoot->min = mStart;
mpRoot->max = mEnd;
mpRoot->axis = AXIS_X;
mpRoot->members = mppTriangles;
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
else if (strchr(arg, '=')) {
if (prefix(arg, "loop")) {
if (lookup(yesno, arg))
sm.sm_config |= CONN_LPBK;
else
sm.sm_config &= ~CONN_LPBK;
loopchange++;
} else if (prefix(arg, "echo")) {
if (lookup(yesno, arg))
sm.sm_config |= CONN_ECHO;
else
sm.sm_config &= ~CONN_ECHO;
echochange++;
} else if (prefix(arg, "nrzi")) {
if (lookup(yesno, arg))
sm.sm_config |= CONN_NRZI;
else
sm.sm_config &= ~CONN_NRZI;
} else if (prefix(arg, "txc")) {
sm.sm_txclock = lookup(txnames, arg);
clockchange++;
} else if (prefix(arg, "rxc")) {
sm.sm_rxclock = lookup(rxnames, arg);
clockchange++;
} else if (prefix(arg, "speed")) {
arg = strchr(arg, '=') + 1;
if (sscanf(arg, "%d", &speed) == 1) {
sm.sm_baudrate = speed;
} else
(void) fprintf(stderr,
"syncinit: %s %s\n",
"bad speed:", arg);
}
} else if (equal(arg, "external")) {
sm.sm_txclock = TXC_IS_TXC;
sm.sm_rxclock = RXC_IS_RXC;
sm.sm_config &= ~CONN_LPBK;
} else if (equal(arg, "sender")) {
sm.sm_txclock = TXC_IS_BAUD;
sm.sm_rxclock = RXC_IS_RXC;
sm.sm_config &= ~CONN_LPBK;
} else if (equal(arg, "internal")) {
sm.sm_txclock = TXC_IS_PLL;
sm.sm_rxclock = RXC_IS_PLL;
sm.sm_config &= ~CONN_LPBK;
} else if (equal(arg, "stop")) {
sm.sm_baudrate = 0;
} else
(void) fprintf(stderr, "Bad arg: %s\n", arg);
}
/*
* If we're going to change the state of loopback, and we
* don't have our own plans for clock sources, use defaults.
*/
if (loopchange && !clockchange) {
if (sm.sm_config & CONN_LPBK) {
sm.sm_txclock = TXC_IS_BAUD;
sm.sm_rxclock = RXC_IS_BAUD;
} else {
sm.sm_txclock = TXC_IS_TXC;
sm.sm_rxclock = RXC_IS_RXC;
}
}
sioc.ic_cmd = S_IOCSETMODE;
sioc.ic_timout = -1;
示例5: yysimfac
static int
yysimfac(int h)
{
int i, j;
for (i = h; i < tos; i++) {
p1 = stack[i];
for (j = h; j < tos; j++) {
if (i == j)
continue;
p2 = stack[j];
// n! / n -> (n - 1)!
if (car(p1) == symbol(FACTORIAL)
&& car(p2) == symbol(POWER)
&& isminusone(caddr(p2))
&& equal(cadr(p1), cadr(p2))) {
push(cadr(p1));
push(one);
subtract();
factorial();
stack[i] = pop();
stack[j] = one;
return 1;
}
// n / n! -> 1 / (n - 1)!
{
int a,b,c,d;
a = car(p2) == symbol(POWER);
b = isminusone(caddr(p2));
c = caadr(p2) == symbol(FACTORIAL);
d = equal(p1, cadadr(p2));
if ( a
&& b
&& c
&& d){
push(p1);
push_integer(-1);
add();
factorial();
reciprocate();
stack[i] = pop();
stack[j] = one;
return 1;
}
}
// (n + 1) n! -> (n + 1)!
if (car(p2) == symbol(FACTORIAL)) {
push(p1);
push(cadr(p2));
subtract();
p3 = pop();
if (isplusone(p3)) {
push(p1);
factorial();
stack[i] = pop();
stack[j] = one;
return 1;
}
}
// 1 / ((n + 1) n!) -> 1 / (n + 1)!
if (car(p1) == symbol(POWER)
&& isminusone(caddr(p1))
&& car(p2) == symbol(POWER)
&& isminusone(caddr(p2))
&& caadr(p2) == symbol(FACTORIAL)) {
push(cadr(p1)); // modified
push(car(cdr(cadr(p2))));
subtract();
p3 = pop();
if (isplusone(p3)) {
push(cadr(p1));
factorial();
reciprocate();
stack[i] = pop();
stack[j] = one;
return 1;
}
}
// (n + 1)! / n! -> n + 1
// n! / (n + 1)! -> 1 / (n + 1)
if (car(p1) == symbol(FACTORIAL)
&& car(p2) == symbol(POWER)
&& isminusone(caddr(p2))
&& caadr(p2) == symbol(FACTORIAL)) {
push(cadr(p1));
push(car(cdr(cadr(p2))));
subtract();
p3 = pop();
if (isplusone(p3)) {
stack[i] = cadr(p1);
//.........这里部分代码省略.........
示例6: quaternionTest
int __EXPORT quaternionTest()
{
printf("Test Quaternion\t\t: ");
// test default ctor
Quaternion q;
ASSERT(equal(q.getA(), 1));
ASSERT(equal(q.getB(), 0));
ASSERT(equal(q.getC(), 0));
ASSERT(equal(q.getD(), 0));
// test float ctor
q = Quaternion(0, 1, 0, 0);
ASSERT(equal(q.getA(), 0));
ASSERT(equal(q.getB(), 1));
ASSERT(equal(q.getC(), 0));
ASSERT(equal(q.getD(), 0));
// test euler ctor
q = Quaternion(EulerAngles(0, 0, 0));
ASSERT(equal(q.getA(), 1));
ASSERT(equal(q.getB(), 0));
ASSERT(equal(q.getC(), 0));
ASSERT(equal(q.getD(), 0));
// test dcm ctor
q = Quaternion(Dcm());
ASSERT(equal(q.getA(), 1));
ASSERT(equal(q.getB(), 0));
ASSERT(equal(q.getC(), 0));
ASSERT(equal(q.getD(), 0));
// TODO test derivative
// test accessors
q.setA(0.1);
q.setB(0.2);
q.setC(0.3);
q.setD(0.4);
ASSERT(equal(q.getA(), 0.1));
ASSERT(equal(q.getB(), 0.2));
ASSERT(equal(q.getC(), 0.3));
ASSERT(equal(q.getD(), 0.4));
printf("PASS\n");
return 0;
}
示例7: equal_impl
static constexpr auto equal_impl(M1 x, M2 y)
{ return equal(x.value, y.value); }
示例8: equal
bool operator == (const Point3D<T>& lhs, const Point3D<T>& rhs) {
std::equal_to<T> equal;
return equal(lhs.x, rhs.x) &&
equal(lhs.y, rhs.y) &&
equal(lhs.z, rhs.z);
}
示例9: less
bool operator < (const Point2D<T>& lhs, const Point2D<T>& rhs) {
std::less<T> less;
std::equal_to<T> equal;
return less(lhs.x, rhs.x) || equal(lhs.x, rhs.x) && less(lhs.y, rhs.y);
}
示例10: switch
/*
* Return a pointer to a map projection structure given the arguments
* below. If this is a new projection we'll allocate a new projection
* struct and return a pointer to it. If this projection is already in
* the list, just return a pointer to it.
* Input: kind - the type of projection, one of PROJ_*
* nr, nc - number of rows and columns of data
* args - array of projection parameters
* Return: pointer to a projection struct.
*/
struct projection *new_projection( struct grid_db *db, int kind,
int nr, int nc, float *args )
{
int p, i, nargs;
/* determine how many arguments are in the args array */
switch (kind) {
case PROJ_GENERIC: nargs = 4; break;
case PROJ_LINEAR: nargs = 4; break;
case PROJ_LAMBERT: nargs = 6; break;
case PROJ_STEREO: nargs = 5; break;
case PROJ_ROTATED: nargs = 7; break;
case PROJ_EPA: nargs = nr*nc*2; break;
case PROJ_CYLINDRICAL: nargs = 4; break;
case PROJ_SPHERICAL: nargs = 4; break;
case PROJ_MERCATOR: nargs = 4; break;
default:
printf("Fatal error in new_projection!\n");
exit(-1);
}
/* Search projection list for a possible match */
for (p=0; p<db->NumProj; p++) {
if ( db->ProjList[p]->Kind==kind
&& db->ProjList[p]->Nr==nr
&& db->ProjList[p]->Nc==nc) {
int same = 1;
for (i=0;i<nargs;i++) {
if ( !equal(args[i], db->ProjList[p]->Args[i]) ) {
same = 0;
break;
}
}
if (same) {
return db->ProjList[p];
}
}
}
/* if we get here, the projection is not in the list, make a new one */
if (db->NumProj<IMAXPROJ) {
struct projection *newp;
/* 01Feb06 Phil McDonald */
newp = (struct projection *) TMP_CALLOC (1, sizeof (struct projection));
/* end PM */
newp->Kind = kind;
newp->Nr = nr;
newp->Nc = nc;
newp->Args = (float *) MALLOC( nargs * sizeof(float) );
for (i=0;i<nargs;i++) {
newp->Args[i] = args[i];
}
/* compute extra, optional proj args */
compute_aux_proj_args( newp );
/* add to end of list */
db->ProjList[db->NumProj] = newp;
db->NumProj++;
return newp;
}
else {
printf("Error: too many map projections, %d is limit\n", IMAXPROJ );
return NULL;
}
}
示例11: command
STATIC union node *
command() {
union node *n1, *n2;
union node *ap, **app;
union node *cp, **cpp;
union node *redir, **rpp;
int t;
checkkwd();
switch (readtoken()) {
case TIF:
n1 = (union node *)stalloc(sizeof (struct nif));
n1->type = NIF;
n1->nif.test = list(0);
if (readtoken() != TTHEN)
synexpect(TTHEN);
n1->nif.ifpart = list(0);
n2 = n1;
while (readtoken() == TELIF) {
n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif));
n2 = n2->nif.elsepart;
n2->type = NIF;
n2->nif.test = list(0);
if (readtoken() != TTHEN)
synexpect(TTHEN);
n2->nif.ifpart = list(0);
}
if (lasttoken == TELSE)
n2->nif.elsepart = list(0);
else {
n2->nif.elsepart = NULL;
tokpushback++;
}
if (readtoken() != TFI)
synexpect(TFI);
break;
case TWHILE:
case TUNTIL:
n1 = (union node *)stalloc(sizeof (struct nbinary));
n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
n1->nbinary.ch1 = list(0);
if (readtoken() != TDO)
synexpect(TDO);
n1->nbinary.ch2 = list(0);
if (readtoken() != TDONE)
synexpect(TDONE);
break;
case TFOR:
if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
synerror("Bad for loop variable");
n1 = (union node *)stalloc(sizeof (struct nfor));
n1->type = NFOR;
n1->nfor.var = wordtext;
if (readtoken() == TWORD && ! quoteflag && equal(wordtext, "in")) {
app = ≈
while (readtoken() == TWORD) {
n2 = (union node *)stalloc(sizeof (struct narg));
n2->type = NARG;
n2->narg.text = wordtext;
n2->narg.backquote = backquotelist;
*app = n2;
app = &n2->narg.next;
}
*app = NULL;
n1->nfor.args = ap;
} else {
#ifndef GDB_HACK
static const char argvars[5] = {CTLVAR, VSNORMAL|VSQUOTE,
'@', '=', '\0'};
#endif
n2 = (union node *)stalloc(sizeof (struct narg));
n2->type = NARG;
n2->narg.text = (char *)argvars;
n2->narg.backquote = NULL;
n2->narg.next = NULL;
n1->nfor.args = n2;
}
if (lasttoken != TNL && lasttoken != TSEMI)
synexpect(-1);
checkkwd();
if ((t = readtoken()) == TDO)
t = TDONE;
else if (t == TBEGIN)
t = TEND;
else
synexpect(-1);
n1->nfor.body = list(0);
if (readtoken() != t)
synexpect(t);
break;
case TCASE:
n1 = (union node *)stalloc(sizeof (struct ncase));
n1->type = NCASE;
if (readtoken() != TWORD)
synexpect(TWORD);
n1->ncase.expr = n2 = (union node *)stalloc(sizeof (struct narg));
n2->type = NARG;
n2->narg.text = wordtext;
n2->narg.backquote = backquotelist;
n2->narg.next = NULL;
//.........这里部分代码省略.........
示例12: equal
template <typename P> bool operator==(const P& p) const { return equal(p, mpl::bool_<is_pixel<P>::value>()); }
示例13: startsWith
bool startsWith(const T &str, const T &prefix) {
return equal(begin(prefix), end(prefix), begin(str));
};
示例14: unequal
static bool unequal(value_type a, value_type b) { return !equal(a,b); }
示例15: while
void Automate::standardisation(){
/* Standardise l'automate en ajoutant l'etat 'i'
* */
list<list<string>*>::iterator iQ;
// Insere l'etat i dans la liste des etats
_Q.push_front(new list<string>);
iQ = _Q.begin();
(*iQ)->push_back("i");
_tab[*iQ] = new list<list<string>*>[_A.size()];
// Insere les transitions de l'etat 'i' (regroupant les transitions des etats initiaux)
for(iQ=++_Q.begin(); iQ!=_Q.end(); iQ++){
for(list<list<string>*>::iterator iI=_I.begin(); iI!=_I.end(); iI++){
if(((*iQ)->size() == (*iI)->size())&&(equal((*iQ)->begin(), ((*iQ)->end()), (*iI)->begin()))){
list<list<string>*>::iterator iiTab;
for(unsigned int cpt=0; cpt<_A.size(); cpt++){
for(list<list<string>*>::iterator iTab=_tab[*iQ][cpt].begin(); iTab!=_tab[*iQ][cpt].end(); iTab++){
_tab[*_Q.begin()][cpt].push_back(new list<string>);
iiTab =-- _tab[*_Q.begin()][cpt].end();
(*iiTab)->insert((*iiTab)->begin(),(*iTab)->begin(),(*iTab)->end());
}
}
}
}
}
// Tri les transitions de l'etat 'i'
iQ = _Q.begin();
for(unsigned int cpt=0; cpt<_A.size(); cpt++){
for(list<list<string>*>::iterator iTab=_tab[*iQ][cpt].begin(); iTab!=_tab[*iQ][cpt].end(); iTab++){
(*iTab)->sort();
(*iTab)->unique();
}
}
\
// Si un des etats initiaux est terminal
int temp = 0;
list<list<string>*>::iterator iI;
list<list<string>*>::iterator iT;
iI=_I.begin();
while ((iI != _I.end())&&(temp == 0)){
iT=_T.begin();
while ((iT != _T.end())&&(temp == 0)){
if (((*iI)->size() == (*iT)->size())&&(equal((*iI)->begin(),(*iI)->end(),(*iT)->begin())))
temp = 1;
iT++;
}
iI++;
}
// Insere 'i' dans les etats terminaux
if (temp == 1){
_T.push_front(new list<string>);
(*_T.begin())->push_back("i");
}
// Remplace les etats initiaux par 'i'
deleteI();
_I.push_front(new list<string>);
(*_I.begin())->push_back("i");
}