<commit_before>
#ifndef __ACTOR_INVENTORY_H__
#define __ACTOR_INVENTORY_H__

#include "precompiled.h"

#include "engine/actor/ActorBase.h"
#include "engine/item/ItemBase.h"

#include <vector>

namespace engine {
namespace inventory {
	
	class ActorInventory {
	private:
		std::vector<item::ItemBase*> itemList;	
		engine::actor::ActorBase * owner;
	public:

		/*
			Kinda explains itself
		*/
		void setOwner(actor::ActorBase * actor) {
			owner = actor;
		}

		/*
			To see which actor this instance belongs too
		*/
		engine::actor::ActorBase * getOwner() {
			return owner;
		}

		/* 
			Well if you must you can look but you can't touch.
		*/
		const std::vector<item::ItemBase*> getItemList() {
			return itemList;
		}

		/*
			It'll loop across the inventory and count how many of the item
			by whatever name you have. That will be in the by reference parameeter
			quantity. The method itself will give you a pointer to the object itself.
		*/
		item::ItemBase * getItem(String name, int & quantity) {
			quantity = 0;
			std::vector<item::ItemBase*>::iterator it;
			item::ItemBase * returnItem = NULL;
			for( it = itemList.begin(); it != itemList.end(); ++it ) {
				if ( (*it)->getName() == name ) {
					quantity += 1;
					returnItem = (*it);
				}
			}
			return returnItem;
		}

		/*
			Removes a single instance
		*/
		bool removeItem(String name) {
			return false;
		}

	};<commit_msg>Modified engine::inventory::ActorInventory, add/remove/search. (Unit testing needed)<commit_after>
#ifndef __ACTOR_INVENTORY_H__
#define __ACTOR_INVENTORY_H__

#include "precompiled.h"

#include "engine/actor/ActorBase.h"
#include "engine/item/ItemBase.h"

#include <vector>

namespace engine {
namespace inventory {

	/**
	* typedef'd the vector so I don't have to look at ::<><>:::><><>
	*/
	typedef std::vector<item::ItemBase*>           tyItemVector;
	typedef std::vector<item::ItemBase*>::iterator tyItemIterator;
	
	class ActorInventory {
	private:
		std::vector<item::ItemBase*> itemList;	
		engine::actor::ActorBase * owner;
	public:

		/** Sets the owner of this inventory
		 * @params actor the actor who owns this inventory
		 */
		void setOwner(actor::ActorBase * actor) {
			owner = actor;
		}

		/** Returns the actor who owns this inventory
		 * @returns the actor who owns this inventory
		 */
		actor::ActorBase * getOwner() {
			return owner;
		}

		/** Returns an unchangable list of the items contained with this inventory object
		 * @returns a list of items of std::vector<item::ItemBase*>
		 */
		const tyItemVector getItemList() {
			return itemList;
		}

		/** Find all of the instances of a object by the supplied name and return a vector of those items
		 * @param name the name of the item to look for
		 * @returns a vector of ItemBase* to the instances of the found object
		 */
		tyItemVector getItemsByName(String name) {
			tyItemIterator iter;
			tyItemVector foundItems;
			for( iter = itemList.begin(); iter != itemList.end(); ++iter ) {
				if ( (*iter)->getName() == name ) {
					foundItems.push_back( (*iter) );
				}
			}
			return foundItems;
		}

		/** Find all of the instances of a object by the supplied name and return a vector of those items
		 * @param name the name of the item to look for
		 * @returns a vector of ItemBase* to the instances of the found object
		 */
		item::ItemBase * getItemByID( int id ) {
			item::ItemBase * returnItem = NULL;
			tyItemIterator iter;
			for( iter = itemList.begin(); iter != itemList.end(); ++iter ) {
				if ( (*iter)->getId() == id ) {
					returnItem = (*iter);
					break;
				}
			}
			return returnItem;
		}

		/** Adds a tracked item to the inventory
         * @param item the ItemBase in which to add
         * @returns boolean indication whether the item was added or not
		 */
		bool addItem(item::ItemBase * item) {
			// untracked items cannot be added
			if ( item->getId() == -1 ) {
				return false;
			}

			itemList.push_back( item );
			return true;
		}

		/** Removes all of the items in this inventory that match a certain name
		 * @param name the name of the item to look for
		 * @returns a vector of ItemBase* which was removed from this inventory
		 */
		tyItemVector removeItemsByName(String name) {
			return tyItemVector();
		}

		/** Removes a specific instance of an item based on it's ID number
		 * @param name the name of the item to look for
		 * @returns a boolean indication whether it was removed or not
		 */
		bool removeItemByID(int id) {
			if ( id < 0 ) { // ids less than 0 (-1) indicate untracked item, it can't be here anyway
				return false;
			}

			tyItemIterator iter;
			for( iter = itemList.begin(); iter != itemList.end(); ++iter ) {
				if ( (*iter)->getId() == id ) {
					iter = itemList.erase(iter);
					return true;
				}
			}
			return false;
		}

	};
{'fraction_non_alphanumeric': 0.11397670549084858, 'fraction_numerical': 0.0012479201331114808, 'mean_word_length': 3.1137724550898205, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3296309', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1454, 'n_words': 519}