void StreamTokenizer::nextChunk(SeekableReadStream &stream) { skipChunk(stream); uint32 c = stream.readChar(); if (c == ReadStream::kEOF) return; if (!isIn(c, _chunkEnds)) stream.seek(-1, SeekableReadStream::kOriginCurrent); }
void isIn(Eigen::Matrix<T, -1, -1> &V, vector<int> &in_vids, const std::vector<T> xs, const std::vector<T> &ys) { T p[2]; for (int i = 0; i < V.rows(); i++) { p[0] = V(i, 0); p[1] = V(i, 1); if (isIn(p, xs, ys)) in_vids.push_back(i); } }
const char_t* Twindow::_(int id,const char_t *s,bool addcbx) { if (addcbx && tr->translateMode && s[0]) { strings &list=translateCbxs[id]; if (!isIn(list,ffstring(s))) { list.push_back(s); } } return tr->translate(s); }
bool StreamTokenizer::isChunkEnd(SeekableReadStream &stream) { if (stream.eos()) return true; bool chunkEnd = isIn(stream.readByte(), _chunkEnds); stream.seek(-1, SEEK_CUR); return chunkEnd; }
void isIn(Eigen::Matrix<T, -1, -1> &V, vector<int> &in_vids, const std::vector<T> xs, const std::vector<T> &ys, const int width , const int height ) { int n = xs.size(); std::vector<T> x(n), y(n); for (int i = 0; i < n; i++) { x[i] = xs[i] * width; y[i] = ys[i] * height; } isIn(V, in_vids, x, y); }
bool StreamTokenizer::isChunkEnd(SeekableReadStream &stream) { uint32 c = stream.readChar(); if (c == ReadStream::kEOF) return true; bool chunkEnd = isIn(c, _chunkEnds); stream.seek(-1, SeekableReadStream::kOriginCurrent); return chunkEnd; }
void StreamTokenizer::skipChunk(SeekableReadStream &stream) { assert(!_chunkEnds.empty()); uint32 c; while ((c = stream.readChar()) != ReadStream::kEOF) { if (isIn(c, _chunkEnds)) { stream.seek(-1, SeekableReadStream::kOriginCurrent); break; } } }
LRESULT TlevelsPage::TwidgetCurves::onMouseMove(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { if (dragpoint!=-1) { int x=256*GET_X_LPARAM(lParam)/dxy; int y=255-256*GET_Y_LPARAM(lParam)/dxy; static const int border=40; if (pt.size()>2 && (!isIn(x,0-border,255+border) || !isIn(y,0-border,255+border))) { pt.erase(pt.begin()+curpoint); curpoint=-1; onLbuttonUp(hwnd,uMsg,wParam,lParam); } else { pt[dragpoint].x=limit(x,int(dragpoint==0?0:pt[dragpoint-1].x),int(dragpoint==(int)pt.size()-1?255:pt[dragpoint+1].x)); pt[dragpoint].y=limit_uint8(y); } save(); levelsPage->map2dlg(); return 0; } return TwindowWidget::onMouseMove(hwnd,uMsg,wParam,lParam); }
boolean Circadian::doTriggers() { long t = time(); if(isIn(t, triggerNow - CCTPD / 2 + 1, triggerNow + 1)) { // time hasn't moved forward yet return false; } triggerLast = triggerNow; triggerNow = t; return true; }
void drawGrid(int coordinates1[], int coordinates2[]) { int grid[HEIGHT][WIDTH]; int i; for (i = 0; i < HEIGHT; ++i) { for (int j = 0; j < WIDTH; ++j) { if ( isIn(j, i, coordinates1) ) { printf("*"); } else if ( isIn(j, i, coordinates2) ) { printf("@"); } else { printf("."); } } printf("\n"); } printf("\n\n"); }
STDMETHODIMP ThwOverlayControlVMR9::set(int cap, int val) { if (!vmr9) { return E_UNEXPECTED; } if (!isIn(cap, 1, 6) || !caps[cap]) { return E_INVALIDARG; } ctrl.*(caps[cap]) = mapRange(val, std::make_pair(hwocMinMax[cap][0], hwocMinMax[cap][1]), std::make_pair(ranges[cap].MinValue, ranges[cap].MaxValue)); vmr9->SetProcAmpControl(id, &ctrl); return S_OK; }
void StreamTokenizer::skipChunk(SeekableReadStream &stream) { assert(!_chunkEnds.empty()); while (!stream.eos() && !stream.err()) { if (isIn(stream.readByte(), _chunkEnds)) { stream.seek(-1, SEEK_CUR); break; } } if (stream.err()) throw Exception(kReadError); }
void TcodecsPage::options2dlg(int i) { static const int idOptions[]= {IDC_CHB_CODEC_OPT1,IDC_CHB_CODEC_OPT2, IDC_CHB_CODEC_OPT3, IDC_CHB_CODEC_OPT4,0}; show(0,idOptions); const Tformat *f=isIn(i,0,(int)formats.size()-1)?&formats[i]:NULL; for (size_t ii=0; f && ii<f->options.size(); ii++) { show(1,idOptions[ii]); const Tformat::Toption &o=f->options[ii]; setText(idOptions[ii],_(idOptions[ii],o.name)); setCheck(idOptions[ii],cfgGet(o.id)&o.val); enable(o.forCodec==0 || cfgGet(f->idff)==o.forCodec,idOptions[ii]); } }
int main() { int K; Node a[100]; int result[100]; scanf("%d", &K); for (int i = 0; i < K; i++){ scanf("%d", &a[i].num); a[i].flag = false; //初始化时没有被覆盖 } for (int i = 0; i < K; i++) { int temp; if (a[i].num % 2 == 0) temp = a[i].num / 2; else temp = (3 * a[i].num + 1) / 2; while (temp != 1) { isIn(temp, a, K); if (temp % 2 == 0) temp /= 2; else temp = (3 * temp + 1) / 2; } } int count = 0; for (int i = 0; i < K; i++) { if (a[i].flag == false) //如果未被覆盖 { result[count] = a[i].num; count++; } } //排序 qsort(result, count, sizeof(result[0]), cmp); //print for (int i = 0; i < count; i++) { if (i != count - 1) printf("%d ", result[i]); else printf("%d", result[i]); } }
int MainWindowClass::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: on_actionOpenFile_triggered(); break; case 1: on_actionLicenceAuthor_triggered(); break; case 2: on_listWidget_itemClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 3: on_PIXELlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 4: on_XPIXFAlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 5: on_YPIXFAlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 6: on_XSCATlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 7: on_YSCATlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 8: on_ANGLElineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 9: on_XNULLlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 10: on_YNULLlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 11: on_RMINlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 12: on_RMAXlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 13: on_DRlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 14: on_RMINTlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 15: on_RMAXTlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 16: on_DRTlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 17: on_TUNEXPlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 18: on_RADIlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 19: on_CADISTlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 20: on_WAVElineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 21: on_DELTASlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 22: on_IRECOAlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 23: on_IRECOA2lineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 24: on_SEPLAlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 25: on_ISECTlineEdit_textEdited((*reinterpret_cast< QString(*)>(_a[1]))); break; case 26: on_UseCheckBox_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break; case 27: on_StartRadioButton_clicked(); break; case 28: on_EndRadioButton_clicked(); break; case 29: on_comboBox_currentIndexChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 30: on_BeamPushButton_pressed(); break; case 31: on_AdvPushButton_pressed(); break; case 32: on_IntegratePushButton_pressed(); break; case 33: { bool _r = isIn((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 34: on_SECFIlineEdit_textChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 35: on_SECFIpushButton_pressed(); break; default: ; } _id -= 36; } return _id; }
int main() { Point a, b, c, d; // b a c要顺时针 a.x = 1; a.y = 1; b.x = 0; b.y = 0; c.x = 1; c.y = 0; d.x = 0.5; d.y = 0; printf("<%lf, %lf> : %d\n", d.x, d.y, isIn(a,b,c,d)); return 0; }
bool Sequence::initFromDetection( const std::string& pattern, const EPattern accept ) { clear(); setDirectoryFromPath( pattern ); if( !retrieveInfosFromPattern( boost::filesystem::path( pattern ).filename().string(), accept, _prefix, _suffix, _padding, _strictPadding ) ) return false; // not recognized as a pattern, maybe a still file if( !boost::filesystem::exists( _directory ) ) return true; // an empty sequence std::vector<std::string> allTimesStr; std::vector<Time> allTimes; bfs::directory_iterator itEnd; for( bfs::directory_iterator iter( _directory ); iter != itEnd; ++iter ) { // we don't make this check, which can take long time on big sequences (>1000 files) // depending on your filesystem, we may need to do a stat() for each file // if( bfs::is_directory( iter->status() ) ) // continue; // skip directories Time time; std::string timeStr; // if the file is inside the sequence if( isIn( iter->path().filename().string(), time, timeStr ) ) { // create a big vector of all times in our sequence allTimesStr.push_back( timeStr ); allTimes.push_back( time ); } } if( allTimes.size() < 2 ) { if( allTimes.size() == 1 ) { _firstTime = _lastTime = allTimes.front(); } //std::cout << "empty => " << _firstTime << " > " << _lastTime << " : " << _nbFiles << std::endl; return true; // an empty sequence } std::sort( allTimes.begin(), allTimes.end() ); extractStep( allTimes ); extractPadding( allTimesStr ); extractIsStrictPadding( allTimesStr, _padding ); _firstTime = allTimes.front(); _lastTime = allTimes.back(); _nbFiles = allTimes.size(); //std::cout << _firstTime << " > " << _lastTime << " : " << _nbFiles << std::endl; return true; // a real file sequence }
/** * Constructs a neighborhood * Parameter: _som The som * Parameter: _center Reference to the center of neighborhood * Parameter: _radius Radius of neighbohood */ std::vector<unsigned> Layout::neighborhood(const ClassificationMap* _som, const SomPos& _center, double _radius) const { std::vector<unsigned> neig; // try to find the neighbors for (unsigned i = 0 ; i < _som->size() ; i++) { if (isIn(_center, _som->indexToPos(i), _radius)) neig.push_back(i); } return neig; }
void TencStats::add(const TencFrameParams &frame) { count++; sumFramesize+=frame.length; sumPsnrY+=frame.psnrY; sumPsnrU+=frame.psnrU; sumPsnrV+=frame.psnrV; if (frame.quant<=0) { return; } sumQuants+=frame.quant; if (isIn(frame.quant,1,51)) { quantCount[frame.quant]++; } }
bool Entry::addProperty(PropertyStruct *es) { if (!isIn(es)) { #ifdef DEBUG qDebug("Entry::addProperty -- Property Name: %s Property ID: %d", es->getName().latin1(), es->getID()); #endif propList->append(es); return true; } return false; }
void StreamTokenizer::nextChunk(SeekableReadStream &stream) { skipChunk(stream); byte c = stream.readByte(); if (stream.eos() || stream.err()) return; if (!isIn(c, _chunkEnds)) stream.seek(-1, SEEK_CUR); else if (stream.pos() == stream.size()) // This actually the last character, read one more byte to properly set the EOS state stream.readByte(); }
/*----------------------------------------------------------------------*/ static int sumAttributeInContainer( Aint containerIndex, /* IN - the container to sum */ Aint attributeIndex /* IN - the attribute to sum over */ ) { int instanceIndex; int sum = 0; for (instanceIndex = 1; instanceIndex <= header->instanceMax; instanceIndex++) if (isIn(instanceIndex, containerIndex, DIRECT)) { /* Then it's directly in this cont */ if (instances[instanceIndex].container != 0) /* This is also a container! */ sum = sum + sumAttributeInContainer(instanceIndex, attributeIndex); sum = sum + getInstanceAttribute(instanceIndex, attributeIndex); } return(sum); }
// Returns if the word is in the data structure. A word could // contain the dot character '.' to represent any one letter. bool search(string pattern) { int t = isIn(pattern); if (t==-1){ return false; } else{ for(int i=0; i<s_v[t].size(); i++){ if (comp(s_v[t][i], pattern)){ return true; } } } return false; }
//功能:检测一个函数中的内存泄漏问题 1.1、malloc开了内存,没有free这块内存。 int memoryLeakFunc1(int begin) { string func[255] = {""}; int flen = 0; int rowNum = -1; rowNum = getFunc(func, begin, flen); if(-1 != rowNum) // 如果读取到了函数 { int i, j; string temp = ""; string single[255] = {""}; int slen = 0; for(i=0; i<flen; i++) { temp = func[i]; slen = covertCmd(temp, single); // 有"malloc"没有"="的情况 if(isIn("malloc", single, slen) && !isIn("=", single, slen)) { errNum[errLen] = (rowNum-flen+i+1); errType[errLen] = 7; errLen++; } //有"malloc", 有"="的情况 if(isIn("malloc", single, slen) && isIn("=", single, slen)) { int freeFlag = -1; int pos[10] = {-1}; int posCount = -1; posCount = isContain("=", single, slen, pos); string pFree = single[pos[0]-1]; for(j=i+1; j<flen; j++) { temp = func[j]; slen = covertCmd(temp, single); if(isIn("free", single, slen) && isIn(pFree, single, slen)) // free了pFree指向的指针 { freeFlag = 1; break; } } if(-1 == freeFlag) // 如果没有free { errNum[errLen] = (rowNum-flen+i+1); errType[errLen] = 7; errLen++; } } } return rowNum; } return -1; }
Range Next() { Range range; range.begin = cursor_; while (cursor_ != sentence_.end()) { if (isIn(symbols_, *cursor_)) { if (range.begin == cursor_) { cursor_ ++; } range.end = cursor_; return range; } cursor_ ++; } range.end = sentence_.end(); return range; }
MStatus ReferenceManager::getTopLevelReferenceNode(const MDagPath & dagPath, MObject & outReferenceNode) { MStringArray references; MStatus status = MFileIO::getReferences(references); unsigned int referenceCount = references.length(); for (unsigned int referenceIndex = 0; referenceIndex < referenceCount; ++referenceIndex) { MString referenceFilename = references[referenceIndex]; MObject referenceNode = ReferenceManager::getReferenceNode(referenceFilename); if (isIn(dagPath, referenceNode)) { outReferenceNode = referenceNode; return MS::kSuccess; } } return MS::kFailure; }
bool isIn(const MDagPath & dagPath, const MObject & referenceNode) { MDagPathArray rootDagPaths; MObjectArray subReferences; ReferenceManager::getRootObjects(referenceNode, rootDagPaths, subReferences); for (unsigned int i = 0; i < rootDagPaths.length(); ++i) { if (rootDagPaths[i] == dagPath) { return true; } } for (unsigned int i = 0; i < subReferences.length(); ++i) { if (isIn(dagPath, subReferences[i])) { return true; } } return false; }
void DialogBox::mouseMove(int x, int y) { float screenX, screenY; CursorMan.toScreenCoordinates(x, y, screenX, screenY); if (!isIn(screenX, screenY)) { setHighlight(_replyLines.end()); return; } std::list<ReplyLine>::iterator highlight; for (highlight = _replyLines.begin(); highlight != _replyLines.end(); ++highlight) if ((highlight->count && highlight->count->isIn(screenX, screenY)) || (highlight->line && highlight->line->isIn (screenX, screenY))) break; setHighlight(highlight); }
int Lattice::CheckNeighbor(int myrank, float x, float y, float z) { int i,j,k; GetIndices(myrank, i, j, k); if (isIn(x,y,z,i-1,j,k)==true) return(0); //-X if (isIn(x,y,z,i+1,j,k)==true) return(1); //+X if (isIn(x,y,z,i,j-1,k)==true) return(2); //-Y if (isIn(x,y,z,i,j+1,k)==true) return(3); //+Y if (isIn(x,y,z,i,j,k-1)==true) return(4); //-Z if (isIn(x,y,z,i,j,k+1)==true) return(5); //+Z return(-1); }
int countSurroundings(int Xcoord, int Ycoord, int coords[]) { int i, j, counter = 0; for (i = 0; i < VISIBILITY; ++i) { for (j = 0; j < VISIBILITY; ++j) { int surroundingX = cellBehind(Xcoord+i, WIDTH); int surroundingY = cellBehind(Ycoord+j, HEIGHT); if ( (isIn(surroundingX, surroundingY, coords)) && (Xcoord != surroundingX || Ycoord != surroundingY) ) { counter++; } } } return counter; }