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

sync with my version.

[[Imported from SVN: r5743]]
parent d4290852
No related branches found
No related tags found
No related merge requests found
...@@ -210,10 +210,11 @@ namespace Dune ...@@ -210,10 +210,11 @@ namespace Dune
*/ */
MemberType item_; MemberType item_;
Element(const MemberType& item); Element(const MemberType& item, Element* next_=0);
Element(); Element();
~Element();
}; };
/** /**
...@@ -563,8 +564,8 @@ namespace Dune ...@@ -563,8 +564,8 @@ namespace Dune
{ {
template<typename T, class A> template<typename T, class A>
SLList<T,A>::Element::Element(const T& item) SLList<T,A>::Element::Element(const T& item, Element* next)
: next_(0), item_(item) : next_(next), item_(item)
{} {}
template<typename T, class A> template<typename T, class A>
...@@ -572,6 +573,12 @@ namespace Dune ...@@ -572,6 +573,12 @@ namespace Dune
: next_(0), item_() : next_(0), item_()
{} {}
template<typename T, class A>
SLList<T,A>::Element::~Element()
{
next_=0;
}
template<typename T, class A> template<typename T, class A>
SLList<T,A>::SLList() SLList<T,A>::SLList()
: beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
...@@ -678,10 +685,9 @@ namespace Dune ...@@ -678,10 +685,9 @@ namespace Dune
current->next_ = allocator_.allocate(1, 0); current->next_ = allocator_.allocate(1, 0);
// Use copy constructor to initialize memory // Use copy constructor to initialize memory
::new(static_cast<void*>(&(current->next_->item_)))T(item); allocator_.construct(current->next_, Element(item,tmp));
// Set next element //::new(static_cast<void*>(&(current->next_->item_))) T(item);
current->next_->next_=tmp;
if(!current->next_->next_) { if(!current->next_->next_) {
// Update tail // Update tail
...@@ -731,8 +737,7 @@ namespace Dune ...@@ -731,8 +737,7 @@ namespace Dune
} }
current->next_ = next->next_; current->next_ = next->next_;
next->item_.~T(); allocator_.destroy(next);
next->next_ = 0;
allocator_.deallocate(next, 1); allocator_.deallocate(next, 1);
--size_; --size_;
assert(!watchForTail || &beforeHead_ != tail_ || size_==0); assert(!watchForTail || &beforeHead_ != tail_ || size_==0);
......
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