I have a class of 3 different linked lists (for saving objects in the game I'm working on). Lists are all objects with the same base type, but I save them separately for processing. Note that IEntity, IObject, and IUndead are all inherited from IEntity.
public class EntityBucket
{
public LinkedList<IEntity> undeadEntities;
public LinkedList<IEntity> objects;
public LinkedList<IEntity> livingEntities;
public EntityBucket()
{
undeadEntities = new LinkedList<IEntity>();
objects = new LinkedList<IEntity>();
livingEntities = new LinkedList<IEntity>();
}
public LinkedList<IEntity> GetList(IObject e)
{
return objects;
}
public LinkedList<IEntity> GetList(IUndead e)
{
return undeadEntities;
}
public LinkedList<IEntity> GetList(ILiving e)
{
return livingEntities;
}
}
3 , . , 3, , , - . - , -, . , GetList, , , . , :
public void Delete(IUndead e, World world)
{
.....
LinkedList<IEntity> list = buckets[k].GetList(e);
.....
}
, (, ). , , , , . 3 ( 3 , add ..) - , IUndead, IObject ILiving. , .
, , , , .
, . , -, , , . getlist , .