Skip to content
Snippets Groups Projects
Commit c540a8e6 authored by Markus Blatt's avatar Markus Blatt
Browse files

Some additional functions and tests.

Removed compiler warning.

[[Imported from SVN: r1118]]
parent 7d22ec87
No related branches found
No related tags found
No related merge requests found
......@@ -79,10 +79,7 @@ namespace Dune
*/
inline void pop_front();
/**
* @brief Remove the first item in the list.
* @return The last item in the list or 0 if the list is empty.
/** @brief Remove all elements from the list. */
/** @brief Remove all elements from the list. */
inline void clear();
/**
......@@ -118,6 +115,13 @@ namespace Dune
*/
inline const_iterator end() const;
/**
* @brief Check whether the list is empty.
*
* @return True if the list is empty;
*/
inline bool empty() const;
private:
struct Element
{
......@@ -326,6 +330,12 @@ namespace Dune
tail_ = head_;
}
template<typename T, class A>
inline bool SLList<T,A>::empty() const
{
return head_==0;
}
template<typename T, class A>
inline SLListIterator<T,A> SLList<T,A>::begin()
{
......
......@@ -5,8 +5,25 @@
#include <dune/common/poolallocator.hh>
#include <iostream>
template<class A>
void randomizeListBack(Dune::SLList<double,A>& alist){
class DoubleWrapper
{
public:
DoubleWrapper(double b)
: d(b)
{}
operator double()
{
return d;
}
private:
double d;
};
template<typename T,class A>
void randomizeListBack(Dune::SLList<T,A>& alist){
using namespace Dune;
srand((unsigned)time(0));
......@@ -14,11 +31,11 @@ void randomizeListBack(Dune::SLList<double,A>& alist){
int lowest=0, highest=1000, range=(highest-lowest)+1;
for(int i=0; i < 10; i++)
alist.push_back((range*(rand()/(RAND_MAX+1.0))));
alist.push_back(T(range*(rand()/(RAND_MAX+1.0))));
}
template<class A>
void randomizeListFront(Dune::SLList<double,A>& alist){
template<typename T,class A>
void randomizeListFront(Dune::SLList<T,A>& alist){
using namespace Dune;
srand((unsigned)time(0));
......@@ -73,9 +90,11 @@ int main()
Dune::SLList<double> list;
Dune::SLList<double,Dune::PoolAllocator<double, 8*1024-20> > list1;
Dune::SLList<DoubleWrapper, Dune::PoolAllocator<DoubleWrapper, 8*1024-20> > list2;
randomizeListBack(list1);
randomizeListFront(list);
randomizeListFront(list2);
ret+=testIterator(list);
ret+=testIterator(list1);
......@@ -83,6 +102,7 @@ int main()
list.clear();
list1.clear();
list2.clear();
randomizeListBack(list);
randomizeListFront(list1);
exit(ret);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment