public static void Run() { NamedDataRegistry <int> registry = new NamedDataRegistry <int>(); registry.Add("Zero", 0); registry.Add("One", 1); registry.Add("Two", 2); registry.Add("Three", 3); registry.Add("Four", 4); registry.Add("Five", 5); foreach (int i in registry) { Console.WriteLine(i); } }
/// <summary> /// Constructs an entity buffer /// </summary> /// <param name="entityHash">the hash value for the entity hash table, larger means faster name searches but more memory</param> /// <param name="systemLinkHash">the hash value for system link hash table, larger means faster search but more memory</param> /// <param name="entityPagePower">the size of the entity pages in the form of a power of 2</param> /// <param name="entityPageCount">the initial number of entity pages, this has a small affect on early performance</param> /// <param name="entityComponentPagePower">the size of the entity component pages in the form of a power of 2</param> /// <param name="entityComponentPageCount">the initial number of entity pages, this has a small affect on early performance</param> /// <param name="entityListPagePower">the size of the entity list pages in the form of a power of 2</param> /// <param name="entityListPageCount">the initial number of entity pages, this has a small affect on early performance</param> /// <param name="systemLinkPagePower">the size of the systemlink pages in the form of a power of 2</param> /// <param name="systemLinkPageCount">the initial number of entity pages, this has a small affect on early performance</param> /// <param name="componentTypes">The registry for component types which is used to get type IDs if a system is registered before its type ids are filled out</param> public EntityBuffer(IComponentTypeRegistry componentTypes, int entityHash = 47, int systemLinkHash = 47, int entityPagePower = 8, int entityComponentPagePower = 8, int entityListPagePower = 8, int systemLinkPagePower = 8, int entityPageCount = 1, int entityComponentPageCount = 1, int entityListPageCount = 1, int systemLinkPageCount = 1) { _entities = new NamedDataRegistry <BufferedBinarySearchTree <EntityLink> >(entityPagePower, entityPageCount, entityHash); _links = new PagedArray <SystemLink>(systemLinkPagePower, systemLinkPageCount); _lists = new PagedArray <EntityList>(systemLinkPagePower, systemLinkPageCount); _hashVal = systemLinkHash; _starts = new int[_hashVal]; _ends = new int[_hashVal]; _listPower = entityListPagePower; _listPages = entityListPageCount; _entityPower = entityComponentPagePower; _entityPages = entityComponentPageCount; _componentTypes = componentTypes; }
/// <summary> /// Constructor for <see cref="ComponentTypeRegistry"/> /// </summary> /// <param name="pagePower">the size of pages as a power of 2</param> /// <param name="pageCount">the number of initial pages, has an affect on early performance but a memory impact</param> /// <param name="hashSize">the size of the hash table, the larger the faster the name search, the more memory it will use</param> public ComponentTypeRegistry(int pagePower = 8, int pageCount = 1, int hashSize = 47) { _registry = new NamedDataRegistry <IComponentBuffer>(pagePower, pageCount, hashSize); }
/// <summary> /// Constructs an instance of <see cref="SystemRegistry"/> /// </summary> /// <param name="systemPagePower">the size of the system pages as a power of 2</param> /// <param name="systemPageCount">the number of pages to start with, larger values decrease early performance hits but increase memory cost</param> /// <param name="hashSize">the hash size used by the internal hashtable. Higher makes for faster searching but increases memory usage</param> public SystemRegistry(int systemPagePower = 8, int systemPageCount = 1, int hashSize = 47) { _systems = new NamedDataRegistry <ISystem>(systemPagePower, systemPageCount, hashSize); }