1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Initial Developer of this code is David Baum.
* Portions created by David Baum are Copyright (C) 1998 David Baum.
* All Rights Reserved.
*/
#include "PListS.h"
void P_ListS::InsertHead(P_LinkS* link)
{
link->fNext = fHead;
fHead = link;
if (!fTail)
fTail = link;
}
void P_ListS::InsertTail(P_LinkS* link)
{
link->fNext = nil;
if (fTail)
fTail->fNext = link;
else
fHead = link;
fTail = link;
}
P_LinkS *P_ListS::_RemoveHead()
{
P_LinkS *link = fHead;
if (link)
{
fHead = link->fNext;
link->fNext = nil;
if (fHead==nil)
fTail = nil;
}
return link;
}
P_LinkS* P_ListSS::_RemoveHead()
{
P_LinkS *link = fHead;
if (link)
{
fHead = link->fNext;
link->fNext = nil;
}
return link;
}
void P_ListSS::InsertHead(P_LinkS* link)
{
link->fNext = fHead;
fHead = link;
}
bool P_ListSS::Remove(P_LinkS *link)
{
P_LinkS* prev = nil;
P_LinkS* l;
for(l=fHead; l; l=l->fNext)
{
if (l==link)
{
// unlink and return
if (prev)
prev->fNext = l->fNext;
else
fHead = l->fNext;
l->fNext = nil;
return true;
}
prev = l;
}
return false;
}
bool P_ListS::Remove(P_LinkS *link)
{
P_LinkS* prev = nil;
P_LinkS* l;
for(l=fHead; l; l=l->fNext)
{
if (l==link)
{
// unlink and return
if (prev)
prev->fNext = l->fNext;
else
fHead = l->fNext;
if (fTail==link)
fTail = prev;
l->fNext = nil;
return true;
}
prev = l;
}
return false;
}
|