1
1
forked from 0ad/0ad
0ad/source/dcdt/se/sr_list_node.cpp
janwas 5bf9bca9ef fix/disable warnings.
there are too many W4 and "potentially uninitialized", so those are
disabled by 0ad_warning_disable.h.

the silly "int x = strlen" and very dangerous "int x = (void*)p" (and
vice versa) problems are fixed.

This was SVN commit r5526.
2007-12-23 12:18:57 +00:00

87 lines
1.9 KiB
C++

#include "precompiled.h"
#include "0ad_warning_disable.h"
# include "sr_list_node.h"
//=============================== SrListNode ================================
SrListNode *SrListNode::remove_next ()
{
SrListNode *n = _next;
_next = _next->_next;
_next->_next->_prior = this;
return n;
}
SrListNode *SrListNode::remove_prior ()
{
SrListNode *n = _prior;
_prior = _prior->_prior;
_prior->_prior->_next = this;
return n;
}
SrListNode *SrListNode::remove ()
{
_next->_prior = _prior;
_prior->_next = _next;
return this;
}
SrListNode *SrListNode::replace ( SrListNode *n )
{
_next->_prior = n;
_prior->_next = n;
n->_next = _next;
n->_prior = _prior;
return this;
}
SrListNode *SrListNode::insert_next ( SrListNode *n )
{
n->_next = _next;
n->_next->_prior = n;
n->_prior = this;
_next = n;
return n;
}
SrListNode *SrListNode::insert_prior ( SrListNode *n )
{
n->_prior = _prior;
_prior->_next = n;
n->_next = this;
_prior = n;
return n;
}
void SrListNode::splice ( SrListNode *n )
{
_next->_prior = n;
n->_next->_prior = this;
SrListNode *nxt=_next;
_next = n->_next;
n->_next = nxt;
/* This has the same result as:
SrListNode *tmp;
SR_SWAP ( _next->_prior, n->_next->_prior );
SR_SWAP ( _next, n->_next );
*/
}
void SrListNode::swap ( SrListNode *n )
{
SrListNode *nn=n->_next, *p=_prior;
if ( _next!=n ) { _prior=n->_prior; n->_next=_next; } else { _prior=n; n->_next=this; }
if ( nn!=this ) { _next=nn; n->_prior=p; } else { _next=n; n->_prior=this; }
_prior->_next=this;
_next->_prior=this;
n->_prior->_next=n;
n->_next->_prior=n;
}
//============================== end of file ===============================