本文整理匯總了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.");
}
}