diff options
author | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
---|---|---|
committer | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
commit | a9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch) | |
tree | 2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/BaseClasses/wxlist.cpp | |
parent | aafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (diff) |
astyle formatting cleanup to make the sourcecode more accessible
switch used: astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren
http://astyle.sourceforge.net/
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1783 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/BaseClasses/wxlist.cpp')
-rw-r--r-- | src/filters/BaseClasses/wxlist.cpp | 168 |
1 files changed, 102 insertions, 66 deletions
diff --git a/src/filters/BaseClasses/wxlist.cpp b/src/filters/BaseClasses/wxlist.cpp index e8fda9d6c..d44282426 100644 --- a/src/filters/BaseClasses/wxlist.cpp +++ b/src/filters/BaseClasses/wxlist.cpp @@ -155,7 +155,8 @@ void CBaseList::RemoveAll() which point the cache will be deleted anway */
CNode *pn = m_pFirst;
- while (pn) {
+ while(pn)
+ {
CNode *op = pn;
pn = pn->Next();
delete op;
@@ -218,7 +219,8 @@ __out void *CBaseList::GetNextI(__inout POSITION& rp) const {
/* have we reached the end of the list */
- if (rp == NULL) {
+ if(rp == NULL)
+ {
return NULL;
}
@@ -250,7 +252,8 @@ __out void *CBaseList::GetNextI(__inout POSITION& rp) const */
__out_opt void *CBaseList::GetI(__in_opt POSITION p) const
{
- if (p == NULL) {
+ if(p == NULL)
+ {
return NULL;
}
@@ -272,11 +275,13 @@ __out void *CBaseList::GetValidI(__in POSITION p) const /* Return the first position in the list which holds the given pointer.
Return NULL if it's not found.
*/
-__out_opt POSITION CBaseList::FindI( __in void * pObj) const
+__out_opt POSITION CBaseList::FindI(__in void * pObj) const
{
POSITION pn;
- INTERNALTRAVERSELIST(*this, pn){
- if (GetI(pn)==pObj) {
+ INTERNALTRAVERSELIST(*this, pn)
+ {
+ if(GetI(pn) == pObj)
+ {
return pn;
}
}
@@ -334,7 +339,7 @@ __out_opt void *CBaseList::RemoveI(__in_opt POSITION pos) /* Lock the critical section before continuing */
// ASSERT (pos!=NULL); // Removing NULL is to be harmless!
- if (pos==NULL) return NULL;
+ if(pos == NULL) return NULL;
CNode *pCurrent = (CNode *) pos;
@@ -343,18 +348,24 @@ __out_opt void *CBaseList::RemoveI(__in_opt POSITION pos) /* Update the previous node */
CNode *pNode = pCurrent->Prev();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
m_pFirst = pCurrent->Next();
- } else {
+ }
+ else
+ {
pNode->SetNext(pCurrent->Next());
}
/* Update the following node */
pNode = pCurrent->Next();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
m_pLast = pCurrent->Prev();
- } else {
+ }
+ else
+ {
pNode->SetPrev(pCurrent->Prev());
}
@@ -401,13 +412,15 @@ __out_opt POSITION CBaseList::AddTailI(__in void *pObject) that otherwise we will have to create a new one */
pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -419,9 +432,12 @@ __out_opt POSITION CBaseList::AddTailI(__in void *pObject) pNode->SetNext(NULL);
pNode->SetPrev(m_pLast);
- if (m_pLast == NULL) {
+ if(m_pLast == NULL)
+ {
m_pFirst = pNode;
- } else {
+ }
+ else
+ {
m_pLast->SetNext(pNode);
}
@@ -450,13 +466,15 @@ __out_opt POSITION CBaseList::AddHeadI(__in void *pObject) that otherwise we will have to create a new one */
pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -470,9 +488,12 @@ __out_opt POSITION CBaseList::AddHeadI(__in void *pObject) pNode->SetPrev(NULL);
pNode->SetNext(m_pFirst);
- if (m_pFirst == NULL) {
+ if(m_pFirst == NULL)
+ {
m_pLast = pNode;
- } else {
+ }
+ else
+ {
m_pFirst->SetPrev(pNode);
}
m_pFirst = pNode;
@@ -497,10 +518,12 @@ BOOL CBaseList::AddTail(__in CBaseList *pList) */
POSITION pos = pList->GetHeadPositionI();
- while (pos) {
- if (NULL == AddTailI(pList->GetNextI(pos))) {
- return FALSE;
- }
+ while(pos)
+ {
+ if(NULL == AddTailI(pList->GetNextI(pos)))
+ {
+ return FALSE;
+ }
}
return TRUE;
} // AddTail(list)
@@ -523,8 +546,10 @@ BOOL CBaseList::AddHead(__in CBaseList *pList) POSITION pos;
- INTERNALREVERSETRAVERSELIST(*pList, pos) {
- if (NULL== AddHeadI(pList->GetValidI(pos))){
+ INTERNALREVERSETRAVERSELIST(*pList, pos)
+ {
+ if(NULL == AddHeadI(pList->GetValidI(pos)))
+ {
return FALSE;
}
}
@@ -540,7 +565,7 @@ BOOL CBaseList::AddHead(__in CBaseList *pList) */
__out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj)
{
- if (pos==NULL)
+ if(pos == NULL)
return AddHeadI(pObj);
/* As someone else might be furkling with the list -
@@ -548,19 +573,21 @@ __out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj */
CNode *pAfter = (CNode *) pos;
ASSERT(pAfter != NULL);
- if (pAfter==m_pLast)
+ if(pAfter == m_pLast)
return AddTailI(pObj);
/* set pnode to point to a new node, preferably from the cache */
CNode *pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -593,10 +620,11 @@ __out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj BOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList)
{
POSITION pos;
- INTERNALTRAVERSELIST(*pList, pos) {
+ INTERNALTRAVERSELIST(*pList, pos)
+ {
/* p follows along the elements being added */
p = AddAfterI(p, pList->GetValidI(pos));
- if (p==NULL) return FALSE;
+ if(p == NULL) return FALSE;
}
return TRUE;
} // AddAfter(list)
@@ -610,24 +638,26 @@ BOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList) */
__out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void * pObj)
{
- if (pos==NULL)
+ if(pos == NULL)
return AddTailI(pObj);
/* set pnode to point to a new node, preferably from the cache */
CNode *pBefore = (CNode *) pos;
ASSERT(pBefore != NULL);
- if (pBefore==m_pFirst)
+ if(pBefore == m_pFirst)
return AddHeadI(pObj);
CNode * pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -661,10 +691,11 @@ __out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void * pObj BOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList)
{
POSITION pos;
- INTERNALREVERSETRAVERSELIST(*pList, pos) {
+ INTERNALREVERSETRAVERSELIST(*pList, pos)
+ {
/* p follows along the elements being added */
p = AddBeforeI(p, pList->GetValidI(pos));
- if (p==NULL) return FALSE;
+ if(p == NULL) return FALSE;
}
return TRUE;
} // AddBefore(list)
@@ -688,7 +719,7 @@ BOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList) MoveElementsFromHeadThroughPositionToOtherTail
*/
BOOL CBaseList::MoveToTail
- (__in_opt POSITION pos, __in CBaseList *pList)
+(__in_opt POSITION pos, __in CBaseList *pList)
{
/* Algorithm:
Note that the elements (including their order) in the concatenation
@@ -701,38 +732,39 @@ BOOL CBaseList::MoveToTail 6. Set/Reset any events
*/
- if (pos==NULL) return TRUE; // no-op. Eliminates special cases later.
+ if(pos == NULL) return TRUE; // no-op. Eliminates special cases later.
/* Make cMove the number of nodes to move */
CNode * p = (CNode *)pos;
int cMove = 0; // number of nodes to move
- while(p!=NULL) {
- p = p->Prev();
- ++cMove;
+ while(p != NULL)
+ {
+ p = p->Prev();
+ ++cMove;
}
/* Join the two chains together */
- if (pList->m_pLast!=NULL)
+ if(pList->m_pLast != NULL)
pList->m_pLast->SetNext(m_pFirst);
- if (m_pFirst!=NULL)
+ if(m_pFirst != NULL)
m_pFirst->SetPrev(pList->m_pLast);
/* set first and last pointers */
p = (CNode *)pos;
- if (pList->m_pFirst==NULL)
+ if(pList->m_pFirst == NULL)
pList->m_pFirst = m_pFirst;
m_pFirst = p->Next();
- if (m_pFirst==NULL)
+ if(m_pFirst == NULL)
m_pLast = NULL;
pList->m_pLast = p;
/* Break the chain after p to create the new pieces */
- if (m_pFirst!=NULL)
+ if(m_pFirst != NULL)
m_pFirst->SetPrev(NULL);
p->SetNext(NULL);
@@ -762,26 +794,27 @@ BOOL CBaseList::MoveToTail concatenates foo onto the start of bar and empties foo.
*/
BOOL CBaseList::MoveToHead
- (__in_opt POSITION pos, __in CBaseList *pList)
+(__in_opt POSITION pos, __in CBaseList *pList)
{
/* See the comments on the algorithm in MoveToTail */
- if (pos==NULL) return TRUE; // no-op. Eliminates special cases later.
+ if(pos == NULL) return TRUE; // no-op. Eliminates special cases later.
/* Make cMove the number of nodes to move */
CNode * p = (CNode *)pos;
int cMove = 0; // number of nodes to move
- while(p!=NULL) {
- p = p->Next();
- ++cMove;
+ while(p != NULL)
+ {
+ p = p->Next();
+ ++cMove;
}
/* Join the two chains together */
- if (pList->m_pFirst!=NULL)
+ if(pList->m_pFirst != NULL)
pList->m_pFirst->SetPrev(m_pLast);
- if (m_pLast!=NULL)
+ if(m_pLast != NULL)
m_pLast->SetNext(pList->m_pFirst);
@@ -789,17 +822,17 @@ BOOL CBaseList::MoveToHead p = (CNode *)pos;
- if (pList->m_pLast==NULL)
+ if(pList->m_pLast == NULL)
pList->m_pLast = m_pLast;
m_pLast = p->Prev();
- if (m_pLast==NULL)
+ if(m_pLast == NULL)
m_pFirst = NULL;
pList->m_pFirst = p;
/* Break the chain after p to create the new pieces */
- if (m_pLast!=NULL)
+ if(m_pLast != NULL)
m_pLast->SetNext(NULL);
p->SetPrev(NULL);
@@ -840,7 +873,8 @@ void CBaseList::Reverse() // Yes we COULD use a traverse, but it would look funny!
p = m_pFirst;
- while (p!=NULL) {
+ while(p != NULL)
+ {
CNode * q;
q = p->Next();
p->SetNext(p->Prev());
@@ -855,15 +889,16 @@ void CBaseList::Reverse() #if 0 // old version
- if (m_pFirst==NULL) return; // empty list
- if (m_pFirst->Next()==NULL) return; // single node list
+ if(m_pFirst == NULL) return; // empty list
+ if(m_pFirst->Next() == NULL) return; // single node list
/* run along forward chain */
- for ( p = m_pFirst
- ; p!=NULL
+ for(p = m_pFirst
+ ; p != NULL
; p = p->Next()
- ){
+ )
+ {
p->SetPrev(p->Next());
}
@@ -873,10 +908,11 @@ void CBaseList::Reverse() /* run along new reverse chain i.e. old forward chain again */
- for ( p = m_pFirst // start at the old first element
- ; p->Prev()!=NULL // while there's a node still to be set
+ for(p = m_pFirst // start at the old first element
+ ; p->Prev() != NULL // while there's a node still to be set
; p = p->Prev() // work in the same direction as before
- ){
+ )
+ {
p->Prev()->SetNext(p);
}
|