Exemple #1
0
//=========================================================================================
// A failure here could leave the list in a bad state.
bool MultiList::Item::Unlink( MultiList* list )
{
	ItemData* itemData = FindItemData( list );
	if( !itemData )
		return false;
	
	Item* left = itemData->left;
	Item* right = itemData->right;

	if( left )
	{
		itemData = left->FindItemData( list );
		if( !itemData )
			return false;
		itemData->right = right;
	}

	if( right )
	{
		itemData = right->FindItemData( list );
		if( !itemData )
			return false;
		itemData->left = left;
	}

	itemData = FindItemData( list );
	if( !itemDataList.Remove( itemData, false ) )
		return false;
	if( !list->DeallocateItemData( itemData ) )
		return false;
	return true;
}
Exemple #2
0
//=========================================================================================
void MultiList::UnbindFromList( List& list )
{
	for( Item* item = ( Item* )list.leftMost; item; item = ( Item* )item->right )
	{
		ItemData* itemData = item->FindItemData( this );
		itemData->left = ( Item* )item->left;
		itemData->right = ( Item* )item->right;
		item->left = 0;
		item->right = 0;
		item->list = 0;
	}
	list.leftMost = 0;
	list.rightMost = 0;
	list.count = 0;
}