44 void add_to_empty_list(
Node * node)
46 assert(head ==
nullptr);
47 assert(tail ==
nullptr);
53 : head(nullptr), tail(nullptr)
76 std::swap(head, l.head);
77 std::swap(tail, l.tail);
82 return head ==
nullptr;
92 return head == tail and head !=
nullptr;
98 add_to_empty_list(node);
109 add_to_empty_list(node);
124 return (
const Node *&) head;
134 return (
const Node *&) tail;
142 Node * ret_val = head;
159 this->head = l->head;
160 this->tail = l->tail;
165 this->tail = l->tail;
168 l->head = l->tail =
nullptr;
179 template <
typename T>
190 r->
append(this->remove_first());
194 template <
typename T>
203 void copy_list(
const SLList &);
232 SLList(
const std::initializer_list<T> &);
252 BaseList::insert(node);
259 Node * node =
new Node(std::forward<T>(item));
260 BaseList::insert(node);
268 BaseList::append(node);
275 Node * node =
new Node(std::forward<T>(item));
276 BaseList::append(node);
284 throw std::underflow_error(
"List is empty");
286 return BaseList::get_first()->get_item();
292 throw std::underflow_error(
"List is empty");
294 return BaseList::get_first()->get_item();
300 throw std::underflow_error(
"List is empty");
302 return BaseList::get_last()->get_item();
308 throw std::underflow_error(
"There is not element in list");
310 return BaseList::get_last()->get_item();
316 throw std::underflow_error(
"There is not element in list");
318 Node * p = BaseList::remove_first();
319 T ret_val = std::move(p->
get_item());
328 std::swap(num_items, l.num_items);
333 num_items += l.num_items;
363 void locate_position();
374 : list_ptr(nullptr), curr(nullptr), pred(nullptr), pos(-1)
380 : list_ptr(&const_cast<
SLList<T> &>(l)),
387 : list_ptr(&const_cast<
SLList<T> &>(l)), curr(c), pred(nullptr), pos(0)
393 : list_ptr(it.list_ptr), curr(it.curr), pred(it.pred), pos(it.pos)
409 list_ptr = it.list_ptr;
425 std::swap(list_ptr, it.list_ptr);
426 std::swap(curr, it.curr);
427 std::swap(pred, it.pred);
428 std::swap(pos, it.pos);
438 return curr !=
nullptr;
443 if (not has_current())
444 throw std::overflow_error(
"There is not current element");
451 if (not has_current())
452 throw std::overflow_error(
"There is not current element");
459 if (not has_current())
469 curr = ((
BaseList *) list_ptr)->get_first();
475 if (not has_current())
476 throw std::logic_error(
"There is not current element");
480 T ret_val = list_ptr->remove_first();
481 curr = ((
BaseList *) list_ptr)->get_first();
488 ((
BaseList *) list_ptr)->get_last() = pred;
491 T ret_val = std::move(p->
get_item());
493 --list_ptr->num_items;
520 const T & select(
nat_t)
const;
527 const T & operator [] (
nat_t i)
const 533 template <
typename T>
537 for (
const T & item : l)
541 template <
typename T>
553 template <
typename T>
560 template <
typename T>
563 for (T & item : *
this)
568 throw std::out_of_range(
"Index out of range");
571 template <
typename T>
574 for (
const T & item : *
this)
579 throw std::out_of_range(
"Index out of range");
582 template <
typename T>
587 pos = list_ptr->
size();
588 pred = ((
BaseList *)list_ptr)->get_last();
602 template <
typename T>
611 void copy_list(
const DLList &);
623 :
Base(), num_items(0)
640 DLList(
const std::initializer_list<T> &);
659 std::swap(num_items, l.num_items);
666 Base::insert_next(node);
673 Node * node =
new Node(std::forward<T>(item));
674 Base::insert_next(node);
682 Base::insert_prev(node);
689 Node * node =
new Node(std::forward<T>(item));
690 Base::insert_prev(node);
697 if (Base::is_empty())
698 throw std::underflow_error(
"List is empty");
705 if (Base::is_empty())
706 throw std::underflow_error(
"List is empty");
713 if (Base::is_empty())
714 throw std::underflow_error(
"List is empty");
721 if (Base::is_empty())
722 throw std::underflow_error(
"List is empty");
729 if (Base::is_empty())
730 throw std::underflow_error(
"List is empty");
733 T ret_val = std::move(node->
get_item());
741 if (Base::is_empty())
742 throw std::underflow_error(
"List is empty");
745 T ret_val = std::move(node->
get_item());
751 void remove(T & item)
787 void locate_position();
791 : Base(), list_ptr(nullptr), pos(-1)
797 : Base(&const_cast<
DLList &>(l)), list_ptr(&const_cast<
DLList &>(l)),
804 : Base(&const_cast<
DLList &>(l), c), list_ptr(&const_cast<
DLList &>(l)),
811 : Base(it), list_ptr(it.list_ptr), pos(it.pos)
828 list_ptr = it.list_ptr;
842 std::swap(list_ptr, it.list_ptr);
843 std::swap(pos, it.pos);
853 return static_cast<Node *
>(Base::get_current())->get_item();
858 return static_cast<Node *
>(Base::get_current())->get_item();
863 Node * p =
static_cast<Node *
>(Base::del());
864 T ret_val = std::move(p->
get_item());
866 --list_ptr->num_items;
900 return Iterator(*
this, const_cast<DLList *>(
this));
918 template <
typename T>
922 for (
const T & item : l)
926 template <
typename T>
931 while ((
DL *)node != &l)
938 template <
typename T>
945 template <
typename T>
948 for (T & item : *
this)
953 throw std::out_of_range(
"Index out of range");
956 template <
typename T>
959 for (
const T & item : *
this)
964 throw std::out_of_range(
"Index out of range");
967 template <
typename T>
972 while (ptr != Base::get_location())
DL * remove_prev()
Definition: nodesdef.H:222
NodeSLList & operator=(const NodeSLList &)=delete
Iterator(Iterator &&it)
Definition: list.H:398
void reset()
Definition: list.H:467
void clear()
Definition: list.H:652
void split(NodeSLList &, NodeSLList &)
Definition: list.H:180
lint_t get_position() const
Definition: list.H:846
Node *& get_last()
Definition: list.H:127
T remove_first()
Definition: list.H:313
void concat(SLList &l)
Definition: list.H:331
SLList(SLList &&l)
Definition: list.H:226
const Node *& get_first() const
Definition: list.H:122
void swap(Iterator &it)
Definition: list.H:839
T & append(const T &item)
Definition: list.H:265
Iterator end() const
Definition: list.H:513
void swap(Iterator &it)
Definition: list.H:423
DLList()
Definition: list.H:622
Definition: iterator.H:92
bool is_empty() const
Definition: nodesdef.H:153
Definition: nodesdef.H:113
SLNode *& get_next()
Definition: nodesdef.H:83
Iterator begin() const
Definition: list.H:503
void concat(NodeSLList *l)
Definition: list.H:152
T & get_item()
Definition: nodesdef.H:454
MapKey< Node< GT > *, Arc< GT > ** > ValueType
Definition: list.H:619
Iterator(const DLList &l)
Definition: list.H:796
T & insert(T &&item)
Definition: list.H:671
T ValueType
Definition: list.H:211
bool is_empty() const
Definition: list.H:80
MapKey< Node< GT > *, Arc< GT > ** > KeyType
Definition: list.H:617
nat_t SizeType
Definition: list.H:620
SLList(const SLList &l)
Definition: list.H:220
DLList(DLList &&l)
Definition: list.H:634
T remove_last()
Definition: list.H:739
Definition: iterator.H:36
Node * get_location() const
Definition: list.H:367
void swap(NodeSLList &l)
Definition: list.H:74
T & get_first()
Definition: list.H:695
void insert_next(SLNode *p)
Definition: nodesdef.H:93
DLList(const DLList &l)
Definition: list.H:628
Iterator(const SLList< T > &l)
Definition: list.H:379
T & get_last()
Definition: list.H:711
const T & get_first() const
Definition: list.H:703
void append(Node *node)
Definition: list.H:106
T & get_current()
Definition: list.H:851
T & get_item()
Definition: nodesdef.H:73
T KeyType
Definition: list.H:209
DL *& get_prev()
Definition: nodesdef.H:178
Node *& get_first()
Definition: list.H:117
void del()
Definition: nodesdef.H:208
Iterator end()
Definition: list.H:508
bool is_unitarian() const
Definition: list.H:90
bool has_current() const
Definition: list.H:436
Iterator(const SLList< T > &l, Node *c)
Definition: list.H:386
Iterator begin()
Definition: list.H:498
Iterator begin() const
Definition: list.H:888
T & insert(const T &item)
Definition: list.H:249
void swap(SLList &l)
Definition: list.H:325
long long lint_t
Definition: types.H:49
T & insert(const T &item)
Definition: list.H:663
const T & get_first() const
Definition: list.H:289
void insert(Node *node)
Definition: list.H:95
Definition: italgorithms.H:33
Definition: nodesdef.H:415
nat_t size() const
Definition: list.H:239
Iterator(const DLList &l, DL *c)
Definition: list.H:803
SLNode< T > Node
Definition: list.H:38
Definition: containeralgorithms.H:33
void reset()
Definition: nodesdef.H:68
~SLList()
Definition: list.H:234
MapKey< Node< GT > *, Arc< GT > ** > ItemType
Definition: list.H:616
void clear()
Definition: list.H:244
T DataType
Definition: list.H:210
Iterator()
Definition: list.H:790
Iterator()
Definition: list.H:373
T & append(T &&item)
Definition: list.H:687
T & insert(T &&item)
Definition: list.H:257
MapKey< Node< GT > *, Arc< GT > ** > DataType
Definition: list.H:618
T & append(const T &item)
Definition: list.H:679
DL * remove_next()
Definition: nodesdef.H:215
DLNode *& get_next()
Definition: nodesdef.H:464
const Node *& get_last() const
Definition: list.H:132
T & append(T &&item)
Definition: list.H:273
const T & get_current() const
Definition: list.H:856
Iterator(const Iterator &it)
Definition: list.H:810
nat_t SizeType
Definition: list.H:212
T & select(nat_t)
Definition: list.H:946
T & get_last()
Definition: list.H:297
bool is_unitarian_or_empty() const
Definition: list.H:85
T del()
Definition: list.H:473
T & get_first()
Definition: list.H:281
const T & get_last() const
Definition: list.H:719
NodeSLList()
Definition: list.H:52
Definition: iterator.H:112
void swap(DLList &l)
Definition: list.H:657
Iterator begin()
Definition: list.H:883
unsigned long int nat_t
Definition: types.H:50
nat_t size() const
Definition: list.H:647
~DLList()
Definition: list.H:642
Iterator end()
Definition: list.H:893
T & operator[](nat_t i)
Definition: list.H:522
void next()
Definition: list.H:457
void concat(NodeSLList &l)
Definition: list.H:171
const T & get_last() const
Definition: list.H:305
Iterator(const Iterator &it)
Definition: list.H:392
Definition: nodesdef.H:35
T remove_first()
Definition: list.H:727
void next()
Definition: list.H:870
const T & get_current() const
Definition: list.H:449
NodeSLList(NodeSLList &&l)
Definition: list.H:60
Iterator end() const
Definition: list.H:898
Iterator(Iterator &&it)
Definition: list.H:816
SLList()
Definition: list.H:214
T & select(nat_t)
Definition: list.H:561
T del()
Definition: list.H:861
SLList & operator=(const SLList &l)
Definition: list.H:338
T ItemType
Definition: list.H:208
DL *& get_next()
Definition: nodesdef.H:168
T & get_current()
Definition: list.H:441
lint_t get_position() const
Definition: list.H:431
void prev()
Definition: list.H:876
Node * remove_first()
Definition: list.H:137
SLNode * remove_next()
Definition: nodesdef.H:101
Definition: nodesdef.H:293