本文整理汇总了C++中size函数的典型用法代码示例。如果您正苦于以下问题:C++ size函数的具体用法?C++ size怎么用?C++ size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
reference operator[]( size_t n )
{
assert(n < size());
return reference( *this, n, queue);
}
示例2: size
void eWindow::hide() {
if (m_animation_mode & 0x10)
m_desktop->sendHide(position(), size());
eWidget::hide();
}
示例3: size
void WebPage::createWindow() {
QSize size(1680, 1050);
setViewportSize(size);
}
示例4: Cancel
void RWsTextCursor::SetL(const TWsWinCmdSetTextCursor &aSet, TBool aClipped)
{
if (aSet.cursor.iType < TTextCursor::ETypeFirst ||
(aSet.cursor.iType > TTextCursor::ETypeLast &&
aSet.cursor.iType <= TTextCursor::ETypeLastBasic) ||
(aSet.cursor.iFlags&static_cast<TUint>(ETextCursorPrivateFlags)))
{
Cancel();
iGroupWin->OwnerPanic(EWservPanicInvalidTextCursor);
}
else
{
CWsClientWindow* win = NULL;
iGroupWin->WsOwner()->HandleToClientWindow(aSet.window, &win);
// Check window is a child of the group window
CWsWindowBase* searchWin = NULL;
for(searchWin=win; searchWin->WinType()!=EWinTypeGroup; searchWin=searchWin->BaseParent())
{}
if (iGroupWin != searchWin)
{
Cancel();
iGroupWin->OwnerPanic(EWservPanicWindow);
}
TPoint pos(aSet.pos.iX, aSet.pos.iY-aSet.cursor.iAscent);
TSize size(aSet.cursor.iWidth, aSet.cursor.iHeight);
TUint flags = aSet.cursor.iFlags;
TInt type = aSet.cursor.iType;
TRect clipRect = iClipRect;
TRgb color = aSet.cursor.iColor;
CWsCustomTextCursor* customTextCursor = iCustomTextCursor;
TBool changed = EFalse;
TPoint clipOrigo;
TSize clipSize;
if (type > TTextCursor::ETypeLastBasic)
{
changed = ETrue;
customTextCursor = CWsClient::FindCustomTextCursor(type);
if (!customTextCursor)
{
Cancel();
iGroupWin->OwnerPanic(EWservPanicNoCustomTextCursor);
return;
}
if( !customTextCursor->HasSpriteMember() )
{
iGroupWin->OwnerPanic(EWservPanicNoSpriteMember);
return;
}
TInt yAdjust=0;
switch (customTextCursor->Alignment())
{
case RWsSession::ECustomTextCursorAlignTop:
break;
case RWsSession::ECustomTextCursorAlignBaseline:
yAdjust = aSet.cursor.iAscent-1;
break;
case RWsSession::ECustomTextCursorAlignBottom:
yAdjust = aSet.cursor.iHeight-1;
break;
default:
Cancel();
iGroupWin->OwnerPanic(EWservPanicCustomTextCursorAlign);
return;
}
pos.iY += yAdjust;
// Start with a clipping rect to be the whole window
// relative cursor pos and shrink down to what we want
clipOrigo = -pos;
clipSize = win->Size();
if (flags & TTextCursor::EFlagClipHorizontal)
{
clipOrigo.iX = 0;
clipSize.iWidth = size.iWidth;
}
if (flags & TTextCursor::EFlagClipVertical)
{
clipOrigo.iY = -yAdjust;
clipSize.iHeight = aSet.cursor.iHeight;
}
}
else
{
customTextCursor = NULL;
}
if (aClipped)
{
flags|=ETextCursorFlagClipped;
clipRect=aSet.rect;
}
if (pos != iPos || size != iSize || iType != type ||
flags != iFlags || clipRect != iClipRect || color != iColor ||
//.........这里部分代码省略.........
示例5: BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(test_result_contains_object, WithSphere) {
const auto result = hitTest.sphereTest({0.f, 0.f, 0.f}, 1.f);
BOOST_ASSERT(result.size() == 1);
BOOST_CHECK_EQUAL(result[0].object, object);
}
示例6: getType
string ofParameterGroup::getType(int position) const {
if(position>=size()) return "";
else return obj->parameters[position]->type();
}
示例7: grow
objVectorOop objVectorOopClass::grow(fint delta, bool mustAllocate) {
objVectorOop v= (objVectorOop) slotsOopClass::grow(size(), delta,
mustAllocate);
if (oop(v) != failedAllocationOop) v->set_length(length() + delta);
return v;
}
示例8: main
int main(int argc, char* argv[])
{
// check for correct number of args
if (argc != 2 && argc != 3)
{
printf("Usage: speller [dictionary] text\n");
return 1;
}
// structs for timing data
struct rusage before, after;
// benchmarks
double time_load = 0.0, time_check = 0.0, time_size = 0.0, time_unload = 0.0;
// determine dictionary to use
char* dictionary = (argc == 3) ? argv[1] : DICTIONARY;
// load dictionary
getrusage(RUSAGE_SELF, &before);
bool loaded = load(dictionary);
getrusage(RUSAGE_SELF, &after);
// abort if dictionary not loaded
if (!loaded)
{
printf("Could not load %s.\n", dictionary);
return 1;
}
// calculate time to load dictionary
time_load = calculate(&before, &after);
// try to open text
char* text = (argc == 3) ? argv[2] : argv[1];
FILE* fp = fopen(text, "r");
if (fp == NULL)
{
printf("Could not open %s.\n", text);
unload();
return 1;
}
// prepare to report misspellings
printf("\nMISSPELLED WORDS\n\n");
// prepare to spell-check
int index = 0, misspellings = 0, words = 0;
char word[LENGTH+1];
// spell-check each word in text
for (int c = fgetc(fp); c != EOF; c = fgetc(fp))
{
// allow only alphabetical characters and apostrophes
if (isalpha(c) || (c == '\'' && index > 0))
{
// append character to word
word[index] = c;
index++;
// ignore alphabetical strings too long to be words
if (index > LENGTH)
{
// consume remainder of alphabetical string
while ((c = fgetc(fp)) != EOF && isalpha(c));
// prepare for new word
index = 0;
}
}
// ignore words with numbers (like MS Word can)
else if (isdigit(c))
{
// consume remainder of alphanumeric string
while ((c = fgetc(fp)) != EOF && isalnum(c));
// prepare for new word
index = 0;
}
// we must have found a whole word
else if (index > 0)
{
// terminate current word
word[index] = '\0';
// update counter
words++;
// check word's spelling
getrusage(RUSAGE_SELF, &before);
bool misspelled = !check(word);
getrusage(RUSAGE_SELF, &after);
// update benchmark
time_check += calculate(&before, &after);
// print word if misspelled
if (misspelled)
//.........这里部分代码省略.........
示例9: kill
void kill(Treap *t) {
if (!size(t)) return;
kill(t->l);
kill(t->r);
delete t;
}
示例10: size
DecoratorDialog::~DecoratorDialog() {
previous_size = size();
}
示例11: pull
void pull(Treap *t) {
push(t->l);
push(t->r);
t->size = size(t->l) + size(t->r) + 1;
}
示例12: push
void push(Treap *t) {
if (!size(t)) return;
}
示例13: end
iterator end()
{
return iterator(*this, size(), queue);
}
示例14: test
void test(RandomForestImage& randomForest, const std::string& folderTesting,
const std::string& folderPrediction, const bool useDepthFilling,
const bool writeProbabilityImages) {
auto filenames = listImageFilenames(folderTesting);
if (filenames.empty()) {
throw std::runtime_error(std::string("found no files in ") + folderTesting);
}
CURFIL_INFO("got " << filenames.size() << " files for prediction");
CURFIL_INFO("label/color map:");
const auto labelColorMap = randomForest.getLabelColorMap();
for (const auto& labelColor : labelColorMap) {
const auto color = LabelImage::decodeLabel(labelColor.first);
CURFIL_INFO("label: " << static_cast<int>(labelColor.first) << ", color: RGB(" << color << ")");
}
// tbb::mutex totalMutex;
utils::Average averageAccuracy;
utils::Average averageAccuracyWithoutVoid;
size_t i = 0;
const bool useCIELab = randomForest.getConfiguration().isUseCIELab();
CURFIL_INFO("CIELab: " << useCIELab);
CURFIL_INFO("DepthFilling: " << useDepthFilling);
const bool useDepthImages = randomForest.getConfiguration().isUseDepthImages();
CURFIL_INFO("useDepthImages: " << useDepthImages);
bool onGPU = randomForest.getConfiguration().getAccelerationMode() == GPU_ONLY;
size_t grainSize = 1;
if (!onGPU) {
grainSize = filenames.size();
}
bool writeImages = true;
if (folderPrediction.empty()) {
CURFIL_WARNING("no prediction folder given. will not write images");
writeImages = false;
}
std::vector<LabelType> ignoredLabels;
for (const std::string colorString : randomForest.getConfiguration().getIgnoredColors()) {
ignoredLabels.push_back(LabelImage::encodeColor(RGBColor(colorString)));
}
const LabelType numClasses = randomForest.getNumClasses();
ConfusionMatrix totalConfusionMatrix(numClasses, ignoredLabels);
double totalPredictionTime = 0;
{
// tbb::parallel_for(tbb::blocked_range<size_t>(0, filenames.size(), grainSize),
// [&](const tbb::blocked_range<size_t>& range) {
for(size_t fileNr = 0; fileNr != filenames.size(); fileNr++) {
const std::string& filename = filenames[fileNr];
const auto imageLabelPair = loadImagePair(filename, useCIELab, useDepthImages, useDepthFilling);
const RGBDImage& testImage = imageLabelPair.getRGBDImage();
const LabelImage& groundTruth = imageLabelPair.getLabelImage();
LabelImage prediction(testImage.getWidth(), testImage.getHeight());
for(int y = 0; y < groundTruth.getHeight(); y++) {
for(int x = 0; x < groundTruth.getWidth(); x++) {
const LabelType label = groundTruth.getLabel(x, y);
if (label >= numClasses) {
const auto msg = (boost::format("illegal label in ground truth image '%s' at pixel (%d,%d): %d RGB(%3d,%3d,%3d) (numClasses: %d)")
% filename
% x % y
% static_cast<int>(label)
% LabelImage::decodeLabel(label)[0]
% LabelImage::decodeLabel(label)[1]
% LabelImage::decodeLabel(label)[2]
% static_cast<int>(numClasses)
).str();
throw std::runtime_error(msg);
}
}
}
boost::filesystem::path fn(testImage.getFilename());
const std::string basepath = folderPrediction + "/" + boost::filesystem::basename(fn);
cuv::ndarray<float, cuv::host_memory_space> probabilities;
utils::Timer timer2;
prediction = randomForest.predict(testImage, &probabilities, onGPU, useDepthImages);
totalPredictionTime += timer2.getMilliseconds();
#ifndef NDEBUG
for(LabelType label = 0; label < randomForest.getNumClasses(); label++) {
if (!randomForest.shouldIgnoreLabel(label)) {
continue;
}
// ignored classes must not be predicted as we did not sample them
for(size_t y = 0; y < probabilities.shape(1); y++) {
for(size_t x = 0; x < probabilities.shape(2); x++) {
const float& probability = probabilities(label, y, x);
assert(probability == 0.0);
}
//.........这里部分代码省略.........
示例15: stateSaver
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
{
if (!nativeImageForCurrentFrame())
return;
if (!patternTransform.isInvertible())
return;
CGContextRef context = ctxt->platformContext();
GraphicsContextStateSaver stateSaver(*ctxt);
CGContextClipToRect(context, destRect);
ctxt->setCompositeOperation(op, blendMode);
CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
CGContextScaleCTM(context, 1, -1);
// Compute the scaled tile size.
float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
// We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
// the origin).
float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);
CGImageRef tileImage = nativeImageForCurrentFrame();
float h = CGImageGetHeight(tileImage);
RetainPtr<CGImageRef> subImage;
if (tileRect.size() == size())
subImage = tileImage;
else {
// Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
// because sub-images are only used for border-image, which only renders when the image is fully decoded.
ASSERT(h == height());
subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
}
// Adjust the color space.
subImage = Image::imageWithColorSpace(subImage.get(), styleColorSpace);
// Leopard has an optimized call for the tiling of image patterns, but we can only use it if the image has been decoded enough that
// its buffer is the same size as the overall image. Because a partially decoded CGImageRef with a smaller width or height than the
// overall image buffer needs to tile with "gaps", we can't use the optimized tiling call in that case.
// FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors. Snow Leopard is ok.
float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
float w = CGImageGetWidth(tileImage);
if (w == size().width() && h == size().height() && !spaceSize().width() && !spaceSize().height())
CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
else {
// On Leopard and newer, this code now only runs for partially decoded images whose buffers do not yet match the overall size of the image.
static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, patternReleaseCallback };
CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
// The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
#if PLATFORM(IOS)
matrix = CGAffineTransformScale(matrix, 1, -1);
matrix = CGAffineTransformTranslate(matrix, 0, -h);
#endif
CGImageRef platformImage = CGImageRetain(subImage.get());
RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreate(platformImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), matrix,
tileRect.width() + spaceSize().width() * (1 / narrowPrecisionToFloat(patternTransform.a())),
tileRect.height() + spaceSize().height() * (1 / narrowPrecisionToFloat(patternTransform.d())),
kCGPatternTilingConstantSpacing, true, &patternCallbacks));
if (!pattern)
return;
RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
CGFloat alpha = 1;
RetainPtr<CGColorRef> color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha));
CGContextSetFillColorSpace(context, patternSpace.get());
// FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
wkSetBaseCTM(context, CGAffineTransformIdentity);
CGContextSetPatternPhase(context, CGSizeZero);
CGContextSetFillColorWithColor(context, color.get());
CGContextFillRect(context, CGContextGetClipBoundingBox(context));
}
stateSaver.restore();
if (imageObserver())
imageObserver()->didDraw(this);
}