-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015 Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016 Jay Freeman (saurik)
*/
/* GNU Affero General Public License, Version 3 {{{ */
#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;
}