ai_abstractlist.hpp
Go to the documentation of this file.00001
00002
00006 #ifndef AI_ABSTRACTLIST_HPP
00007 #define AI_ABSTRACTLIST_HPP
00008
00009 #include "ai_object.hpp"
00010 #include <map>
00011 #include <set>
00012
00013 class AIAbstractListSorter;
00014
00018 class AIAbstractList : public AIObject {
00019 public:
00020 static const char *GetClassName() { return "AIAbstractList"; }
00021
00023 enum SorterType {
00024 SORT_BY_VALUE,
00025 SORT_BY_ITEM,
00026 };
00027
00028 private:
00029 AIAbstractListSorter *sorter;
00030 SorterType sorter_type;
00031 bool sort_ascending;
00032 bool initialized;
00033
00034 public:
00035 typedef std::set<int32> AIItemList;
00036 typedef std::map<int32, AIItemList> AIAbstractListBucket;
00037 typedef std::map<int32, int32> AIAbstractListMap;
00038
00039 AIAbstractListMap items;
00040 AIAbstractListBucket buckets;
00041
00042 protected:
00048 void AddItem(int32 item);
00049
00054 void RemoveItem(int32 item);
00055
00056 public:
00057 AIAbstractList();
00058 ~AIAbstractList();
00059
00063 void Clear();
00064
00070 bool HasItem(int32 item);
00071
00076 int32 Begin();
00077
00083 int32 Next();
00084
00089 bool IsEmpty();
00090
00096 bool HasNext();
00097
00102 int32 Count();
00103
00109 int32 GetValue(int32 item);
00110
00119 bool SetValue(int32 item, int32 value);
00120
00127 void Sort(SorterType sorter, bool ascending);
00128
00137 void AddList(AIAbstractList *list);
00138
00143 void RemoveAboveValue(int32 value);
00144
00149 void RemoveBelowValue(int32 value);
00150
00156 void RemoveBetweenValue(int32 start, int32 end);
00157
00162 void RemoveValue(int32 value);
00163
00168 void RemoveTop(int32 count);
00169
00174 void RemoveBottom(int32 count);
00175
00181 void RemoveList(AIAbstractList *list);
00182
00187 void KeepAboveValue(int32 value);
00188
00193 void KeepBelowValue(int32 value);
00194
00200 void KeepBetweenValue(int32 start, int32 end);
00201
00206 void KeepValue(int32 value);
00207
00212 void KeepTop(int32 count);
00213
00218 void KeepBottom(int32 count);
00219
00225 void KeepList(AIAbstractList *list);
00226
00227 #ifndef DOXYGEN_SKIP
00228
00231 SQInteger _get(HSQUIRRELVM vm);
00232
00236 SQInteger _nexti(HSQUIRRELVM vm);
00237
00241 SQInteger Valuate(HSQUIRRELVM vm);
00242 #else
00243
00259 void Valuate(void *valuator_function, int params, ...);
00260 #endif
00261 };
00262
00263 #endif