char * mDump(char *bp, int more) { int line; line = 0; while((bp < Mip->end) && (*bp)) { putchar(*bp); if (more && (*bp == '\n')) { if (++line == 24) { line = 0; if (!More()) return(0); } } bp++; } while(*bp) { putchar(*bp); if (more && (*bp == '\n')) { if (++line == 24) { line = 0; if (!More()) return(0); } } bp++; } return(bp); }
//-------------------------------------------------------------------------------- // CArrayIterator::NextIndex //-------------------------------------------------------------------------------- ArrayIndex CArrayIterator::NextIndex() { Advance(); return More() ? fCurrentIndex : kEmptyIndex; } // CArrayIterator::NextIndex
/*-------------------------------------------------------------------------- | macrodir macrosysdir | | This command lists the directory of macros in the userdir and | systemdir paths. | | VMS version uses the DIR command, along with Files-11 syntax. | /+--------------------------------------------------------------------------*/ int macroDir(int argc, char *argv[], int retc, char *retv[]) { char cmdstr[MAXSHSTRING]; #ifdef UNIX strcpy(cmdstr,"/bin/ls -C -F "); if ( ! strcmp("macrodir",argv[0])) /* userdir listing ?*/ strncat(cmdstr,userdir,MAXSHSTRING - strlen(cmdstr) -1); else strncat(cmdstr,systemdir,MAXSHSTRING - strlen(cmdstr) -1); strncat(cmdstr,"/maclib",MAXSHSTRING - strlen(cmdstr) -1); #else strcpy(cmdstr,"dir "); if (strcmp("macrodir",argv[0])==NULL) strcat(cmdstr,userdir); else strcat(cmdstr,systemdir); vms_fname_cat(cmdstr,"[.maclib]*."); #endif TPRINT1("macroDir: command string \"%s\"\n",cmdstr); Wsettextdisplay(argv[0]); Wshow_text(); /* Startup the shell command and pipe in the output */ if ((stream = popen_call(cmdstr,"r")) == NULL) { Werrprintf("Problem with creating macrols command with popen"); ABORT; } More(stream,WscreenSize()); /* more it out to screen */ RETURN; }
//-------------------------------------------------------------------------------- // CArrayIterator::FirstIndex //-------------------------------------------------------------------------------- ArrayIndex CArrayIterator::FirstIndex() { Reset(); return More() ? fCurrentIndex : kEmptyIndex; } // CArrayIterator::FirstIndex
void makeThread(nodeptr start, nodeptr stop) { int ndesc, i; nodeptr desc[NCHILD + 1]; /* Set link to the next node */ Next(start) = stop; /* If could descendent to thread */ if (Type(start) == CELL) { /* Start counting */ ndesc = 0; /* Loop over all child cells */ for (i = 0; i < NCHILD; i++) /* If this one is occupied */ if (Child(start)[i] != NULL) /* Store it in the table */ desc[ndesc++] = Child(start)[i]; /* Set link to the first one */ More(start) = desc[0]; /* Thread last one to next */ desc[ndesc] = stop; /* Loop over descendents */ for (i = 0; i < ndesc; i++) /* Thread them together */ makeThread(desc[i], desc[i + 1]); } }
TText CJsonTokener::Current() { if( More() ) { return iJsonString[ iPosition ]; } return 0; }
TText CJsonTokener::Next() { if( More() ) { return iJsonString[ iPosition++ ]; } return 0; }
/*-------------------------------------------------------------------------- | macrocat macrosyscat | | This command lists the contents of macros in the userdir and | systemdir paths. | | VMS version: Command is "type <file1>,<file2>..." , with a | comma between each file name. Better way needed to display | large macros or multiple macros | /+--------------------------------------------------------------------------*/ int macroCat(int argc, char *argv[], int retc, char *retv[]) { char cmdstr[MAXSHSTRING]; char dirname[MAXSHSTRING]; int i; int found = 0; if (argc == 1) { Werrprintf("Usage -- %s('macro_name'[,'macro_name'....])",argv[0]); ABORT; } #ifdef UNIX strcpy(cmdstr,"/bin/cat"); #else strcpy(cmdstr,"typ "); #endif if ( ! strcmp("macrocat",argv[0])) /* userdir directory ?*/ strcpy(dirname,userdir); else strcpy(dirname,systemdir); #ifdef UNIX strcat(dirname,"/maclib/"); #else vms_fname_cat(dirname,"[.maclib]"); #endif for (i=1; i<argc; i++) { char macroname[MAXSHSTRING]; strcpy(macroname,dirname); strcat(macroname,argv[i]); if (access(macroname,F_OK|R_OK) == -1) { Werrprintf("Macro %s is not accessible",macroname); } else { found = 1; strncat(cmdstr," ",MAXSHSTRING - strlen(cmdstr) -1); strncat(cmdstr,macroname,MAXSHSTRING - strlen(cmdstr) -1); #ifdef VMS if (i < argc-1) strcat(cmdstr,"., "); else strcat(cmdstr,"."); #endif } } TPRINT1("macroCat: command string \"%s\"\n",cmdstr); if (found) { Wsettextdisplay(argv[0]); Wshow_text(); /* Startup the shell command and pipe in the output */ if ((stream = popen_call(cmdstr,"r")) == NULL) { Werrprintf("Problem with creating macrocat command with popen"); ABORT; } More(stream,WscreenSize()); /* more it out to screen */ } RETURN; }
const T& PtrDynArrayIterator<T>::operator * () const { if (_ArrayObjPtr == NULL) Xnullp(); if (More()) return *((*_ArrayObjPtr)[_Index]); return *((*_ArrayObjPtr)[0]); }
T* PtrDynArrayIterator<T>::Pointee() { if (_ArrayVarPtr == NULL) Xnullp(); if (More()) return ((*_ArrayVarPtr)[_Index]); return ((*_ArrayVarPtr)[0]); }
const T* PtrDynArrayIterator<T>::ConstPointee() const { if (_ArrayObjPtr == NULL) Xnullp(); if (More()) return ((*_ArrayObjPtr)[_Index]); return ((*_ArrayObjPtr)[0]); }
SimpleNode<T>* SimpleListIterator<T>::Next() { if (!More()) return NULL; _Here = _Here->_Next; _Index++; return _Here; }
char* showCell(const NBodyCell* c) { char* buf; char* posBuf; if (!c) return NULL; posBuf = showVector(Pos(c)); if (0 > asprintf(&buf, "NBodyCell = {\n" " cellnode = {\n" " pos = %s\n" " next = %p\n" " mass = %f\n" " type = %d\n" " }\n" " rcrit2 = %f\n" " more = %p\n" " stuff = {\n" " .quad = {\n" " .xx = %f, .xy = %f, .xz = %f,\n" " .yy = %f, .yz = %f,\n" " .zz = %f\n" " },\n" "\n" " .subp = {\n" " %p, %p, %p, %p,\n" " %p, %p, %p, %p\n" " }\n" " }\n" "}\n", posBuf, (void*) Next(c), Mass(c), Type(c), Rcrit2(c), (void*) More(c), Quad(c).xx, Quad(c).xy, Quad(c).xz, Quad(c).yy, Quad(c).yz, Quad(c).zz, (void*) Subp(c)[0], (void*) Subp(c)[1], (void*) Subp(c)[2], (void*) Subp(c)[3], (void*) Subp(c)[5], (void*) Subp(c)[5], (void*) Subp(c)[6], (void*) Subp(c)[7] )) { mw_fail("asprintf() failed\n"); } free(posBuf); return buf; }
const SimpleNode<T>* ConstListIterator<T>::Next() { if (!More()) return NULL; _ConstHere = _ConstHere->_Next; _Index++; return _ConstHere; }
Boolean PtrDynArrayIterator<T>::IsValid() const { if (_ArrayVarPtr == NULL) Xnullp(); if (More()) return TRUE; return FALSE; }
local void walktree(nodeptr *aptr, nodeptr *nptr, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr *np, *ap, q; int actsafe; matrix trQM; if (Update(p)) { // new forces needed in node? np = nptr; // start new active list actsafe = actmax - NSUB; // leave room for NSUB more for (ap = aptr; ap < nptr; ap++) { // loop over active nodes if (Type(*ap) == CELL) { // is this node a cell? if (accept(*ap, psize, pmid)) { // does it pass the test? if (Mass(*ap) > 0.0) { // and contribute to field? Mass(cptr) = Mass(*ap); // copy to interaction list SETV(Pos(cptr), Pos(*ap)); #if defined(SOFTCORR) TRACEM(Trace(cptr), Quad(*ap)); // save trace in copy SETMI(trQM); MULMS(trQM, trQM, Trace(cptr)/3); SUBM(Quad(cptr), Quad(*ap), trQM); // store traceless moment #else SETM(Quad(cptr), Quad(*ap)); // copy traceless moment #endif cptr++; // and bump cell array ptr } } else { // this cell fails the test if (np - active >= actsafe) // make sure list has room fatal("%s.walktree: active list overflow\n", getprog()); for (q = More(*ap); q != Next(*ap); q = Next(q)) // loop over all subcells *np++= q; // put them on active list } } else // else this node is a body if (*ap != p && Mass(*ap) > 0.0) { // not self-interaction? --bptr; // bump body array ptr Mass(bptr) = Mass(*ap); // and copy data to array SETV(Pos(bptr), Pos(*ap)); } } acttot = MAX(acttot, np - active); // keep track of max active if (np != nptr) { // if new actives were added walksub(nptr, np, cptr, bptr, p, psize, pmid); // then visit next level } else { // else no actives left if (Type(p) != BODY) // make sure we got a body fatal("%s.walktree: recursion terminated with cell\n" " p = 0x%x psize = %.8f Mass(p) = %g\n" " pmid = (%.8f,%.8f,%.8f)\n Pos(p) = (%.8f,%.8f,%.8f)\n", getprog(), (int) p, psize, Mass(p), pmid[0], pmid[1], pmid[2], Pos(p)[0], Pos(p)[1], Pos(p)[2]); gravsum((bodyptr) p, cptr, bptr); // sum force on this body } } }
tlib::bson::object Collection::Cursor::CursorImpl::Current() const { assert( More() && "There are no data in cursor" ); const bson_t* record = mongoc_cursor_current( m_cursor.get() ); if( !record ) throw MongoError("Invoke Cursor::Current with bad cursor"); return tlib::bson::object( record ); }
int help(int argc, char *argv[], int retc, char *retv[]) { char fileName[MAXPATHL]; char filePath[MAXPATHL]; char cmdstr[MAXSHSTRING]; extern char help_name[]; FILE *stream, *popen_call(); (void) argc; (void) argv; (void) retc; (void) retv; if (help_name[0] == '\0') /* use a default name */ strcpy(fileName, "default" ); else /* use help_name name */ strcpy(fileName,help_name); filePath[ 0 ] = '\0'; appdirFind(fileName,"help",filePath,NULL,R_OK); if (strlen(filePath) < 1 || access(filePath,R_OK) < 0) { Werrprintf("help file %s does not exist",fileName); ABORT; } else { /* VMS requires an extension to the file name, even if it is null; otherwise, the TYPE command assumes .LIS, which causes problems. */ #ifdef VMS strcat(filePath,"."); #endif if ( !Wissun() ) /* If using a terminal, stop */ Wturnoff_buttons(); /* interactive display. */ Wsettextdisplay("Help"); Wshow_text(); Wclear_text(); #ifdef UNIX strcpy(cmdstr,"/bin/cat "); #else strcpy(cmdstr,"type "); #endif strcat(cmdstr,filePath); /* Start shell cmd */ if ((stream = popen_call(cmdstr,"r")) == NULL) /* & pipe output */ { Werrprintf("Problem with creating shell command with popen"); ABORT; } else { More(stream,WscreenSize()); /* more it out to screen */ RETURN; } } /* found a help file */ }
RandomAccessIterator<T>& PtrDynArrayIterator<T>::operator -- () { if (_ArrayVarPtr == NULL) Xnullp(); if (More()) --_Index; else SetToLast(); return *this; }
RandomAccessIterator<T>& PtrDynArrayIterator<T>::operator -= (SizeType Diff_) { if (_ArrayVarPtr == NULL) Xnullp(); if (_Index >= Diff_) _Index -= Diff_; else if (!More() && Diff_ <= _ArrayObjPtr->RunLength()) _Index = _ArrayObjPtr->RunLength() - Diff_; else _Index = SizeType(-1); return *this; }
RandomAccessIterator<T> PtrDynArrayIterator<T>::operator -- (int) { RandomAccessIterator<T> Ref_(*this); if (_ArrayVarPtr == NULL) Xnullp(); if (More()) --_Index; else SetToLast(); return Ref_; }
const RandomAccessIterator<T>& PtrDynArrayIterator<T>::operator -- () const { if (_ArrayObjPtr == NULL) Xnullp(); PtrDynArrayIterator<T>* const LocalThis_ = (PtrDynArrayIterator<T>* const)this; if (More()) --LocalThis_->_Index; else LocalThis_->SetToLast(); return *this; }
const RandomAccessIterator<T>& PtrDynArrayIterator<T>::operator -= (SizeType Diff_) const { if (_ArrayObjPtr == NULL) Xnullp(); PtrDynArrayIterator<T>* const LocalThis_ = (PtrDynArrayIterator<T>* const)this; if (_Index >= Diff_) LocalThis_->_Index -= Diff_; else if (!More() && Diff_ <= _ArrayObjPtr->RunLength()) LocalThis_->_Index = _ArrayObjPtr->RunLength() - Diff_; else LocalThis_->_Index = SizeType(-1); return *this; }
/* the main program: set up the population and loop through evolutionary cycles (generations) as controlled by the user */ main() { InitPop(); /* initialize the population */ do /* for each evolutionary cycle */ { /* reproduce, cross-over, and mutate each cycle */ Repro(); Cross(); Mutate(); /* test each individual for survivability, update goodness variables, and print statistics for the top genotypes */ Test(); Top(NTop); } while (More()); return 0; }
void walkTree(nodeptr * aPtr, nodeptr *nPtr, cellptr cPtr, cellptr bPtr, nodeptr p, real pSize, vector pMid, double eps) { nodeptr *np, *ap, q; int activeSafe; /* Are new forces needed? */ if (Update(p)) { /* Start new active list */ np = nPtr; /* Loop over active nodes */ for (ap = aPtr; ap < nPtr; ap++) { /* Is this node a cell? */ if (Type(*ap) == CELL) { /* If the node pass the test */ if (acceptNode(*ap, pSize, pMid)) { /* If the node contribute to the field */ if (Mass(*ap) > 0.0) { /* Copy to interaction list */ Mass(cPtr) = Mass(*ap); SETV(Pos(cPtr), Pos(*ap)); /* Next interaction element */ cPtr++; } } else { /* If not accepted */ for (q = More(*ap); q != Next(*ap); q = Next(q)) *np++ = q; } } else {/* If this node is a body */ /* If it's not self-interaction */ if (*ap != p && Mass(*ap) > 0.0) { /* Build interaction element */ --bPtr; /* Copy data to array */ Mass(bptr) = Mass(*ap); SETV(Pos(bPtr), Pos(*ap)); } } } } }
static void Add_Layer_To_Dialogs(int num, char *name, Boolean state) { Arg args[5]; int n; char widg_name[12]; int i; if ( ! layer_list_shell ) Create_Layer_List(); if ( ! layer_toggle_shell ) Create_Layer_Toggle_Shell(); if ( num_layers >= max_list_length ) { if ( max_list_length ) { max_list_length += 5; layer_name_list = More(layer_name_list, char*, max_list_length); layer_list_map = More(layer_list_map, int, max_list_length); layer_toggles = More(layer_toggles, Widget, max_list_length); } else { max_list_length += 5; layer_name_list = New(char*, max_list_length); layer_list_map = New(int, max_list_length); layer_toggles = New(Widget, max_list_length); } n = 0; XtSetArg(args[n], XtNborderWidth, 0); n++; for ( i = max_list_length - 5 ; i < max_list_length ; i++ ) { sprintf(widg_name, "toggle%d", i); layer_toggles[i] = XtCreateWidget(widg_name, toggleWidgetClass, layer_toggle_box, args, n); XtAddCallback(layer_toggles[i], XtNcallback, Layer_Toggle_Callback, NULL); } }
local void walkgrav(nodeptr *aptr, nodeptr *nptr, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr *np, *ap, q; int actsafe; if (Update(p)) { /* are new forces needed? */ np = nptr; /* start new active list */ actsafe = actlen - NSUB; /* leave room for NSUB more */ for (ap = aptr; ap < nptr; ap++) /* loop over active nodes */ if (Cell(*ap)) { /* is this node a cell? */ if (accept(*ap, psize, pmid)) { /* does it pass the test? */ Mass(cptr) = Mass(*ap); /* copy to interaction list */ SETV(Pos(cptr), Pos(*ap)); SETM(Quad(cptr), Quad(*ap)); cptr++; /* and bump cell array ptr */ } else { /* else it fails the test */ if (np - active >= actsafe) /* check list has room */ error("walkgrav: active list overflow\n"); for (q = More(*ap); q != Next(*ap); q = Next(q)) /* loop over all subcells */ *np++= q; /* put on new active list */ } } else /* else this node is a body */ if (*ap != p) { /* if not self-interaction */ --bptr; /* bump body array ptr */ Mass(bptr) = Mass(*ap); /* and copy data to array */ SETV(Pos(bptr), Pos(*ap)); } actmax = MAX(actmax, np - active); /* keep track of max active */ if (np != nptr) /* if new actives listed */ walksub(nptr, np, cptr, bptr, p, psize, pmid); /* then visit next level */ else { /* else no actives left, so */ if (! Body(p)) /* must have found a body */ error("walkgrav: recursion terminated with cell\n"); gravsum((bodyptr) p, cptr, bptr); /* sum force on the body */ } } }
local void walksub(nodeptr *nptr, nodeptr *np, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr q; int k; vector qmid; if (Type(p) == CELL) { // fanout over descendents for (q = More(p); q != Next(p); q = Next(q)) { // loop over all subcells for (k = 0; k < NDIM; k++) // set subcell's midpoint qmid[k] = pmid[k] + (Pos(q)[k] < pmid[k] ? - psize : psize) / 4; walktree(nptr, np, cptr, bptr, q, psize / 2, qmid); // recurse on subcell } } else { // extend "virtual" tree for (k = 0; k < NDIM; k++) // set virtual midpoint qmid[k] = pmid[k] + (Pos(p)[k] < pmid[k] ? - psize : psize) / 4; walktree(nptr, np, cptr, bptr, p, psize / 2, qmid); // and search next level } }
local void treescan(nodeptr q) { while (q != NULL) { /* while not at end of scan */ if (Type(q) == CELL && /* is node a cell and... */ subdivp(q)) /* too close to accept? */ { cellptr SAFE c = TC(q); q = More(c); /* follow to next level */ } else { /* else accept this term */ if (q == (nodeptr) &pskip->bodynode) /* self-interaction? */ skipself = TRUE; /* then just skip it */ else { /* not self-interaction */ gravsub(q); /* so compute gravity */ if (Type(q) == BODY) n2bterm++; /* count body-body */ else nbcterm++; /* count body-cell */ } q = Next(q); /* follow next link */ } } }
int _tmain(int argc, _TCHAR* argv[]) { MyString<int> str("Hello"); //str.Print(); A* p_a; B b; p_a = &b; std::cout << typeid(b).name() << std::endl; std::cout << typeid(*p_a).name() << std::endl; std::vector<int> a {3, 1, 2, 11, 5, -2, 23, 21, 32}; typedef std::vector<int>::iterator int_iter; for_each (a.begin(), a.end(), [](int& n) { std::cout << n << std::endl; }); sort(a.begin(), a.end()); for_each(a.begin(), a.end(), [](int& n) { std::cout << n << std::endl; }); std::cout << std::count_if(a.begin(), a.end(), More(1)); //B b; //system("Pause"); return 0; }