beginner – Implementing the C ++ linked list

I hope that's the way to do things right: I've already posted a code review request and got comments. Now I have a new, improved code on which I would like a code revision again. Old: C ++ linked list iterator implementation


Known issues:

  • The Sentinel node contains a value
  • I have not yet learned how to implement the rule of five.
  • I do not understand the purpose of const_iterator

Node.h

#pragma once

Namespace Util
{
model
    Node class
{
public:
model Iterator friends class;
model class list of friends;
private:
Node (T);
~ Node ();

void push_back (Node *);
void unlink ();

T value;
Node* following;
Node* prev;
};

model
    Node:: Node (T t): value (t), next (this), prev (this)
{
// ...
}

model
    Node:: ~ Node ()
{
unlink ();
}

model
    empty node:: push_back (Node * n)
{
n-> next = this;
n-> prev = prev;
prev-> next = n;
prev = n;
}

model
    empty node:: unlink ()
{
next-> prev = prev;
prev-> next = next;
next = this;
prev = this;
}
}

Iterator.h

#pragma once

#include "Node.h"

Namespace Util
{
model
    Iterator class
{
public:
model class list of friends;

T & operator * () const;
Iterator & operator ++ ();
Iterator and operator - ();
Iterator & operator ++ (int);
Iterator and Operator - (int);
operator bool == (const Iterator & rhs) const;
bool operator! = = (const Iterator & rhs) const;
private:
Iterator (node* not);
Node* node;
};
model
    iterator:: Iterator (Node* n): node (n)
{
// ...
}

model
    T & Iterator:: operator * () const
{
return node-> value;
}

model
    iteratorAnd iterator:: operator ++ ()
{
node = node-> next;
return * this;
}

model
    iteratorAnd iterator::operator--()
{
node = node-> prev;
return * this;
}

model
    iteratorAnd iterator:: operator ++ (int)
{
iterator c & # 39;);
operator ++ ();
render it;
}

model
    iteratorAnd iterator:: operator - (int)
{
iterator c & # 39;);
operator--();
render it;
}

model
    bool Iterator:: operator == (const Iterator & rhs) const
{
return node == rhs.node;
}

model
    bool Iterator:: operator! = (const Iterator & rhs) const
{
return node! = rhs.node;
}
}

list.h

#pragma once

#include "Iterator.h"

Namespace Util
{
model
    class list
{
public:
typedef Iterator iterator;
Typedef node Node;

Listing();
~ List ();
List (const List) = delete;
List (List &&) = delete;
List & operator = (const list &) = delete;
List & operator = (List &&) = delete;

// ability
bool empty () const;
int size () const;

// Modifiers
void push_back (const T &);
void push_front (const T &);
void pop_back ();
void pop_front ();
empty clear ();
Insert iterator (Iterator, Const T &);
Erase iterator (Iterator);

// Access to the elements
T & front () const;
T & back () const;
Iterator begin () const;
Iterator end () const;
private:
Node * head;
int list_size;
};

model
    listing:: List (): head (new node (0)), list_size (0)
{
// ...
}

model
    listing:: ~ List ()
{
while (! empty ())
{
pop_back ();
}
remove the head;
}

model
    Boolean list:: empty () const
{
return the head-> next == head;
}

model
    int list:: size () const
{
return list_size;
}

model
    Empty list:: push_back (const T & T)
{
head-> push_back (new node (t));
++ list_size;
}

model
    Empty list:: push_front (const T & T)
{
head-> next-> push_back (new node (t));
++ list_size;
}

model
    Empty list:: pop_back ()
{
delete head-> prev;
--list_size;
}

model
    Empty list:: pop_front ()
{
delete head-> next;
--list_size;
}

model
    Empty list::clear()
{
Iterator il = begin ();
while (! empty ())
{
it = delete (it);
}
}

model
    list of type names:: List of iterators:: insert (Iterator, constants)
{
it.node-> push_back (new node (t));
++ list_size;
--he;
return Iterator (it);
}

model
    list of type names:: List of iterators:: delete (iterator)
{
Node * n = it.node-> next;
delete it.node;
--list_size;
returns Iterator (n);
}

model
    T & List:: front () const
{
return head-> next-> value;
}

model
    T & List:: back () const
{
returns the head-> previous-> value;
}

model
    list of type names:: List of iterators:: begin () const
{
returns Iterator (head-> next);
}

model
    list of type names:: List of iterators:: end () const
{
return Iterator (head);
}
}

Possible bug:
I've manually compared most of the methods of std :: list and my list, and it seems consistent. With the exception of:

for (auto it = list.begin (); it! = list.end (); ++ it)
{
it = list.erase (it);
}

the std :: list removes all items, then errors, because you can not increment past I have a tendency (). But my list removes all the other elements in a strange way, and I think we move several times.