本文整理汇总了C++中DoublyLinkedList::First方法的典型用法代码示例。如果您正苦于以下问题:C++ DoublyLinkedList::First方法的具体用法?C++ DoublyLinkedList::First怎么用?C++ DoublyLinkedList::First使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList::First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MockStruct
//
// First
//
TEST_F( SimplexSupportDoublyLinkedList, FirstReturnsLastElementPushedToFront )
{
MockStruct* m1 = new MockStruct();
MockStruct* m2 = new MockStruct();
MockStruct* m3 = new MockStruct();
DoublyLinkedList list;
list.PushFront(m1);
ASSERT_EQ(list.First()->Value, (MockStruct*)m1);
list.PushFront(m2);
ASSERT_EQ(list.First()->Value, (MockStruct*)m2);
list.PushFront(m3);
ASSERT_EQ(list.First()->Value, (MockStruct*)m3);
delete(m1);
delete(m2);
delete(m3);
}
示例2: GetVolume
// RemoveAttribute
status_t
Node::RemoveAttribute(Attribute *attribute)
{
status_t error = (attribute && attribute->GetNode() == this
? B_OK : B_BAD_VALUE);
if (error == B_OK) {
// move all iterators pointing to the attribute to the next attribute
if (GetVolume()->IteratorLock()) {
// set the iterators' current entry
Attribute *nextAttr = fAttributes.GetNext(attribute);
DoublyLinkedList<AttributeIterator> *iterators
= attribute->GetAttributeIteratorList();
for (AttributeIterator *iterator = iterators->First();
iterator;
iterator = iterators->GetNext(iterator)) {
iterator->SetCurrent(nextAttr, true);
}
// Move the iterators from one list to the other, or just remove
// them, if there is no next attribute.
if (nextAttr) {
DoublyLinkedList<AttributeIterator> *nextIterators
= nextAttr->GetAttributeIteratorList();
nextIterators->MoveFrom(iterators);
} else
iterators->RemoveAll();
GetVolume()->IteratorUnlock();
} else
error = B_ERROR;
// remove the attribute
if (error == B_OK) {
error = GetVolume()->NodeAttributeRemoved(GetID(), attribute);
if (error == B_OK) {
fAttributes.Remove(attribute);
attribute->SetNode(NULL);
MarkModified();
}
}
}
return error;
}