当前位置: 首页>>代码示例>>C++>>正文


C++ PositionIterator类代码示例

本文整理汇总了C++中PositionIterator的典型用法代码示例。如果您正苦于以下问题:C++ PositionIterator类的具体用法?C++ PositionIterator怎么用?C++ PositionIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PositionIterator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: quantize

void quantize(Grid<Y> & dst, Grid<Y> & src)
{
    assert(dst.h < src.h);
    assert(dst.w < src.w);
    Position tile(src.h / dst.h, src.w / dst.w);  // assume dst divides src
    for (PositionIterator it = dst.positions(); it.more(); ++it) {
        Position & p = it.position;
        std::map<Y, size_t> counts;
        for (PositionIterator to(tile.i, tile.j); to.more(); ++to) {
            Position & tilep = to.position;
            ++counts[src.cell(
                    p.i * tile.i + tilep.i,
                    p.j * tile.j + tilep.j)];
        }
        size_t r = 0;
        const Y  * q = NULL;
        for (typename std::map<Y, size_t>::const_iterator m = counts.begin();
                m != counts.end(); ++m) {
            if (m->second > r) {
                r = m->second;
                q = & m->first;
            }
        }
        dst.cell(it) = *q;
    }
}
开发者ID:biotty,项目名称:rmg,代码行数:26,代码来源:cellular.hpp

示例2: previousCandidate

Position previousCandidate(const Position& position)
{
    PositionIterator p = position;
    while (!p.atStart()) {
        p.decrement();
        if (p.isCandidate())
            return p;
    }
    return Position();
}
开发者ID:johnwpoliver,项目名称:Samsung-GT-P3113-AOSP-CM-Kernel-and-Ramdisk,代码行数:10,代码来源:htmlediting.cpp

示例3: nextCandidate

Position nextCandidate(const Position& position)
{
    PositionIterator p = position;
    while (!p.atEnd()) {
        p.increment();
        if (p.isCandidate())
            return p;
    }
    return Position();
}
开发者ID:johnwpoliver,项目名称:Samsung-GT-P3113-AOSP-CM-Kernel-and-Ramdisk,代码行数:10,代码来源:htmlediting.cpp

示例4: isStreamer

// upstream() and downstream() want to return positions that are either in a
// text node or at just before a non-text node.  This method checks for that.
static bool isStreamer(const PositionIterator& pos)
{
    if (!pos.node())
        return true;
        
    if (isAtomicNode(pos.node()))
        return true;
        
    return pos.atStartOfNode();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:12,代码来源:Position.cpp

示例5: forwardIterator

static bool forwardIterator(PositionIterator& iterator, int distance)
{
    int remaining = distance;
    while (!iterator.atEnd()) {
        if (iterator.node()->isCharacterDataNode()) {
            int length = lastOffsetForEditing(iterator.node());
            int last = length - iterator.offsetInLeafNode();
            if (remaining < last) {
                iterator.setOffsetInLeafNode(iterator.offsetInLeafNode() + remaining);
                return true;
            }

            remaining -= last;
            iterator.setOffsetInLeafNode(iterator.offsetInLeafNode() + last);
        }

        iterator.increment();
    }

    return false;    
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:21,代码来源:SpellChecker.cpp

示例6: node

// P.downstream() returns the end of the range of positions that map to the same VisiblePosition as P.
Position Position::downstream() const
{
    Node* startNode = node();
    if (!startNode)
        return Position();

    // iterate forward from there, looking for a qualified position
    Node* block = enclosingBlock(startNode);
    PositionIterator lastVisible = *this;
    PositionIterator currentPos = lastVisible;
    Node* originalRoot = node()->rootEditableElement();
    for (; !currentPos.atEnd(); currentPos.increment()) {   
        Node* currentNode = currentPos.node();
        
        if (currentNode->rootEditableElement() != originalRoot)
            break;

        // stop before going above the body, up into the head
        // return the last visible streamer position
        if (currentNode->hasTagName(bodyTag) && currentPos.atEndOfNode())
            break;
            
        // Do not enter a new enclosing block flow or table element, and don't leave the original one.
        if (block != enclosingBlock(currentNode))
            return lastVisible;

        // skip position in unrendered or invisible node
        RenderObject* renderer = currentNode->renderer();
        if (!renderer || renderer->style()->visibility() != VISIBLE)
            continue;
            
        // track last visible streamer position
        if (isStreamer(currentPos))
            lastVisible = currentPos;

        // Return position before brs, tables, and nodes which have content that can be ignored.
        if (editingIgnoresContent(currentNode) || renderer->isBR() || isTableElement(currentNode)) {
            if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset())
                return Position(currentNode, renderer->caretMinOffset());
            continue;
        }

        // return current position if it is in rendered text
        if (renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox()) {
            if (currentNode != startNode) {
                ASSERT(currentPos.atStartOfNode());
                return Position(currentNode, renderer->caretMinOffset());
            }

            unsigned textOffset = currentPos.offsetInLeafNode();

            RenderText* textRenderer = static_cast<RenderText*>(renderer);
            for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
                if (textOffset >= box->start() && textOffset <= box->end())
                    return currentPos;
                
                if (box != textRenderer->lastTextBox() && 
                     !box->nextOnLine() &&
                     textOffset == box->start() + box->len()) {
                    return currentPos;
                }
            }
        }
    }
    
    return lastVisible;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:68,代码来源:Position.cpp


注:本文中的PositionIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。