summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_abstractlist.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-02-28 20:25:03 +0000
committerfrosch <frosch@openttd.org>2010-02-28 20:25:03 +0000
commit333249ce501085405afabac8eb61a2c3ed599c0f (patch)
tree1892303233cef8b6bf22b985f142c9ef3d2bfbe6 /src/ai/api/ai_abstractlist.cpp
parentac1a08ef4ad2414491b050b374714d7313373c1f (diff)
downloadopenttd-333249ce501085405afabac8eb61a2c3ed599c0f.tar.xz
(svn r19294) -Change: [NoAI] Remove HasNext() from all lists/iterators and add IsEnd() instead.
Diffstat (limited to 'src/ai/api/ai_abstractlist.cpp')
-rw-r--r--src/ai/api/ai_abstractlist.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/ai/api/ai_abstractlist.cpp b/src/ai/api/ai_abstractlist.cpp
index 9aeff4fc4..e169f5ef6 100644
--- a/src/ai/api/ai_abstractlist.cpp
+++ b/src/ai/api/ai_abstractlist.cpp
@@ -42,9 +42,9 @@ public:
virtual int32 Next() = 0;
/**
- * See if there is a next item of the sorter.
+ * See if the sorter has reached the end.
*/
- virtual bool HasNext() = 0;
+ virtual bool IsEnd() = 0;
/**
* Callback from the list if an item gets removed.
@@ -114,7 +114,7 @@ public:
int32 Next()
{
- if (!this->HasNext()) return 0;
+ if (this->IsEnd()) return 0;
int32 item_current = this->item_next;
FindNext();
@@ -123,7 +123,7 @@ public:
void Remove(int item)
{
- if (!this->HasNext()) return;
+ if (this->IsEnd()) return;
/* If we remove the 'next' item, skip to the next */
if (item == this->item_next) {
@@ -132,9 +132,9 @@ public:
}
}
- bool HasNext()
+ bool IsEnd()
{
- return !(this->list->buckets.empty() || this->has_no_more_items);
+ return this->list->buckets.empty() || this->has_no_more_items;
}
};
@@ -208,7 +208,7 @@ public:
int32 Next()
{
- if (!this->HasNext()) return 0;
+ if (this->IsEnd()) return 0;
int32 item_current = this->item_next;
FindNext();
@@ -217,7 +217,7 @@ public:
void Remove(int item)
{
- if (!this->HasNext()) return;
+ if (this->IsEnd()) return;
/* If we remove the 'next' item, skip to the next */
if (item == this->item_next) {
@@ -226,9 +226,9 @@ public:
}
}
- bool HasNext()
+ bool IsEnd()
{
- return !(this->list->buckets.empty() || this->has_no_more_items);
+ return this->list->buckets.empty() || this->has_no_more_items;
}
};
@@ -278,7 +278,7 @@ public:
int32 Next()
{
- if (!this->HasNext()) return 0;
+ if (this->IsEnd()) return 0;
int32 item_current = this->item_next;
FindNext();
@@ -287,7 +287,7 @@ public:
void Remove(int item)
{
- if (!this->HasNext()) return;
+ if (this->IsEnd()) return;
/* If we remove the 'next' item, skip to the next */
if (item == this->item_next) {
@@ -296,9 +296,9 @@ public:
}
}
- bool HasNext()
+ bool IsEnd()
{
- return !(this->list->items.empty() || this->has_no_more_items);
+ return this->list->items.empty() || this->has_no_more_items;
}
};
@@ -349,7 +349,7 @@ public:
int32 Next()
{
- if (!this->HasNext()) return 0;
+ if (this->IsEnd()) return 0;
int32 item_current = this->item_next;
FindNext();
@@ -358,7 +358,7 @@ public:
void Remove(int item)
{
- if (!this->HasNext()) return;
+ if (this->IsEnd()) return;
/* If we remove the 'next' item, skip to the next */
if (item == this->item_next) {
@@ -367,9 +367,9 @@ public:
}
}
- bool HasNext()
+ bool IsEnd()
{
- return !(this->list->items.empty() || this->has_no_more_items);
+ return this->list->items.empty() || this->has_no_more_items;
}
};
@@ -448,13 +448,13 @@ bool AIAbstractList::IsEmpty()
return this->items.empty();
}
-bool AIAbstractList::HasNext()
+bool AIAbstractList::IsEnd()
{
if (this->initialized == false) {
- DEBUG(ai, 0, "HasNext() is invalid as Begin() is never called");
- return false;
+ DEBUG(ai, 0, "IsEnd() is invalid as Begin() is never called");
+ return true;
}
- return this->sorter->HasNext();
+ return this->sorter->IsEnd();
}
int32 AIAbstractList::Count()
@@ -748,7 +748,7 @@ SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm)
sq_getinteger(vm, 2, &idx);
int val = this->Next();
- if (!this->HasNext()) {
+ if (this->IsEnd()) {
sq_pushnull(vm);
return 1;
}