author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// e32\euser\cbase\ub_tque.cpp |
sl@0 | 15 |
// |
sl@0 | 16 |
// |
sl@0 | 17 |
|
sl@0 | 18 |
#include <e32std.h> |
sl@0 | 19 |
#include <e32std_private.h> |
sl@0 | 20 |
|
sl@0 | 21 |
|
sl@0 | 22 |
|
sl@0 | 23 |
|
sl@0 | 24 |
// Class TTickCountQue |
sl@0 | 25 |
/** |
sl@0 | 26 |
@internalComponent |
sl@0 | 27 |
@released |
sl@0 | 28 |
|
sl@0 | 29 |
Constructs an empty list header |
sl@0 | 30 |
*/ |
sl@0 | 31 |
TTickCountQue::TTickCountQue() |
sl@0 | 32 |
{} |
sl@0 | 33 |
|
sl@0 | 34 |
|
sl@0 | 35 |
|
sl@0 | 36 |
|
sl@0 | 37 |
/** |
sl@0 | 38 |
@internalComponent |
sl@0 | 39 |
@released |
sl@0 | 40 |
|
sl@0 | 41 |
Adds the specified list element. |
sl@0 | 42 |
|
sl@0 | 43 |
The element is added into the list in order of its tick count. |
sl@0 | 44 |
|
sl@0 | 45 |
@param aRef The list element to be inserted. |
sl@0 | 46 |
*/ |
sl@0 | 47 |
void TTickCountQue::Add(TTickCountQueLink& aRef) |
sl@0 | 48 |
{ |
sl@0 | 49 |
TTickCountQueLink* currentLink = (TTickCountQueLink*)(iHead.iNext); |
sl@0 | 50 |
TTickCountQueLink* addLink = &aRef; |
sl@0 | 51 |
|
sl@0 | 52 |
while ( (currentLink != (TTickCountQueLink*)&iHead) && |
sl@0 | 53 |
(((TInt)(addLink->iTickCount - currentLink->iTickCount)) >= 0) |
sl@0 | 54 |
) |
sl@0 | 55 |
{ |
sl@0 | 56 |
currentLink = (TTickCountQueLink*)currentLink->iNext; |
sl@0 | 57 |
} |
sl@0 | 58 |
|
sl@0 | 59 |
addLink->Enque(currentLink->iPrev); |
sl@0 | 60 |
} |
sl@0 | 61 |
|
sl@0 | 62 |
|
sl@0 | 63 |
|
sl@0 | 64 |
|
sl@0 | 65 |
/** |
sl@0 | 66 |
@internalComponent |
sl@0 | 67 |
@released |
sl@0 | 68 |
|
sl@0 | 69 |
Removes the first list element from the linked list if its tick count |
sl@0 | 70 |
is prior to the current tick count. |
sl@0 | 71 |
|
sl@0 | 72 |
@param aTickCount The current tick count. |
sl@0 | 73 |
|
sl@0 | 74 |
@return A pointer to the element removed from the linked list. This is NULL |
sl@0 | 75 |
if the first element has yet to expire or the queue is empty. |
sl@0 | 76 |
*/ |
sl@0 | 77 |
TTickCountQueLink* TTickCountQue::RemoveFirst(TUint aTickCount) |
sl@0 | 78 |
{ |
sl@0 | 79 |
TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext; |
sl@0 | 80 |
|
sl@0 | 81 |
if (((TInt)(firstLink->iTickCount - aTickCount)) <= 0) |
sl@0 | 82 |
{ |
sl@0 | 83 |
return RemoveFirst(); |
sl@0 | 84 |
} |
sl@0 | 85 |
else |
sl@0 | 86 |
{ |
sl@0 | 87 |
return NULL; |
sl@0 | 88 |
} |
sl@0 | 89 |
} |
sl@0 | 90 |
|
sl@0 | 91 |
|
sl@0 | 92 |
/** |
sl@0 | 93 |
@internalComponent |
sl@0 | 94 |
@released |
sl@0 | 95 |
|
sl@0 | 96 |
Removes the first list element from the linked list, if any. |
sl@0 | 97 |
|
sl@0 | 98 |
@return A pointer to the element removed from the linked list. This is NULL, |
sl@0 | 99 |
if the queue is empty. |
sl@0 | 100 |
*/ |
sl@0 | 101 |
TTickCountQueLink* TTickCountQue::RemoveFirst() |
sl@0 | 102 |
{ |
sl@0 | 103 |
TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext; |
sl@0 | 104 |
|
sl@0 | 105 |
if (firstLink != (TTickCountQueLink*)&iHead) |
sl@0 | 106 |
{ |
sl@0 | 107 |
firstLink->Deque(); |
sl@0 | 108 |
return firstLink; |
sl@0 | 109 |
} |
sl@0 | 110 |
|
sl@0 | 111 |
return NULL; |
sl@0 | 112 |
} |
sl@0 | 113 |
|
sl@0 | 114 |
|
sl@0 | 115 |
|
sl@0 | 116 |
|
sl@0 | 117 |
/** |
sl@0 | 118 |
@internalComponent |
sl@0 | 119 |
@released |
sl@0 | 120 |
|
sl@0 | 121 |
Gets a pointer to the first list element in the doubly linked list. |
sl@0 | 122 |
|
sl@0 | 123 |
@return A pointer to the first list element in the doubly linked list. If |
sl@0 | 124 |
the list is empty, this pointer is not necessarily NULL and must not |
sl@0 | 125 |
be assumed to point to a valid object. |
sl@0 | 126 |
*/ |
sl@0 | 127 |
TTickCountQueLink* TTickCountQue::First() const |
sl@0 | 128 |
{ |
sl@0 | 129 |
#if defined (_DEBUG) |
sl@0 | 130 |
__DbgTestEmpty(); |
sl@0 | 131 |
#endif |
sl@0 | 132 |
return((TTickCountQueLink*)iHead.iNext); |
sl@0 | 133 |
} |