Home | History | Annotate | Download | only in Rewrite

Lines Matching refs:Offset

39 /// the RopePiece corresponding to some offset very efficiently, and it
73 /// when looking for an offset in the BTree.
100 /// split - Split the range containing the specified offset so that we are
102 /// offset. The offset is relative, so "0" is the start of the node.
106 RopePieceBTreeNode *split(unsigned Offset);
109 /// specified offset. The offset is relative, so "0" is the start of the
114 RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
116 /// erase - Remove NumBytes from this node at the specified offset. We are
117 /// guaranteed that there is a split at Offset.
118 void erase(unsigned Offset, unsigned NumBytes);
203 /// split - Split the range containing the specified offset so that we are
205 /// offset. The offset is relative, so "0" is the start of the node.
209 RopePieceBTreeNode *split(unsigned Offset);
212 /// specified offset. The offset is relative, so "0" is the start of the
217 RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
220 /// erase - Remove NumBytes from this node at the specified offset. We are
221 /// guaranteed that there is a split at Offset.
222 void erase(unsigned Offset, unsigned NumBytes);
231 /// split - Split the range containing the specified offset so that we are
233 /// offset. The offset is relative, so "0" is the start of the node.
237 RopePieceBTreeNode *RopePieceBTreeLeaf::split(unsigned Offset) {
239 // specified offset so find it.
240 if (Offset == 0 || Offset == size()) {
245 // Find the piece that this offset lands in.
248 while (Offset >= PieceOffs+Pieces[i].size()) {
253 // If there is already a split point at the specified offset, just return
255 if (PieceOffs == Offset)
258 // Otherwise, we need to split piece 'i' at Offset-PieceOffs. Convert Offset
260 unsigned IntraPieceOffset = Offset-PieceOffs;
269 return insert(Offset, Tail);
274 /// specified offset. The offset is relative, so "0" is the start of the node.
278 RopePieceBTreeNode *RopePieceBTreeLeaf::insert(unsigned Offset,
283 // specified offset so find it.
285 if (Offset == size()) {
290 for (; Offset > SlotOffs; ++i)
292 assert(SlotOffs == Offset && "Split didn't occur before insertion!");
330 if (this->size() >= Offset)
331 this->insert(Offset, R);
333 NewNode->insert(Offset - this->size(), R);
337 /// erase - Remove NumBytes from this node at the specified offset. We are
338 /// guaranteed that there is a split at Offset.
339 void RopePieceBTreeLeaf::erase(unsigned Offset, unsigned NumBytes) {
340 // Since we are guaranteed that there is a split at Offset, we start by
344 for (; Offset > PieceOffs; ++i)
346 assert(PieceOffs == Offset && "Split didn't occur before erase!");
352 for (; Offset+NumBytes > PieceOffs+getPiece(i).size(); ++i)
356 if (Offset+NumBytes == PieceOffs+getPiece(i).size())
370 unsigned CoverBytes = PieceOffs-Offset;
431 /// split - Split the range containing the specified offset so that we are
433 /// offset. The offset is relative, so "0" is the start of the node.
437 RopePieceBTreeNode *split(unsigned Offset);
441 /// specified offset. The offset is relative, so "0" is the start of the
446 RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
452 /// erase - Remove NumBytes from this node at the specified offset. We are
453 /// guaranteed that there is a split at Offset.
454 void erase(unsigned Offset, unsigned NumBytes);
463 /// split - Split the range containing the specified offset so that we are
465 /// offset. The offset is relative, so "0" is the start of the node.
469 RopePieceBTreeNode *RopePieceBTreeInterior::split(unsigned Offset) {
471 if (Offset == 0 || Offset == size())
472 return 0; // If we have an exact offset, we're already split.
476 for (; Offset >= ChildOffset+getChild(i)->size(); ++i)
480 if (ChildOffset == Offset)
484 if (RopePieceBTreeNode *RHS = getChild(i)->split(Offset-ChildOffset))
490 /// specified offset. The offset is relative, so "0" is the start of the
495 RopePieceBTreeNode *RopePieceBTreeInterior::insert(unsigned Offset,
498 // specified offset so find it.
502 if (Offset == size()) {
507 for (; Offset > ChildOffs+getChild(i)->size(); ++i)
514 if (RopePieceBTreeNode *RHS = getChild(i)->insert(Offset-ChildOffs, R))
562 /// erase - Remove NumBytes from this node at the specified offset. We are
563 /// guaranteed that there is a split at Offset.
564 void RopePieceBTreeInterior::erase(unsigned Offset, unsigned NumBytes) {
568 // Find the first child that overlaps with Offset.
570 for (; Offset >= getChild(i)->size(); ++i)
571 Offset -= getChild(i)->size();
580 if (Offset+NumBytes < CurChild->size()) {
581 CurChild->erase(Offset, NumBytes);
587 if (Offset) {
588 unsigned BytesFromChild = CurChild->size()-Offset;
589 CurChild->erase(Offset, BytesFromChild);
592 Offset = 0;
619 /// split - Split the range containing the specified offset so that we are
621 /// offset. The offset is relative, so "0" is the start of the node.
625 RopePieceBTreeNode *RopePieceBTreeNode::split(unsigned Offset) {
626 assert(Offset <= size() && "Invalid offset to split!");
628 return Leaf->split(Offset);
629 return cast<RopePieceBTreeInterior>(this)->split(Offset);
633 /// specified offset. The offset is relative, so "0" is the start of the
638 RopePieceBTreeNode *RopePieceBTreeNode::insert(unsigned Offset,
640 assert(Offset <= size() && "Invalid offset to insert!");
642 return Leaf->insert(Offset, R);
643 return cast<RopePieceBTreeInterior>(this)->insert(Offset, R);
646 /// erase - Remove NumBytes from this node at the specified offset. We are
647 /// guaranteed that there is a split at Offset.
648 void RopePieceBTreeNode::erase(unsigned Offset, unsigned NumBytes) {
649 assert(Offset+NumBytes <= size() && "Invalid offset to erase!");
651 return Leaf->erase(Offset, NumBytes);
652 return cast<RopePieceBTreeInterior>(this)->erase(Offset, NumBytes);
738 void RopePieceBTree::insert(unsigned Offset, const RopePiece &R) {
739 // #1. Split at Offset.
740 if (RopePieceBTreeNode *RHS = getRoot(Root)->split(Offset))
744 if (RopePieceBTreeNode *RHS = getRoot(Root)->insert(Offset, R))
748 void RopePieceBTree::erase(unsigned Offset, unsigned NumBytes) {
749 // #1. Split at Offset.
750 if (RopePieceBTreeNode *RHS = getRoot(Root)->split(Offset))
754 getRoot(Root)->erase(Offset, NumBytes);