void MamdaOrderBookPriceLevel::setAsDifference (
        const MamdaOrderBookPriceLevel&  lhs,
        const MamdaOrderBookPriceLevel&  rhs)
    {
        assert (lhs.getPrice() == rhs.getPrice());

        MamdaOrderBookPriceLevel::iterator lhsEnd  = end();
        MamdaOrderBookPriceLevel::iterator lhsIter = begin();
        MamdaOrderBookPriceLevel::iterator rhsEnd  = end();
        MamdaOrderBookPriceLevel::iterator rhsIter = begin();

        while ((lhsIter != lhsEnd) && (rhsIter != rhsEnd))
        {
            const char*      lhsId   = NULL;
            const char*      rhsId   = NULL;
            mama_quantity_t  lhsSize = 0.0;
            mama_quantity_t  rhsSize = 0.0;

            if (lhsIter != lhsEnd)
            {
                const MamdaOrderBookEntry* entry = *lhsIter;
                lhsId   = entry->getId();
                lhsSize = entry->getSize();
            }
            if (rhsIter != rhsEnd)
            {
                const MamdaOrderBookEntry* entry = *rhsIter;
                rhsId   = entry->getId();
                rhsSize = entry->getSize();
            }

            if (lhsId && rhsId)
            {
                if (strcmp(lhsId,rhsId)==0)
                {
                    // Same ID, maybe different size.
                    if (mama_isQuantityEqual (lhsSize, rhsSize))
                    {
                        MamdaOrderBookEntry* updateEntry =
                            new MamdaOrderBookEntry (**rhsIter);
                        updateEntry->setAction(
                            MamdaOrderBookEntry::MAMDA_BOOK_ACTION_UPDATE);
                        addEntry (updateEntry);
                    }
                    ++lhsIter;
                    ++rhsIter;
                    continue;
                }
                else
                {
                    // Different ID (either something exists on the LHS
                    // and not on RHS or vice versa).
                    MamdaOrderBookPriceLevel::const_iterator rhsFound = 
                        findEntryAfter (rhsIter, lhsId);
                    if (rhsFound != rhsEnd)
                    {
                        // The ID from the LHS was found on the RHS, so
                        // there must have been additional entries on the
                        // RHS, which we now need to add.
                        do
                        {
                            MamdaOrderBookEntry* entry =
                                new MamdaOrderBookEntry(**rhsIter);
                            addEntry (entry);
                            ++rhsIter;
                        }
                        while (rhsIter != rhsFound);
                    }
                    else
                    {
                        // The ID from the LHS was not present on the RHS,
                        // so add the LHS entry.  Note: it would probably
                        // be faster to iterate over the LHS side rather
                        // than begin the loop again.
                        MamdaOrderBookEntry* entry =
                            new MamdaOrderBookEntry(**lhsIter);
                        addEntry (entry);
                        ++lhsIter;
                    }
                }
            }
        }

        setPrice (rhs.getPrice());
        setSizeChange (rhs.getSize() - lhs.getSize());
        setSize (rhs.getSize());
        setNumEntries (rhs.getNumEntries());
        setAction (MamdaOrderBookPriceLevel::MAMDA_BOOK_ACTION_UPDATE);
        setTime (rhs.getTime());
        setSide (rhs.getSide());
    }