本文整理汇总了Java中com.badlogic.gdx.utils.Array.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Array.contains方法的具体用法?Java Array.contains怎么用?Java Array.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.Array
的用法示例。
在下文中一共展示了Array.contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMatch
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
boolean checkMatch(TileType[] tiles, Array<TileType> black, Array<TileType> white, boolean nullMatches) {
if(tiles.length != map.length)
throw new IllegalArgumentException("tile type array must be of equal size to overlap map array; "+tiles.length+"!="+map.length);
// if the white or black tiles are null, then it means it works if it doesn't match the other color.
for(int i = 0; i < tiles.length; i++) {
int matchRule = map[i];
TileType type = tiles[i];
if(type == null) {
if(nullMatches) continue;
else return false;
}
if(matchRule == WHITE && (white == null && black.contains(type, true) || white != null && !white.contains(type, true)))
return false;
if(matchRule == BLACK && (black == null && white.contains(type, true) || black != null && !black.contains(type, true)))
return false;
/*if(black == null && type != white && (matchRule == BLACK || matchRule == WHITE)) {
// here, make sure that if the tile is adjacent to a white tile, that the current type is not greater than the white tile in z order.
if(i >= height && map[i-height] == WHITE && tiles[i-height] == white || i+height < tiles.length && map[i+height] == WHITE && tiles[i+height] == white || i%height > 0 && map[i-1] == WHITE && tiles[i-1] == white || i%height < height-1 && map[i+1] == WHITE && tiles[i+1] == white)
if(TileType.tileSorter.compare(type, white) > 0)
return false;
}*/
}
return true;
}
示例2: getDirectSubclass
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
/** @noinspection unchecked*/
@NotNull
public static <S, T extends S> Class<? extends S> getDirectSubclass(@NotNull Class<S> superClass, @NotNull Class<T> target) {
if (superClass.equals(target))
return target; // this returns the super class, not it's direct subclass, but in this situation that's that best we're gonna get.
// because we only ever use super classes from the original target, it is safe at any time to assume that any class found is super T.
Class<? super T> targetSuper = target.getSuperclass(); // due to the equality check above, this class will always extend S.
boolean hasSuper = targetSuper != null; // if target is the Object class, then there won't a super class.
if (hasSuper && targetSuper.equals(superClass))
return target;
Array<Class<? super T>> parents = new Array<>((Class<? super T>[]) target.getInterfaces());
if (parents.contains(superClass, false))
return target;
// target is not a direct subclass of superClass, so recurse first into the super class, and then into the interfaces.
if (hasSuper && superClass.isAssignableFrom(targetSuper))
return getDirectSubclass(superClass, (Class<? extends S>) targetSuper);
else {
// it HAS to be one of the interfaces that extend the superClass.
for(Class<? super T> parent: parents)
if(superClass.isAssignableFrom(parent))
return getDirectSubclass(superClass, (Class<? extends S>) parent);
// if the code reaches here, then something went terribly wrong, because target is required to extend superClass, but at this point we've gone through both the interfaces and the super class, and haven't found it.
throw new IncompatibleClassChangeError("Class " + target + " is required by generics to extend " + superClass + ", but neither the super class nor any implemented interfaces do.");
}
}