sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\cbase\ub_tque.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: sl@0: sl@0: // Class TTickCountQue sl@0: /** sl@0: @internalComponent sl@0: @released sl@0: sl@0: Constructs an empty list header sl@0: */ sl@0: TTickCountQue::TTickCountQue() sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: @released sl@0: sl@0: Adds the specified list element. sl@0: sl@0: The element is added into the list in order of its tick count. sl@0: sl@0: @param aRef The list element to be inserted. sl@0: */ sl@0: void TTickCountQue::Add(TTickCountQueLink& aRef) sl@0: { sl@0: TTickCountQueLink* currentLink = (TTickCountQueLink*)(iHead.iNext); sl@0: TTickCountQueLink* addLink = &aRef; sl@0: sl@0: while ( (currentLink != (TTickCountQueLink*)&iHead) && sl@0: (((TInt)(addLink->iTickCount - currentLink->iTickCount)) >= 0) sl@0: ) sl@0: { sl@0: currentLink = (TTickCountQueLink*)currentLink->iNext; sl@0: } sl@0: sl@0: addLink->Enque(currentLink->iPrev); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: @released sl@0: sl@0: Removes the first list element from the linked list if its tick count sl@0: is prior to the current tick count. sl@0: sl@0: @param aTickCount The current tick count. sl@0: sl@0: @return A pointer to the element removed from the linked list. This is NULL sl@0: if the first element has yet to expire or the queue is empty. sl@0: */ sl@0: TTickCountQueLink* TTickCountQue::RemoveFirst(TUint aTickCount) sl@0: { sl@0: TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext; sl@0: sl@0: if (((TInt)(firstLink->iTickCount - aTickCount)) <= 0) sl@0: { sl@0: return RemoveFirst(); sl@0: } sl@0: else sl@0: { sl@0: return NULL; sl@0: } sl@0: } sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: @released sl@0: sl@0: Removes the first list element from the linked list, if any. sl@0: sl@0: @return A pointer to the element removed from the linked list. This is NULL, sl@0: if the queue is empty. sl@0: */ sl@0: TTickCountQueLink* TTickCountQue::RemoveFirst() sl@0: { sl@0: TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext; sl@0: sl@0: if (firstLink != (TTickCountQueLink*)&iHead) sl@0: { sl@0: firstLink->Deque(); sl@0: return firstLink; sl@0: } sl@0: sl@0: return NULL; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: @released sl@0: sl@0: Gets a pointer to the first list element in the doubly linked list. sl@0: sl@0: @return A pointer to the first list element in the doubly linked list. If sl@0: the list is empty, this pointer is not necessarily NULL and must not sl@0: be assumed to point to a valid object. sl@0: */ sl@0: TTickCountQueLink* TTickCountQue::First() const sl@0: { sl@0: #if defined (_DEBUG) sl@0: __DbgTestEmpty(); sl@0: #endif sl@0: return((TTickCountQueLink*)iHead.iNext); sl@0: }