# ai_abstractlist.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_abstractlist.hpp 17197 2009-08-15 22:06:51Z rubidium $ */
    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
    00029   static const bool SORT_ASCENDING = true;
    00031   static const bool SORT_DESCENDING = false;
    00032
    00033 private:
    00034   AIAbstractListSorter *sorter;
    00035   SorterType sorter_type;
    00036   bool sort_ascending;
    00037   bool initialized;
    00038   int modifications;
    00039
    00040 public:
    00041   typedef std::set<int32> AIItemList;
    00042   typedef std::map<int32, AIItemList> AIAbstractListBucket;
    00043   typedef std::map<int32, int32> AIAbstractListMap;
    00044
    00045   AIAbstractListMap items;
    00046   AIAbstractListBucket buckets;
    00047
    00048 protected:
    00054   void AddItem(int32 item);
    00055
    00060   void RemoveItem(int32 item);
    00061
    00062 public:
    00063   AIAbstractList();
    00064   ~AIAbstractList();
    00065
    00069   void Clear();
    00070
    00076   bool HasItem(int32 item);
    00077
    00082   int32 Begin();
    00083
    00089   int32 Next();
    00090
    00095   bool IsEmpty();
    00096
    00102   bool HasNext();
    00103
    00108   int32 Count();
    00109
    00115   int32 GetValue(int32 item);
    00116
    00125   bool SetValue(int32 item, int32 value);
    00126
    00134   void Sort(SorterType sorter, bool ascending);
    00135
    00144   void AddList(AIAbstractList *list);
    00145
    00150   void RemoveAboveValue(int32 value);
    00151
    00156   void RemoveBelowValue(int32 value);
    00157
    00163   void RemoveBetweenValue(int32 start, int32 end);
    00164
    00169   void RemoveValue(int32 value);
    00170
    00175   void RemoveTop(int32 count);
    00176
    00181   void RemoveBottom(int32 count);
    00182
    00188   void RemoveList(AIAbstractList *list);
    00189
    00194   void KeepAboveValue(int32 value);
    00195
    00200   void KeepBelowValue(int32 value);
    00201
    00207   void KeepBetweenValue(int32 start, int32 end);
    00208
    00213   void KeepValue(int32 value);
    00214
    00219   void KeepTop(int32 count);
    00220
    00225   void KeepBottom(int32 count);
    00226
    00232   void KeepList(AIAbstractList *list);
    00233
    00234 #ifndef DOXYGEN_SKIP
    00235
    00238   SQInteger _get(HSQUIRRELVM vm);
    00239
    00243   SQInteger _nexti(HSQUIRRELVM vm);
    00244
    00248   SQInteger Valuate(HSQUIRRELVM vm);
    00249 #else
    00250
    00268   void Valuate(void *valuator_function, int params, ...);
    00269 #endif /* DOXYGEN_SKIP */
    00270 };
    00271
    00272 #endif /* AI_LIST_HPP */