// ----------------------------------------------------------------------------- // CNATTraversalNotIntegrated::Cancel // ----------------------------------------------------------------------------- // void CNATTraversalNotIntegrated::Cancel( TUint32 aRequestId ) { TBool found( EFalse ); for ( TInt i = 0; i < iAsyncRequests.Count() && !found; i++ ) { TPendingAsyncRequest& request = iAsyncRequests[ i ]; if ( request.MatchRequestId( aRequestId ) ) { found = ETrue; iAsyncCompletionTimer->Remove( request.iTimerEntry ); iAsyncRequests.Remove( i ); iAsyncRequests.Compress(); } } }
bool MessageButtonPane::GetPaneHilite(ZSubPane* inPane, EZTriState& outHilite) { ButtonList::iterator found( find( mButtons.begin(), mButtons.end(), inPane ) ); if ( found != mButtons.end() ) { if ( (found - mButtons.begin()) == mSelectedButton ) outHilite = eZTriState_On; else outHilite = eZTriState_Off; return true; } return ZPaneLocator::GetPaneHilite( inPane, outHilite ); }
bool MessageButtonPane::GetPaneLocation(ZSubPane* inPane, ZPoint& outLocation) { ButtonList::iterator found( find( mButtons.begin(), mButtons.end(), inPane ) ); if ( found != mButtons.end() ) { ZPoint firstSize = mButtons.front()->GetSize(); outLocation.h = 0; outLocation.v = (found - mButtons.begin()) * firstSize.v; return true; } return ZPaneLocator::GetPaneLocation( inPane, outLocation ); }
void data(int *a,int *b,char *p) { int i,m,n,x=0,c=0,sign=0,coeff=1; for(i=0;p[i];) { if(p[i]!='+' && p[i]!='-') { if(p[i]=='x') x += sign ? -1 : 1; else found(p,i,&coeff) ? (x += sign ? -coeff : coeff) : (c += sign ? -coeff : coeff); while(p[i]!='+' && p[i]!='-' && p[i]) i++; } else { sign = p[i]=='+' ? 0 : 1; i++; } } *a=x; *b=c; return; }
void csPdfSearch::processSearch() { if( !_running ) { return; } if( _cancel ) { _running = false; emit canceled(); return; } int blockSize = 0; if( !isBlocksFinished() ) { // Do CSPDF_SEARCH_BLOCKSIZE's Work... blockSize = CSPDF_SEARCH_BLOCKSIZE; _cntBlocks++; } else if( isBlocksFinished() && !isRemainFinished() ) { // Do _numRemain's Work... blockSize = _numRemain; _cntRemain += _numRemain; } if( blockSize != 0 ) { const csPdfSearchResults results = searchPages(_doc.textPages(_cntIndex, blockSize), _needles, _cs, _context); if( !results.isEmpty() ) { emit found(results); } _cntIndex += blockSize; _cntDone += blockSize; progressUpdate(); } if( isFinished() && _startIndex != 0 && _wrap ) { initialize(0, _startIndex); _startIndex = 0; } if( !isFinished() ) { QMetaObject::invokeMethod(this, "processSearch", Qt::QueuedConnection); } else { _running = false; emit finished(); } }
//Perform a simple binary search for the value. unsigned int binary_search(T value, Search type, unsigned int first, unsigned int last) { if (first+1 == last) { //Base case return found(value, type, first, last); } else { //Recursive case unsigned int candidate = (last-first)/2 + first; if (value < lookup[candidate]) { return binary_search(value, type, first, candidate); } else if (value > lookup[candidate]) { return binary_search(value, type, candidate, last); } else { //Needed if the lookup array's size is 1, or to speed up searches in general return candidate; } } }
int main() { mpz_class maxcount(45); mpz_class found(0); mpz_class check(0); for( mpz_nextprime(check.get_mpz_t(), check.get_mpz_t()); found < maxcount; mpz_nextprime(check.get_mpz_t(), check.get_mpz_t())) { //std::cout << "P" << check << " " << std::flush; if( is_mersenne_prime(check) ) { ++found; std::cout << "M" << check << " " << std::flush; } } }
void refresh() { qDeleteAll(entries); entries.clear(); KoTemplateTree* tree(0); if(templateType == WORDS_MIME_TYPE) tree = new KoTemplateTree("words/templates/", true); else if(templateType == STAGE_MIME_TYPE) tree = new KoTemplateTree("stage/templates/", true); if(!tree) return; Q_FOREACH(const KoTemplateGroup* group , tree->groups()) { Q_FOREACH(const KoTemplate* tmplate, group->templates()) { if(tmplate->wide() != showWide) continue; QString title = tmplate->name(); TemplateEntry* found(0); Q_FOREACH(TemplateEntry* otherEntry, entries) { if(otherEntry->title == title) { found = otherEntry; break; } } TemplateEntry* entry(0); if(found) { entry = found; } else { entry = new TemplateEntry(); entry->title = title; entry->description = tmplate->description(); entries.append(entry); } entry->variants->addVariant(tmplate->variantName(), tmplate->color(), tmplate->swatch(), tmplate->thumbnail().isEmpty() ? tmplate->picture() : tmplate->thumbnail(), tmplate->file()); } } }
void BlockManager::RecycleBlock( offset_type blockid ) { FileAutoLock lock(m_pLock); assert(blockid.offset >=0 && blockid < m_Header.Blocks && "Recycle out of range"); assert(blockid != m_Header.Unused && "Recycle again?"); if(blockid.offset == m_Header.Blocks.offset -1)//shrink file size { --m_Header.Blocks.offset; while (m_Header.Unused.offset == m_Header.Blocks.offset -1 && m_Header.Unused.offset >= 0) { offset_type header(-1); ReadEmptyBlockHeader(m_Header.Unused, header); m_Header.Unused = header; --m_Header.Blocks.offset; assert(m_Header.Blocks.offset >=0); assert(m_Header.Unused < m_Header.Blocks); } m_pFile->ReserveSpace(CalcOffset(m_Header.Blocks)); FlushHeader(); } else { if(blockid > m_Header.Unused) { offset_type header = m_Header.Unused; WriteEmptyBlockHeader(blockid, header); m_Header.Unused = blockid; FlushHeader(); } else { offset_type unused = m_Header.Unused; offset_type found(0); offset_type header(-1); while (blockid < unused) { ReadEmptyBlockHeader(unused, header); found = unused; unused = header; } WriteEmptyBlockHeader(found, blockid); WriteEmptyBlockHeader(blockid, unused); } } }
int lengthOfLongestSubstring(string s) { int res = 0; int start = 0, end = 0; int N = s.size(); vector<bool> found(256, false); while (end < N) { // slinding window (2 pointers) if (!found[s[end]]) { found[s[end++]] = true; continue; } res = max(end - start, res); while (found[s[end]]) { found[s[start++]] = false; } } res = max(res, end - start); return res; }
TBool CIpUpsDialog::ResolveClientNameFromAppArcL(const TSecureId& aSid) /** Gets the caption name for the application from AppArc (if available). @param aSid The secure id of the client process. @return ETrue if a match was found in apparc; otherwise, EFalse is returned. */ { TBool found(EFalse); RApaLsSession apa; CleanupClosePushL(apa); TInt err = apa.Connect(); if (err == KErrNone) { TApaAppInfo* info = new(ELeave) TApaAppInfo(); CleanupStack::PushL(info); err = apa.GetAppInfo(*info, TUid::Uid(aSid)); if (err == KErrNone) { iPromptData->iClientName.Close(); iPromptData->iClientName.Create(info->iCaption); found = ETrue; } else if (err != KErrNotFound) { User::Leave(err); } CleanupStack::PopAndDestroy(info); } else if (err != KErrNotFound) { // If the connection to apparc failed with KErrNotFound // then the error is ignored becase we assume the dialog // creator was invoked from text-shell User::Leave(err); } CleanupStack::PopAndDestroy(&apa); return found; }
void SoundManager::initialiseModule(const ApplicationContext& ctx) { // Create the SoundPlayer if sound is not disabled const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs(); ApplicationContext::ArgumentList::const_iterator found( std::find(args.begin(), args.end(), "--disable-sound") ); if (found == args.end()) { rMessage() << "SoundManager: initialising sound playback" << std::endl; _soundPlayer = boost::shared_ptr<SoundPlayer>(new SoundPlayer); } else { rMessage() << "SoundManager: sound ouput disabled" << std::endl; } }
void Foam::JobInfo::end(const word& terminationType) { if (writeJobInfo && constructed && Pstream::master()) { add("cpuTime", cpuTime_.elapsedCpuTime()); add("endDate", clock::date()); add("endTime", clock::clockTime()); if (!found("termination")) { add("termination", terminationType); } rm(runningJobPath_); write(OFstream(finishedJobPath_)()); } constructed = false; }
int authp9any(Npcfid *afid, Npuser *user, void *aux) { char buf[128], *p, *word, *proto, *dom; int (*found)(Npcfid *afid, Npuser *user, void *aux); int v2, i; if(getline0(afid, buf, sizeof buf) <= 0) return err("botch", EINVAL); p = buf; found = 0; v2 = 0; if(strncmp(p, "v.2 ", 4) == 0) { v2 = 1; p += 4; } while(*p && !found) { if(getWord(&p, ' ', &word) == -1 || getWord(&word, '@', &proto) == -1 || getWord(&word, 0, &dom) == -1) return err("botch", EINVAL); for(i = 0; authprotos[i].name; i++) { if(strcmp(authprotos[i].name, "p9sk1") == 0) { found = authprotos[i].auth; break; } } } if(!found) return err("unsupported", EPROTONOSUPPORT); if(putline0(afid, "%s %s", proto, dom) <= 0) return err("botch", EINVAL); if(v2) { if(getline0(afid, buf, sizeof buf) <= 0) return err("botch", EINVAL); if(strcmp(buf, "OK") != 0) return err("botch", EINVAL); } return found(afid, user, aux); }
Filter_Base* find_filter(const char* filter_id) { if (!filter_id) return 0; std::string filter_id_trimmed(filter_id); generic_util::trim(filter_id_trimmed); if (filter_id_trimmed.empty()) return 0; std::lock_guard<std::recursive_mutex> lock(mutex_); Logger_Settings settings(thread_log_settings_table_[std::hash<std::thread::id>()(std::this_thread::get_id())]); std::map<std::string, std::shared_ptr<Filter_Base>>::iterator found(settings.filter_id_ptr_map.find(filter_id_trimmed)); if (found != settings.filter_id_ptr_map.end()) return found->second.get(); return 0; }
void CmsUtils::AddAlgorithmIdentifierL(RPointerArray<CX509AlgorithmIdentifier>& aAlgorithmIdList, TAlgorithmId aDigestAlgorithm) { TInt found(EFalse); TInt count=aAlgorithmIdList.Count(); for (TInt i=0;i<count;i++) { if (aAlgorithmIdList[i]->Algorithm()==aDigestAlgorithm) { found=ETrue; break; } } if (!found) { CX509AlgorithmIdentifier* digAlg=CX509AlgorithmIdentifier::NewLC(aDigestAlgorithm, KNullDesC8()); aAlgorithmIdList.AppendL(digAlg); CleanupStack::Pop(digAlg); } }
int main() { Linked_list *t = new Linked_list; Linked_list *w = new Linked_list; Create_list(t); Create_list(w); cout << "Введите текст:" << endl; Read(t); cout << "Введите фрагмент для поиска:" << endl; Read(w); if (found(t, w)) cout << "Заданная последовательность символов является фрагментом текста. " << endl; else cout << "Заданная последовательность символов не встречается в тексте." << endl; return 0; }
// ----------------------------------------------------------------------------- // CMmsAdapterMsvApi::AddUserFolderL // Creates new user folder // ----------------------------------------------------------------------------- TInt CMmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName ) { TRACE_FUNC_ENTRY; LOGGER_WRITE_1( "aName: %S", &aName ); // Make sure that we are not going to add same folder twise TBool found( EFalse ); found = FindUserFolderL( aName, aFolder ); if ( found ) { LOGGER_WRITE( "Folder already exists" ); LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" ); return KErrNone; } CMsvEntry* entry = iSession.GetEntryL(KMsvMyFoldersEntryIdValue); CleanupStack::PushL( entry ); TTime date; date.UniversalTime(); TMsvEntry folderEntry; folderEntry.iType = KUidMsvFolderEntry; folderEntry.iMtm = KUidMsvLocalServiceMtm; folderEntry.iDetails.Set( aName ); folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue; folderEntry.iSize = sizeof( folderEntry ); folderEntry.iDate = date; folderEntry.SetStandardFolder( EFalse ); folderEntry.SetVisible( ETrue ); folderEntry.SetComplete( ETrue ); folderEntry.SetInPreparation( EFalse ); folderEntry.SetReadOnly( EFalse ); entry->CreateL( folderEntry ); CleanupStack::PopAndDestroy( entry ); aFolder = folderEntry.Id(); TRACE_FUNC_EXIT; return KErrNone; }
drag_flavor_uber_descriptor_t find_drag_flavor(::DragRef the_drag, InputIterator first, InputIterator last) { ::UInt16 count(0); drag_flavor_descriptor_t result(0, 0); ::CountDragItems(the_drag, &count); for (::UInt16 cur_item_index(1); cur_item_index <= count; ++cur_item_index) { ::DragItemRef drag_item(0); if (::GetDragItemReferenceNumber(the_drag, cur_item_index, &drag_item) != noErr) continue; ::UInt16 flavor_count(0); if (::CountDragItemFlavors(the_drag, drag_item, &flavor_count) != noErr) continue; for (::UInt16 cur_flavor(1); cur_flavor <= flavor_count; ++cur_flavor) { ::FlavorType flavor_type(0); if (::GetFlavorType(the_drag, drag_item, cur_flavor, &flavor_type) == noErr) { InputIterator found(std::find(first, last, flavor_type)); if (found != last) { result.first = drag_item; result.second = cur_flavor; return drag_flavor_uber_descriptor_t(result, *found); } } } } return drag_flavor_uber_descriptor_t(result, flavor_invalid); }
EXPORT_C HBufC* CResourceLoader::Load2L( TInt aResourceId, const TDesC& aString ) { HBufC* resbuf = Load2LC( aResourceId ); TPtr retptr(resbuf->Des()); // Get number of sub strings TInt count = GetSubStringCount( retptr ); TBool marker(EFalse); if (count >= 1) { HBufC* buffer = ResolveSubStringDirsL( retptr, count, &marker ); CleanupStack::PushL(buffer); TBool found(EFalse); TBidiText::TDirectionality mainDir = DirectionalityL(*buffer , &found); //Formating the return string with FormatStringL. HBufC* retbuf = FormatStringL(*buffer, KStringKeyBuf, aString, mainDir); CleanupStack::PopAndDestroy(buffer); CleanupStack::PopAndDestroy(resbuf); if (marker && retbuf->Length()) { TPtr ptr = retbuf->Des(); RemoveNoDirMarkers(ptr); } __ASSERT_DEBUG(retbuf->Length(), User::Panic(KPanicCategory, EKeyStringNotFound)); return retbuf; } else { CleanupStack::PopAndDestroy(resbuf); HBufC* retbuf = HBufC::NewL(0); // return empty buffer __ASSERT_DEBUG(retbuf->Length(), User::Panic(KPanicCategory, EKeyStringNotFound)); return retbuf; } }
// --------------------------------------------------------------------------- // Scans a list of drives for files // --------------------------------------------------------------------------- // void CMPXFolderScanner::ScanL( RArray<TPath>& aDrives ) { MPX_DEBUG1("CMPXFolderScanner::ScanL <---"); // Copy all the other drives we want to scan // TInt count( aDrives.Count() ); MPX_DEBUG2("CMPXFolderScanner::ScanL aDrives %d",count); for( TInt i=0; i<count; ++i ) { // Check if we are already scanning this drive TInt found( iDrivesToScan.FindInOrder( aDrives[i], CompareString ) ); if( found == KErrNotFound ) { iDrivesToScan.Append( aDrives[i] ); } } // If we were already scanning, don't do it again // if( !iScanning ) { // Setup the next drive to scan // if( !SetupNextDriveToScanL() ) { // Kick off the scanning iCurDirQueueEntry = iDirQueue[ 0 ]; iCurFullPath = iCurDirQueueEntry->iFullPath; ReadDirEntry(); // We've started scanning iScanning = ETrue; } else { // Nothing to scan DoScanCompleteL(KErrNone); } } MPX_DEBUG1("CMPXFolderScanner::ScanL --->"); }
int lengthOfLongestSubstring(string s) { if (s.size() == 0) { return 0; } vector<int> found(256, 0); // number of char found int start = 0, end = 0, maxlen = 0; while (end < s.size()) { if (found[s[end]] == 0) { found[s[end]]++; end++; maxlen = max(maxlen, end - start); } else { found[s[start]]--; start++; } } return maxlen; }
// Check if the low-pressure parameters are provided for every species void ExtendedFallOff::CheckForLowPressureKineticParameters(const std::vector< std::vector<std::string> >& coefficients) { std::vector<bool> found(n_); std::fill(found.begin(), found.end(), false); for (unsigned int k = 0; k < species_.size(); k++) for (unsigned int i = 0; i < coefficients.size() - 4; i++) { if (coefficients[i][1] == species_[k] && coefficients[i][0] == "low") { found[k] = true; break; } } for (unsigned int k = 0; k < species_.size(); k++) if (found[k] == false) { ErrorMessage("Too low-pressure kinetic parameters were specified for species: " + species_[k]); } }
// ----------------------------------------------------------------------------- // CMccResourcePool::FindNetworkResourceByRtpSsrc // ----------------------------------------------------------------------------- // TInt CMccResourcePool::FindNetworkResourceByRtpSsrc( const TRtpSSRC& /*aRtpSsrc*/, MDataSource** /*aSource*/, MDataSink** /*aSink*/ ) { TBool found( EFalse ); /* for ( TInt i = 0; i < iEndpoints.Count() && !found; i++ ) { CMccResourceItem* item = iEndpoints[ i ]; if ( item->IsSource() && item->Source()->DataSourceType() == KMccRtpSourceUid ) { CMccRtpDataSource* rtpSource = static_cast<CMccRtpDataSource*>( item->Source() ); if ( rtpSource->HandleBySsrc( aRtpSsrc ) ) { *aSource = item->Source(); found = ETrue; } } else if ( item->IsSink() && item->Sink()->DataSinkType() == KMccRtpSinkUid ) { CMccRtpDataSink* rtpSink = static_cast<CMccRtpDataSink*>( item->Sink() ); if ( rtpSink->HandleBySsrc( aRtpSsrc ) ) { *aSink = item->Sink(); found = ETrue; } } else { } } */ return ( found ? KErrNone : KErrNotFound ); }
bool FileFinder::Find(DirectorySpecifier &dir, Typecode type, bool recursive) { // Get list of entries in directory vector<dir_entry> entries; if (!dir.ReadDirectory(entries)) { return false; } sort(entries.begin(), entries.end()); // Iterate through entries vector<dir_entry>::const_iterator i, end = entries.end(); for (i = entries.begin(); i != end; i++) { // Construct full specifier of file/dir FileSpecifier file = dir + i->name; // DJB Skip our texture directories if ( dir.GetPathString().find ( "SpriteTextures" ) != string::npos || dir.GetPathString().find ( "TTEP" ) != string::npos ) { // Don't go down these paths return false; } if (i->is_directory) { // Recurse into directory if (recursive) { if (Find(file, type, recursive)) { return true; } } } else { // Check file type and call found() function if (type == WILDCARD_TYPE || type == file.GetType()) { if (found(file)) { return true; } } } } return false; }
// ----------------------------------------------------------------------------- // CHttpCacheManager::Find // // ----------------------------------------------------------------------------- // EXPORT_C TBool CHttpCacheManager::Find( const TDesC8& aUrl ) { TBool found( EFalse ); // if( iCacheEnabled || iVSSCacheEnabled ) { CHttpCacheHandler* cache = CacheHandler( aUrl, NULL ); // if( cache ) { found = cache->Find( aUrl ); } if( !found && iVSSCacheEnabled ) { found = iphoneSpecificCache->Find( aUrl ); } } return found; }
Foam::autoPtr<Foam::GAMGInterface> Foam::GAMGInterface::New ( const word& coupleType, const label index, const lduInterfacePtrsList& coarseInterfaces, Istream& is ) { auto cstrIter = IstreamConstructorTablePtr_->cfind(coupleType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown GAMGInterface type " << coupleType << ".\n" << "Valid GAMGInterface types :" << IstreamConstructorTablePtr_->sortedToc() << exit(FatalError); } return autoPtr<GAMGInterface>(cstrIter()(index, coarseInterfaces, is)); }
void KRSearchMod::scanRemoteDir(QUrl url) { vfs * vfs_; if (url.scheme() == QStringLiteral("virt")) { if (virtual_vfs == 0) virtual_vfs = new virt_vfs(0); vfs_ = virtual_vfs; } else { if (remote_vfs == 0) remote_vfs = new ftp_vfs(0); vfs_ = remote_vfs; } if (!vfs_->vfs_refresh(url)) return ; for (vfile * vf = vfs_->vfs_getFirstFile(); vf != 0 ; vf = vfs_->vfs_getNextFile()) { QString name = vf->vfile_getName(); QUrl fileURL = vfs_->vfs_getFile(name); if (query->isRecursive() && ((vf->vfile_isSymLink() && query->followLinks()) || vf->vfile_isDir())) unScannedUrls.push(fileURL); if (query->match(vf)) { // if we got here - we got a winner results.append(fileURL.toDisplayString(QUrl::PreferLocalFile)); emit found(fileURL.fileName(), KIO::upUrl(fileURL).toDisplayString(QUrl::PreferLocalFile | QUrl::StripTrailingSlash), vf->vfile_getSize(), vf->vfile_getTime_t(), vf->vfile_getPerm(), vf->vfile_getUid(), vf->vfile_getGid(), query->foundText()); } if (timer.elapsed() >= EVENT_PROCESS_DELAY) { qApp->processEvents(); timer.start(); if (stopSearch) return; } } }
void CmsUtils::AddCertificateL(RPointerArray<CCmsCertificateChoice>& aCertList, const TDesC8& aCert, CCmsCertificateChoice::TCertificateType aType) { TInt found(EFalse); TInt count=aCertList.Count(); for (TInt i=0;i<count;i++) { if (aCertList[i]->CertificateType()==CCmsCertificateChoice::ECertificateAttribute && aCert.Compare(*aCertList[i]->AttributeCertificate())==0) { found=ETrue; break; } } if (!found) { CCmsCertificateChoice* cert=CCmsCertificateChoice::NewL(aType, aCert); CleanupStack::PushL(cert); aCertList.AppendL(cert); CleanupStack::Pop(cert); } }
int insert_leaf (tree_s *tree, leaf_s *leaf, u64 key, void *rec, unint len) { rec_s *r; int total = len + sizeof(rec_s); FN; r = leaf_search(leaf, key); if (found(leaf, r, key)) { bput(leaf); return qERR_DUP; } memmove(r + 1, r, (char *)&leaf->l_rec[leaf->l_num] - (char *)r); ++leaf->l_num; leaf->l_total -= total; leaf->l_end -= len; r->r_start = leaf->l_end; r->r_len = len; r->r_key = key; pack_rec(tree, (u8 *)leaf + r->r_start, rec, len); bdirty(leaf); bput(leaf); return 0; }