/** * Remove the entity from the specified group. * * @param e entity to remove from group * @param group group to remove the entity from */ public void remove(Entity e, String group) { final Bag<Entity> entities = entitiesByGroup.get(group); if (entities != null) { entities.remove(e); } final IntBag identities = identitiesByGroup.get(group); if (identities != null) { identities.removeValue(e.getId()); } Bag<String> groups = groupsByEntity.get(e); if (groups != null) { groups.remove(group); if (groups.size() == 0) groupsByEntity.remove(e); } }
/** * Remove the entity from the specified group. * * @param e entity to remove from group * @param group group to remove the entity from */ public void remove(Entity e, String group) { final Bag<Entity> entities = entitiesByGroup.get(group); if (entities != null) { entities.remove(e); } final IntBag identities = identitiesByGroup.get(group); if (identities != null) { identities.removeValue(e.getId()); } Bag<String> groups = groupsByEntity.get(e); if (groups != null) { groups.remove(group); if (groups.size() == 0) groupsByEntity.remove(e); } }
/** * Remove the entity from all groups. * * @param e the entity to remove */ public void removeFromAllGroups(Entity e) { Bag<String> groups = groupsByEntity.get(e); if (groups == null) return; for (int i = 0, s = groups.size(); s > i; i++) { Bag<Entity> entities = entitiesByGroup.get(groups.get(i)); if (entities != null) { entities.remove(e); } IntBag identities = identitiesByGroup.get(groups.get(i)); if (identities != null) { identities.removeValue(e.getId()); } } groupsByEntity.remove(e); }
/** * Remove the entity from all groups. * * @param e the entity to remove */ public void removeFromAllGroups(Entity e) { Bag<String> groups = groupsByEntity.get(e); if (groups == null) return; for (int i = 0, s = groups.size(); s > i; i++) { Bag<Entity> entities = entitiesByGroup.get(groups.get(i)); if (entities != null) { entities.remove(e); } IntBag identities = identitiesByGroup.get(groups.get(i)); if (identities != null) { identities.removeValue(e.getId()); } } groupsByEntity.remove(e); }