Example #1
0
    void testBookSet ()
    {
        Currency const c1 (1);
        Account   const i1 (1);
        Currency const c2 (2);
        Account   const i2 (2);
        IssueRef const a1 (c1, i1);
        IssueRef const a2 (c2, i2);
        BookRef  const b1 (a1, a2);
        BookRef  const b2 (a2, a1);

        {
            Set c;

            c.insert (b1);
            if (! expect (c.size () == 1)) return;
            c.insert (b2);
            if (! expect (c.size () == 2)) return;

            if (! expect (c.erase (Book (a1, a1)) == 0)) return;
            if (! expect (c.erase (Book (a1, a2)) == 1)) return;
            if (! expect (c.erase (Book (a2, a1)) == 1)) return;
            if (! expect (c.empty ())) return;
        }

        {
            Set c;

            c.insert (b1);
            if (! expect (c.size () == 1)) return;
            c.insert (b2);
            if (! expect (c.size () == 2)) return;

            if (! expect (c.erase (BookRef (a1, a1)) == 0)) return;
            if (! expect (c.erase (BookRef (a1, a2)) == 1)) return;
            if (! expect (c.erase (BookRef (a2, a1)) == 1)) return;
            if (! expect (c.empty ())) return;

    #if STL_SET_HAS_EMPLACE
            c.emplace (a1, a2);
            if (! expect (c.size() == 1)) return;
            c.emplace (a2, a1);
            if (! expect (c.size() == 2)) return;
    #endif
        }
    }
Example #2
0
 /**
  * Make a range allocated.
  */
 void setAllocated(size_t off, size_t size) {
     assert(0 < size);
     const auto p0 = set_.emplace(off, size);
     unusedVar(p0);
     assert(p0.second);
     allocated_ += size;
     if (maxItemSize_ < size) { maxItemSize_ = size; }
 }
 static void         load(BinaryBuffer& bb, Set& m)
 {
   size_t s;
   diy::load(bb, s);
   for (size_t i = 0; i < s; ++i)
   {
     T p;
     diy::load(bb, p);
     m.emplace(std::move(p));
   }
 }