Пример #1
0
static void testDoublyLinked()
{
    DoublyLinkedList<TestItem, offsetof(TestItem, dlMembership)> list;

    unsigned i;
    for(i = 10; i > 0; --i)
    {
        TestItem *pItem = new TestItem;
        pItem->x = i;
        list.prepend(pItem);
    }

    TestItem *pItem;
    for(pItem = list.getLast(), i = 10; pItem;
        --i, pItem = list.getPrevious(pItem))
    {
        assert(pItem->x == i);
    }
    assert(i == 0); // we saw them all
}
 double getLast() { return dll->getLast(); }