#ifndef CYCRIPT_LIST_HPP
#define CYCRIPT_LIST_HPP
+#include "Exception.hpp"
+
template <typename Type_>
struct CYNext {
Type_ *next_;
Type_ *first_;
Type_ *last_;
- CYList(Type_ *first = NULL) :
+ CYList() :
+ first_(NULL),
+ last_(NULL)
+ {
+ }
+
+ CYList(Type_ *first) :
first_(first),
last_(CYGetLast(first))
{
}
+ CYList(Type_ *first, Type_ *last) :
+ first_(first),
+ last_(last)
+ {
+ }
+
operator Type_ *() const {
return first_;
}
if (first_ == NULL) {
first_ = next;
last_ = next;
- } else for (;; last_ = last_->next_)
- if (last_->next_ == NULL) {
- last_->next_ = next;
- last_ = next;
- break;
- }
+ } else {
+ _assert(last_->next_ == NULL);
+ last_->next_ = next;
+ last_ = next;
+ }
return *this;
}