Exemplo n.º 1
0
void 
BTnode::InsertBefore(const GiSTentry& entry, int index)
{
    // Only BTentry's can be inserted into BTnodes.
    assert(entry.IsA() == BTENTRY_CLASS);

    BTentry e((const BTentry&) entry);

    // If this is an internal node, adjust the lower/upper bounds
    if (!IsLeaf()) {
	// If not leftmost entry...
	if (index != 0) {
	    // -inf changes to the upper bound of previous item
	    BTentry *prev = (BTentry*) (*this)[index-1].Ptr();
	    if (e.LowerBound() == NegInf)
		e.SetLowerBound(prev->UpperBound());
	}
	// If not rightmost entry...
	if (index != NumEntries()) {
	    // +inf changes to the lower bound of next item
	    BTentry *next = (BTentry*) (*this)[index].Ptr();
	    if (e.UpperBound() == PosInf)
		e.SetUpperBound(next->LowerBound());
	}
    }

    // Insert it into the node
    GiSTnode::InsertBefore(e, index);
}
Exemplo n.º 2
0
void 
BTnode::Insert(const GiSTentry &entry)
{
    // Only BTentry's can be inserted into BTnode's.
    assert(entry.IsA() == BTENTRY_CLASS);

    // This doesn't work for internal nodes.  For internal nodes,
    // the caller must know exactly where to insert.
    assert(IsLeaf());
   
    GiSTnode::Insert(entry);
}