本文整理了Java中com.artemis.utils.Bag.contains()
方法的一些代码示例,展示了Bag.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bag.contains()
方法的具体详情如下:
包路径:com.artemis.utils.Bag
类名称:Bag
方法名:contains
[英]Check if bag contains this element.
[中]检查袋子是否包含此元素。
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-eventbus
/** Subscribe listener to events. */
@Override
public void register( EventListener listener )
{
if ( !listeners.contains(listener) ) {
listeners.add(listener);
sortDirty =true;
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Ensure this builder includes the specified component type.
*
* @param type
* @return This instance for chaining.
*/
public ArchetypeBuilder add(Class<? extends Component> type) {
if (!classes.contains(type))
classes.add(type);
return this;
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Ensure this builder includes the specified component types.
*
* @param types
* @return This instance for chaining.
*/
public ArchetypeBuilder add(Class<? extends Component>... types) {
for (int i = 0; types.length > i; i++) {
Class<? extends Component> type = types[i];
if (!classes.contains(type))
classes.add(type);
}
return this;
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Ensure this builder includes the specified component type.
*
* @param type
* @return This instance for chaining.
*/
public ArchetypeBuilder add(Class<? extends Component> type) {
if (!classes.contains(type))
classes.add(type);
return this;
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
/** Subscribe listener to events. */
@Override
public void register( EventListener listener )
{
if ( !listeners.contains(listener) ) {
listeners.add(listener);
sortDirty =true;
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Ensure this builder includes the specified component types.
*
* @param types
* @return This instance for chaining.
*/
public ArchetypeBuilder add(Class<? extends Component>... types) {
for (int i = 0; types.length > i; i++) {
Class<? extends Component> type = types[i];
if (!classes.contains(type))
classes.add(type);
}
return this;
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-eventbus
@Override
public void register(EventListener listener) {
if ( listener == null ) throw new NullPointerException("Listener required.");
// Bind listener to the related event class.
Bag<EventListener> listenersFor = getListenersFor(listener.getParameterType(), true);
if ( !listenersFor.contains(listener)) {
listenersFor.add(listener);
// the hierarchical cache is now out of date. purrrrrrrrge!
invalidateHierarchicalCache();
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Set the group of the entity.
*
* @param group group to add the entity into
* @param e entity to add into the group
*/
public void add(Entity e, String group) {
Bag<Entity> entities = entitiesByGroup.get(group);
if (entities == null) {
entities = new Bag<>();
entitiesByGroup.put(group, entities);
}
IntBag identities = identitiesByGroup.get(group);
if (identities == null) {
identities = new IntBag();
identitiesByGroup.put(group, identities);
}
if (!entities.contains(e)) {
entities.add(e);
identities.add(e.getId());
}
Bag<String> groups = groupsByEntity.get(e);
if (groups == null) {
groups = new Bag<>();
groupsByEntity.put(e, groups);
}
if (!groups.contains(group)) {
groups.add(group);
}
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Set the group of the entity.
*
* @param group group to add the entity into
* @param e entity to add into the group
*/
public void add(Entity e, String group) {
Bag<Entity> entities = entitiesByGroup.get(group);
if (entities == null) {
entities = new Bag<>();
entitiesByGroup.put(group, entities);
}
IntBag identities = identitiesByGroup.get(group);
if (identities == null) {
identities = new IntBag();
identitiesByGroup.put(group, identities);
}
if (!entities.contains(e)) {
entities.add(e);
identities.add(e.getId());
}
Bag<String> groups = groupsByEntity.get(e);
if (groups == null) {
groups = new Bag<>();
groupsByEntity.put(e, groups);
}
if (!groups.contains(group)) {
groups.add(group);
}
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
@Override
public void register(EventListener listener) {
if ( listener == null ) throw new NullPointerException("Listener required.");
// Bind listener to the related event class.
Bag<EventListener> listenersFor = getListenersFor(listener.getParameterType(), true);
if ( !listenersFor.contains(listener)) {
listenersFor.add(listener);
// the hierarchical cache is now out of date. purrrrrrrrge!
invalidateHierarchicalCache();
}
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
/**
* Subscribe T to entity.
* <p/>
* Does nothing if already subscribed.
*
* @param subscriber subscriber
* @param entityId entity to subscribe.
*/
public void subscribe(T subscriber, int entityId) {
// hook subscriber to entity.
IntBag entities = subscriberEntities.get(subscriber);
if (entities == null) {
entities = new IntBag();
subscriberEntities.put(subscriber, entities);
}
if (!entities.contains(entityId)) {
entities.add(entityId);
}
// hook entity to subscriber.
Bag<T> subscribers = entitySubscribers.get(entityId);
if (subscribers == null) {
subscribers = new Bag<>();
entitySubscribers.set(entityId, subscribers);
}
if (!subscribers.contains(subscriber)) {
subscribers.add(subscriber);
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* <p>Injects and associates the listener with a specific field for a given
* component type.</p>
*
* <p>Each <code>ComponentType::Field</code> pair can only have one {@link LinkListener}</p>
*
* @param component component type associated with listener
* @param field target field for listener
* @param listener link listener
*/
public void register(Class<? extends Component> component, String field, LinkListener listener) {
world.inject(listener);
try {
Field f = (field != null)
? ClassReflection.getDeclaredField(component, field)
: null;
ComponentType ct = world.getComponentManager().getTypeFactory().getTypeFor(component);
for (LinkSite site : linkSites) {
if (ct.equals(site.type) && (f == null || site.field.equals(f))) {
site.listener = listener;
if (!decoratedLinkSites.contains(site))
decoratedLinkSites.add(site);
if (fireEventsOnRegistration)
site.inserted(site.subscription.getEntities());
}
}
} catch (ReflectionException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* <p>Injects and associates the listener with a specific field for a given
* component type.</p>
*
* <p>Each <code>ComponentType::Field</code> pair can only have one {@link LinkListener}</p>
*
* @param component component type associated with listener
* @param field target field for listener
* @param listener link listener
*/
public void register(Class<? extends Component> component, String field, LinkListener listener) {
world.inject(listener);
try {
Field f = (field != null)
? ClassReflection.getDeclaredField(component, field)
: null;
ComponentType ct = world.getComponentManager().getTypeFactory().getTypeFor(component);
for (LinkSite site : linkSites) {
if (ct.equals(site.type) && (f == null || site.field.equals(f))) {
site.listener = listener;
if (!decoratedLinkSites.contains(site))
decoratedLinkSites.add(site);
if (fireEventsOnRegistration)
site.inserted(site.subscription.getEntities());
}
}
} catch (ReflectionException e) {
throw new RuntimeException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!