Changeset - r21610:44b8e9a9a523
[Not reviewed]
master
0 1 0
frosch - 10 years ago 2014-08-16 20:40:26
frosch@openttd.org
(svn r26742) -Doc: Why reverse_iterator is unsuitable for ScriptList iterators
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_list.cpp
Show inline comments
 
@@ -142,24 +142,27 @@ public:
 
		if (item == this->item_next) {
 
			FindNext();
 
			return;
 
		}
 
	}
 
};
 

	
 
/**
 
 * Sort by value, descending.
 
 */
 
class ScriptListSorterValueDescending : public ScriptListSorter {
 
private:
 
	/* Note: We cannot use reverse_iterator.
 
	 *       The iterators must only be invalidated when the element they are pointing to is removed.
 
	 *       This only holds for forward iterators. */
 
	ScriptList::ScriptListBucket::iterator bucket_iter;    ///< The iterator over the list to find the buckets.
 
	ScriptList::ScriptItemList *bucket_list;               ///< The current bucket list we're iterator over.
 
	ScriptList::ScriptItemList::iterator bucket_list_iter; ///< The iterator over the bucket list.
 

	
 
public:
 
	/**
 
	 * Create a new sorter.
 
	 * @param list The list to sort.
 
	 */
 
	ScriptListSorterValueDescending(ScriptList *list)
 
	{
 
		this->list = list;
 
@@ -306,24 +309,27 @@ public:
 
		if (item == this->item_next) {
 
			FindNext();
 
			return;
 
		}
 
	}
 
};
 

	
 
/**
 
 * Sort by item, descending.
 
 */
 
class ScriptListSorterItemDescending : public ScriptListSorter {
 
private:
 
	/* Note: We cannot use reverse_iterator.
 
	 *       The iterators must only be invalidated when the element they are pointing to is removed.
 
	 *       This only holds for forward iterators. */
 
	ScriptList::ScriptListMap::iterator item_iter; ///< The iterator over the items in the map.
 

	
 
public:
 
	/**
 
	 * Create a new sorter.
 
	 * @param list The list to sort.
 
	 */
 
	ScriptListSorterItemDescending(ScriptList *list)
 
	{
 
		this->list = list;
 
		this->End();
 
	}
0 comments (0 inline, 0 general)