Loading...
Searching...
No Matches
LinkedList.cpp
Go to the documentation of this file.
#ifndef __cxxtest__LinkedList_cpp__
#define __cxxtest__LinkedList_cpp__
#include <cxxtest/LinkedList.h>
namespace CxxTest
{
List GlobalFixture::_list = { 0, 0 };
List RealSuiteDescription::_suites = { 0, 0 };
void List::initialize()
{
_head = _tail = 0;
}
Link *List::head()
{
Link *l = _head;
while ( l && !l->active() )
l = l->next();
return l;
}
const Link *List::head() const
{
Link *l = _head;
while ( l && !l->active() )
l = l->next();
return l;
}
Link *List::tail()
{
Link *l = _tail;
while ( l && !l->active() )
l = l->prev();
return l;
}
const Link *List::tail() const
{
Link *l = _tail;
while ( l && !l->active() )
l = l->prev();
return l;
}
bool List::empty() const
{
return (_head == 0);
}
unsigned List::size() const
{
unsigned count = 0;
for ( const Link *l = head(); l != 0; l = l->next() )
++ count;
return count;
}
Link *List::nth( unsigned n )
{
Link *l = head();
while ( n -- )
l = l->next();
return l;
}
void List::activateAll()
{
for ( Link *l = _head; l != 0; l = l->justNext() )
l->setActive( true );
}
void List::leaveOnly( const Link &link )
{
for ( Link *l = head(); l != 0; l = l->next() )
if ( l != &link )
l->setActive( false );
}
Link::Link() :
_next( 0 ),
_prev( 0 ),
_active( true )
{
}
Link::~Link()
{
}
bool Link::active() const
{
return _active;
}
void Link::setActive( bool value )
{
_active = value;
}
Link * Link::justNext()
{
return _next;
}
Link * Link::justPrev()
{
return _prev;
}
Link * Link::next()
{
Link *l = _next;
while ( l && !l->_active )
l = l->_next;
return l;
}
Link * Link::prev()
{
Link *l = _prev;
while ( l && !l->_active )
l = l->_prev;
return l;
}
const Link * Link::next() const
{
Link *l = _next;
while ( l && !l->_active )
l = l->_next;
return l;
}
const Link * Link::prev() const
{
Link *l = _prev;
while ( l && !l->_active )
l = l->_prev;
return l;
}
void Link::attach( List &l )
{
if ( l._tail )
l._tail->_next = this;
_prev = l._tail;
_next = 0;
if ( l._head == 0 )
l._head = this;
l._tail = this;
}
void Link::detach( List &l )
{
if ( _prev )
_prev->_next = _next;
else
l._head = _next;
if ( _next )
_next->_prev = _prev;
else
l._tail = _prev;
}
};
#endif // __cxxtest__LinkedList_cpp__
LinkedList.h
l
int l
Definition cfEzgcd.cc:100
CxxTest::GlobalFixture::_list
static List _list
Definition GlobalFixture.h:25
CxxTest::Link
Definition LinkedList.h:32
CxxTest::Link::active
bool active() const
Definition LinkedList.cpp:93
CxxTest::Link::next
Link * next()
Definition LinkedList.cpp:113
CxxTest::Link::_active
bool _active
Definition LinkedList.h:57
CxxTest::Link::_prev
Link * _prev
Definition LinkedList.h:56
CxxTest::Link::~Link
virtual ~Link()
Definition LinkedList.cpp:89
CxxTest::Link::setActive
void setActive(bool value=true)
Definition LinkedList.cpp:98
CxxTest::Link::justNext
Link * justNext()
Definition LinkedList.cpp:103
CxxTest::Link::justPrev
Link * justPrev()
Definition LinkedList.cpp:108
CxxTest::Link::_next
Link * _next
Definition LinkedList.h:55
CxxTest::Link::detach
void detach(List &l)
Definition LinkedList.cpp:158
CxxTest::Link::attach
void attach(List &l)
Definition LinkedList.cpp:145
CxxTest::Link::Link
Link()
Definition LinkedList.cpp:82
CxxTest::Link::prev
Link * prev()
Definition LinkedList.cpp:121
CxxTest::RealSuiteDescription::_suites
STATIC_INST_VAR List _suites
Definition RealDescriptions.h:78
List
Definition ftmpl_list.h:52
CxxTest
Definition Descriptions.cpp:7
count
int status int void size_t count
Definition si_signals.h:69
CxxTest::List
Definition LinkedList.h:12
CxxTest::List::head
Link * head()
Definition LinkedList.cpp:16
CxxTest::List::size
unsigned size() const
Definition LinkedList.cpp:53
CxxTest::List::leaveOnly
void leaveOnly(const Link &link)
Definition LinkedList.cpp:75
CxxTest::List::empty
bool empty() const
Definition LinkedList.cpp:48
CxxTest::List::initialize
void initialize()
Definition LinkedList.cpp:11
CxxTest::List::activateAll
void activateAll()
Definition LinkedList.cpp:69
CxxTest::List::_head
Link * _head
Definition LinkedList.h:13
CxxTest::List::nth
Link * nth(unsigned n)
Definition LinkedList.cpp:61
CxxTest::List::_tail
Link * _tail
Definition LinkedList.h:14
CxxTest::List::tail
Link * tail()
Definition LinkedList.cpp:32