src/ai/api/ai_list.hpp
branchnoai
changeset 9590 16cde7f36a88
parent 9589 2fbda08db406
child 9593 012f29f59906
equal deleted inserted replaced
9589:2fbda08db406 9590:16cde7f36a88
    17 class AIList : public AIObject {
    17 class AIList : public AIObject {
    18 private:
    18 private:
    19 	AIListSorter *sorter;
    19 	AIListSorter *sorter;
    20 
    20 
    21 public:
    21 public:
    22 	typedef std::set<int32> AIItemList;
    22 	typedef std::set<int32> AIItemList;               ///< The list of items inside the bucket
    23 	typedef std::map<int32, AIItemList> AIListBucket;
    23 	typedef std::map<int32, AIItemList> AIListBucket; ///< The bucket list per value
    24 	typedef std::map<int32, int32> AIListMap;
    24 	typedef std::map<int32, int32> AIListMap;         ///< List per item
    25 
    25 
    26 	AIListMap items;           ///< The items in the list
    26 	AIListMap items;           ///< The items in the list
    27 	AIListBucket buckets;      ///< The items in the list, sorted by value
    27 	AIListBucket buckets;      ///< The items in the list, sorted by value
    28 
    28 
    29 public:
    29 public:
   173 
   173 
   174 	/**
   174 	/**
   175 	 * The definition how valuators should look.
   175 	 * The definition how valuators should look.
   176 	 */
   176 	 */
   177 	class Valuator {
   177 	class Valuator {
       
   178 		/* Make this valuator a friend of AIList, so we can access the private.
       
   179 		 *  Nobody else should ever call Valuate. */
   178 		friend class AIList;
   180 		friend class AIList;
   179 	public:
   181 	public:
       
   182 		/**
       
   183 		 * Virtual destructor, needed to make compilers happy.
       
   184 		 */
   180 		virtual ~Valuator() {}
   185 		virtual ~Valuator() {}
   181 
   186 
   182 	private:
   187 	private:
   183 		virtual int32 Valuate(int32 item) const = 0;
   188 		virtual int32 Valuate(int32 item) const = 0;
   184 	};
   189 	};