本文整理汇总了C++中ConstIterator类的典型用法代码示例。如果您正苦于以下问题:C++ ConstIterator类的具体用法?C++ ConstIterator怎么用?C++ ConstIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: localContext
/******************* FUNCTION *********************/
void ProjectActionOld::genItLoopCCode ( ostream& out, const CMRProjectContext& context, int depth ) const
{
CMRProjectContext localContext(&context);
//errors
assert(name == "cmrSubBlock" && description == "cmrIteratorLoop");
//search the related iterator definition
const CMRProjectEntity * entity = context.parent->find(eq->latexEntity);
if (entity == NULL)
{
cerr << "Can't find the definition of iterator " << eq->compute << " in current context." << endl;
abort();
}
const CMRProjectIterator * iterator = dynamic_cast<const CMRProjectIterator*>(entity);
if (iterator == NULL)
{
cerr << "Cuation, expect iterator " << eq->compute << " but get another type." << endl;
context.printDebug();
abort();
}
assert(iterator != NULL);
CMRProjectLocalVariable localVar(eq->compute,eq->compute);
localContext.addEntry(&localVar);
out << genCCodeIndent(depth) << "for (int " << eq->compute << " = " << iterator->start << " ; " << eq->compute << " < " << iterator->end << " ; " << eq->compute << "++ )" <<endl;
out << genCCodeIndent(depth) << "{" << endl;
for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
it->genCCode(out,it->context,depth+1);
//it->genCCode(out,localContext,depth+1);
out << genCCodeIndent(depth) << "}" << endl;
//checkContext(localContext);
}
示例2: Q_ASSERT
bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags)
{
Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);
Iterator entry = findEntry(group, key, flags);
if (entry != end()) {
//qDebug() << "reverting" << entry.key() << " = " << entry->mValue;
if (entry->bReverted) { // already done before
return false;
}
KEntryKey defaultKey(entry.key());
defaultKey.bDefault = true;
//qDebug() << "looking up default entry with key=" << defaultKey;
const ConstIterator defaultEntry = constFind(defaultKey);
if (defaultEntry != constEnd()) {
Q_ASSERT(defaultEntry.key().bDefault);
//qDebug() << "found, update entry";
*entry = *defaultEntry; // copy default value, for subsequent lookups
} else {
entry->mValue = QByteArray();
}
entry->bDirty = true;
entry->bReverted = true; // skip it when writing out to disk
//qDebug() << "Here's what we have now:" << *this;
return true;
}
return false;
}
示例3: get_mean
float get_mean(Image::Pointer im)
{
ConstIterator it;
it = ConstIterator(im, im->GetLargestPossibleRegion());
float mean = 0, N=0;
try
{
while(!it.IsAtEnd())
{
if(it.Get()!=0)
{
mean = N/(N+1)*mean + it.Get()/(N+1);
++N;
}
++it;
}
}
catch( itk::ExceptionObject & err)
{
std::cout<<"Error calculating mean, iterator error"<<std::endl;
std::cout<<err<<std::endl;
}
return mean;
}
示例4: largestFragment
inline typename ListType::ConstIterator largestFragment(const ListType& src)
{
typedef typename ListType::ConstIterator ConstIterator;
ConstIterator result = src.begin();
for( ConstIterator i = result; i != src.end(); ++i )
if( result->length() < i->length() ) result = i;
return result;
}
示例5: findBreakpointByAddress
BreakpointId BreakHandler::findBreakpointByAddress(quint64 address) const
{
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
for ( ; it != et; ++it)
if (it->data.address == address || it->response.address == address)
return it.key();
return BreakpointId();
}
示例6: findBreakpointByFunction
BreakpointId BreakHandler::findBreakpointByFunction(const QString &functionName) const
{
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
for ( ; it != et; ++it)
if (it->data.functionName == functionName)
return it.key();
return BreakpointId();
}
示例7: findBreakpointByFileAndLine
BreakpointId BreakHandler::findBreakpointByFileAndLine(const QString &fileName,
int lineNumber, bool useMarkerPosition)
{
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
for ( ; it != et; ++it)
if (it->isLocatedAt(fileName, lineNumber, useMarkerPosition))
return it.key();
return BreakpointId();
}
示例8: getAnnotationStatistics
AnnotationStatistics FeatureMap::getAnnotationStatistics() const
{
AnnotationStatistics result;
for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
{
result += iter->getAnnotationState();
}
return result;
}
示例9: makeTiled
Int64
Header::writeTo (OStream &os, bool isTiled) const
{
//
// Write a "magic number" to identify the file as an image file.
// Write the current file format version number.
//
Xdr::write <StreamIO> (os, MAGIC);
int version = isTiled ? makeTiled (EXR_VERSION) : EXR_VERSION;
Xdr::write <StreamIO> (os, version);
//
// Write all attributes. If we have a preview image attribute,
// keep track of its position in the file.
//
Int64 previewPosition = 0;
const Attribute *preview =
findTypedAttribute <PreviewImageAttribute> ("preview");
for (ConstIterator i = begin(); i != end(); ++i)
{
//
// Write the attribute's name and type.
//
Xdr::write <StreamIO> (os, i.name());
Xdr::write <StreamIO> (os, i.attribute().typeName());
//
// Write the size of the attribute value,
// and the value itself.
//
StdOSStream oss;
i.attribute().writeValueTo (oss, version);
std::string s = oss.str();
Xdr::write <StreamIO> (os, (int) s.length());
if (&i.attribute() == preview)
previewPosition = os.tellp();
os.write (s.data(), s.length());
}
//
// Write zero-length attribute name to mark the end of the header.
//
Xdr::write <StreamIO> (os, "");
return previewPosition;
}
示例10: get
const char* MessageHeader::get(const char* key) const
{
for (ConstIterator it = begin(); it != end(); ++it)
{
if (compareIgnoreCase(key, it->name()) == 0)
return it->value();
}
return 0;
}
示例11: eptr
void MessageHeader::remove(const char* key)
{
if( ! *key)
throw std::invalid_argument("header key is NULL");
char* p = eptr();
ConstIterator it = begin();
while (it != end())
{
if (compareIgnoreCase(key, it->name()) == 0)
{
std::size_t slen = it->value() - it->name() + std::strlen(it->value()) + 1;
std::memcpy(
const_cast<char*>(it->name()),
it->name() + slen,
p - it->name() + slen);
p -= slen;
it.fixup();
}
else
++it;
}
_endOffset = p - _rawdata;
}
示例12: finalText
QString TemplateDocument::finalText() const
{
QString ready = d->templateText;
typedef QMap<QString, QString>::ConstIterator ConstIterator;
ConstIterator end = d->templateEntries.constEnd();
for (ConstIterator i = d->templateEntries.constBegin(); i != end; i++) {
ready.replace(QLatin1Char('%') + i.key() + QLatin1Char('%'), i.value());
}
d->processTemplateIncludes(ready);
return ready;
}
示例13: findWatchpoint
BreakpointId BreakHandler::findWatchpoint(const BreakpointParameters &data) const
{
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
for ( ; it != et; ++it)
if (it->data.isWatchpoint()
&& it->data.address == data.address
&& it->data.size == data.size
&& it->data.bitpos == data.bitpos)
return it.key();
return BreakpointId();
}
示例14: selectBlock
typename ListType::FragmentType
selectBlock(const ListType& src, typename ListType::FSizeType blockSize,
const AvailableType* available )
{
typedef typename ListType::FragmentType FragmentType;
typedef typename ListType::FSizeType FSizeType;
typedef typename ListType::ConstIterator ConstIterator;
if( src.empty() ) return FragmentType( 0,
::std::numeric_limits< FSizeType >::max() );
::std::deque< FSizeType > blocks;
for( ConstIterator selectIterator = src.begin();
selectIterator != src.end(); ++selectIterator )
{
FSizeType blockBegin = selectIterator->begin() / blockSize;
FSizeType blockEnd = ( selectIterator->end() - 1 ) / blockSize;
if ( selectIterator->begin() % blockSize )
{
// the start of a block is complete, but part is missing
if ( !available || available[ blockBegin ] )
{
return FragmentType( selectIterator->begin(),
::std::min( selectIterator->end(),
blockSize * ( blockBegin + 1 ) ) );
}
++blockBegin;
}
if ( blockBegin <= blockEnd && selectIterator->end() % blockSize
&& selectIterator->end() < src.limit() )
{
// the end of a block is complete, but part is missing
if ( !available || available[ blockEnd ] )
{
return FragmentType( blockEnd * blockSize,
selectIterator->end() );
}
--blockEnd;
}
// this fragment contains one or more aligned empty blocks
if( blockEnd != ~0ULL ) for( ; blockBegin <= blockEnd; ++blockBegin )
{
if( !available || available[ blockBegin ] )
{
blocks.push_back( blockBegin );
}
}
}
if( blocks.empty() ) return FragmentType( 0,
::std::numeric_limits< FSizeType >::max() );
FSizeType blockBegin = blocks[ ::std::rand() % blocks.size() ] * blockSize;
return FragmentType( blockBegin, ::std::min( blockBegin + blockSize, src.limit() ) );
}
示例15: begin
bool SVGTransformList::concatenate(AffineTransform& result) const
{
if (isEmpty())
return false;
ConstIterator it = begin();
ConstIterator itEnd = end();
for (; it != itEnd; ++it)
result *= it->matrix();
return true;
}