本文整理汇总了Java中java.util.ArrayList.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.indexOf方法的具体用法?Java ArrayList.indexOf怎么用?Java ArrayList.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ArrayList
的用法示例。
在下文中一共展示了ArrayList.indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GenerateProperty
import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public ArrayList<InspectorProperty> GenerateProperty() {
ArrayList<InspectorProperty> res = super.GenerateProperty();
String[] afetados = new String[]{"setWidth", "setHeight"};
InspectorProperty tmp = InspectorProperty.FindByProperty(res, "setHeight");
int p = res.indexOf(tmp) + 1;
res.add(p, InspectorProperty.PropertyFactorySN("cardinalidade.tamanhoautmatico", "setTamanhoAutmatico", isTamanhoAutmatico()).AddCondicaoForFalse(afetados));
res.add(p + 1, InspectorProperty.PropertyFactorySN("cardinalidade.movimentacaomanual", "setMovimentacaoManual", isMovimentacaoManual()));
//res.add(InspectorProperty.PropertyFactorySeparador("mer"));
ArrayList<String> strCards = new ArrayList<>();
for (int i = 0; i < 4; i++) {
strCards.add(CardToString(IntToCard(i)));
}
res.add(InspectorProperty.PropertyFactoryMenu("cardinalidade.card", "setCard", CardToInt(), strCards));
return res;
}
示例2: bindScreens
import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public void bindScreens(ArrayList<Long> orderedScreenIds) {
// Make sure the first screen is always at the start.
if (orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) {
orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID);
orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID);
LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds);
} else if (orderedScreenIds.isEmpty()) {
// If there are no screens, we need to have an empty screen
mWorkspace.addExtraEmptyScreen();
}
bindAddScreens(orderedScreenIds);
// Create the custom content page (this call updates mDefaultScreen which calls
// setCurrentPage() so ensure that all pages are added before calling this).
if (hasCustomContentToLeft()) {
mWorkspace.createCustomContentContainer();
populateCustomContentContainer();
}
// After we have added all the screens, if the wallpaper was locked to the default state,
// then notify to indicate that it can be released and a proper wallpaper offset can be
// computed before the next layout
mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout();
}
示例3: getOrderByForWith
import java.util.ArrayList; //导入方法依赖的package包/类
private static StringBuilder getOrderByForWith(StringBuilder sWith, ArrayList<String> tokens) {
int posOfOrder = tokens.indexOf("order");
sWith.append(" ORDER BY ");
tokens = new ArrayList<>(tokens.subList(posOfOrder, tokens.size()));
// deals with clauses such as ORDER BY <alias> ASC/DESC
if (tokens.size() == 3 || tokens.size() == 4) {
sWith.append(tokens.get(2)).append(" ").append((tokens.size() == 4) ? tokens.get(3) : "ASC");
return sWith;
}
while (true) {
String field = tokens.get(4);
String dir = (tokens.get(5).equals("asc") || tokens.get(5).equals("desc")) ? tokens.get(5) : null;
sWith.append(field).append(" ").append((dir == null) ? "" : dir);
int posOfComma = tokens.indexOf(",");
if (posOfComma == -1) break;
else tokens = new ArrayList<>(tokens.subList(posOfComma + 1, tokens.size()));
}
return sWith;
}
示例4: validationSuccess
import java.util.ArrayList; //导入方法依赖的package包/类
private boolean validationSuccess(){
ArrayList typeList = HabitListController.getTypeList();
String editedTitle = titleEditText.getText().toString().trim();
if(typeList.indexOf((editedTitle))!= -1 && !editedTitle.equals(oldHabitType)){
Toast.makeText(this, "This habit type already exist.",
Toast.LENGTH_SHORT).show();
return false;
}
if (titleEditText.getText().toString().isEmpty()) {
Toast.makeText(this, "Please enter a habit name.",
Toast.LENGTH_SHORT).show();
return false;
}
if (reasonEditText.getText().toString().isEmpty()) {
Toast.makeText(this, "Please enter a habit reason.",
Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
示例5: getLastIndex
import java.util.ArrayList; //导入方法依赖的package包/类
private static int getLastIndex(ArrayList<LatLng> circlePoints, ArrayList<LatLng> checkAgainst) {
int endIndex = 0;
boolean stopChecking = false;
for (LatLng latLng : circlePoints) {
if (!PolyUtil.containsLocation(latLng, checkAgainst, isGeoDisc)) {
endIndex = circlePoints.indexOf(latLng);
stopChecking = true;
} else {
if (stopChecking) {
break;
}
}
}
return endIndex;
}
示例6: calcMaisADireita
import java.util.ArrayList; //导入方法依赖的package包/类
protected Forma calcMaisADireita(ArrayList<EapBarraLigacao> ja, HashMap<Forma, EapBarraLigacao> areas) {
if (ja.indexOf(this) > -1) {
return null;
}
ja.add(this);
ArrayList<Forma> lst = getListaDeFormasLigadas();
Forma ma = capturePrincipal();
lst.remove(ma);
for (Forma forma : lst) {
if (areas.get(forma) != null) {
Forma tmp = areas.get(forma).calcMaisADireita(ja, areas);
if (tmp != null) {
forma = tmp;
}
}
if (forma.getLeftWidth() > ma.getLeftWidth()) {
ma = forma;
}
}
return ma;
}
示例7: addPrintServiceToList
import java.util.ArrayList; //导入方法依赖的package包/类
private int addPrintServiceToList(ArrayList<PrintService> printerList, PrintService ps) {
int index = printerList.indexOf(ps);
// Check if PrintService with same name is already in the list.
if (CUPSPrinter.isCupsRunning() && index != -1) {
// Bug in Linux: Duplicate entry of a remote printer
// and treats it as local printer but it is returning wrong
// information when queried using IPP. Workaround is to remove it.
// Even CUPS ignores these entries as shown in lpstat or using
// their web configuration.
PrinterURI uri = ps.getAttribute(PrinterURI.class);
if (uri.getURI().getHost().equals("localhost")) {
IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps);
return index; // Do not add this.
}
PrintService oldPS = printerList.get(index);
uri = oldPS.getAttribute(PrinterURI.class);
if (uri.getURI().getHost().equals("localhost")) {
IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS);
printerList.remove(oldPS);
} else {
return index;
}
}
printerList.add(ps);
return (printerList.size() - 1);
}
示例8: getlblClass
import java.util.ArrayList; //导入方法依赖的package包/类
public void getlblClass(ArrayList<Double> lblClass,
ArrayList<Integer> lblCount, ArrayList<Float> lblProba) {
int j = 0;
for (double i : labels) {
// 如果当前的label不存在于lblClass则加入
if (!lblClass.contains(i)) {
lblClass.add(j, i);
lblCount.add(j++, 1);
}
else // 如果label中已经存在,就将其计数加1
{
int index = lblClass.indexOf(i);
int count = lblCount.get(index);
lblCount.set(index, ++count);
}
}
for (int i = 0; i < lblClass.size(); i++) {
// System.out.println("值为"+lblClass.get(i)+"的个数有"+lblCount.get(i)+"概率是"+lblCount.get(i)/(float)labels.length);
lblProba.add(i, lblCount.get(i) / (float) labels.length);
}
}
示例9: calculateSafeBrakingDistance
import java.util.ArrayList; //导入方法依赖的package包/类
private double calculateSafeBrakingDistance(String trainID) {
// get the current block
TrainInfo train = trains.get(trainID);
MboBlock block = getBlockFromCoordinates(train.getPosition());
ArrayList<MboBlock> line;
if (block.getLine().equals("red")) {
line = redLine;
} else {
line = greenLine;
}
// get displacement into block. this is positive from the start of the block's coordinate list
int blockIndex = line.indexOf(block);
int blockDisplacement = block.getOffset(train.getPosition());
// calculate the safe braking distance by determining how far a meter on each block slows the train down
double potentialSpeed = train.getSpeed();
int distance = 0;
while (potentialSpeed > 0) {
int[] blockInfo = getBlockAfterMoving(line, blockIndex, blockDisplacement, distance, train.getDirection());
potentialSpeed = calculateSpeedAfterMeter(potentialSpeed, line.get(blockInfo[0]), blockInfo[1], train.getMass());
distance += 1;
}
return distance;
}
示例10: CanLiga
import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public boolean CanLiga(Forma forma, Linha lin) {
if (forma == null) {
return true;
}
if (super.CanLiga(forma, lin)) {
if (forma instanceof PreAtributo) {
return forma.CanLiga(this, lin);
}
if (forma instanceof PreEntidade) {
ArrayList<Forma> lst = getListaDeFormasLigadasNaoExclusiva(PreEntidade.class);
if (AutoRelacionamento(lst) || getPrincipal() == forma) {
return false;
}
if (isSubComponente()) { //entidade ass.
if (lst.indexOf(forma) > -1) {
return false; //NÃO PODE SER AUTO-REL.
}
} else {
if (lst.indexOf(forma) > -1 && lst.size() > 1) {
return false; //já está ligado e possui outra ligação, por isso não pode ser alto-rel.
}
}
return true;
}
}
return false;
}
示例11: coordinateIndex
import java.util.ArrayList; //导入方法依赖的package包/类
private int coordinateIndex(ArrayList<Coordinate> settlementCoords, Coordinate nukedCoord){
for(Coordinate c : settlementCoords){
if(c.getX() == nukedCoord.getX() && c.getY() == nukedCoord.getY()){
return settlementCoords.indexOf(c);
}
}
return -1;
}
示例12: Nomeie
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* Com base nos nomes dos objetos traduzidos nos arq. de confg. nomeia os objetos no ato de criação.
*
* @param padrao nome dado por mim
* @return nome traduzido/configurado pelo usuário.
*/
public final String Nomeie(String padrao) {
String txt = Editor.fromConfiguracao.getValor("diagrama." + padrao + ".nome");
int res = 1;
ArrayList<String> txts = new ArrayList<>();
ListaDeItens.stream().filter((el) -> (el instanceof Forma)).map(el -> (Forma) el).forEach(el -> el.EscrevaTexto(txts));
while (txts.indexOf(txt + "_" + res) != -1) {
res++;
}
return txt + "_" + res;
}
示例13: validationSuccess
import java.util.ArrayList; //导入方法依赖的package包/类
private boolean validationSuccess() {
ArrayList typeList = HabitListController.getTypeList();
if(typeList.indexOf(hTitle.getText().toString().trim())!= -1 ){
Toast.makeText(this, "This habit type already exist.",
Toast.LENGTH_SHORT).show();
return false;
}
if (hTitle.getText().toString().isEmpty()) {
Toast.makeText(this, "Please enter a habit name.",
Toast.LENGTH_SHORT).show();
return false;
}
if (hReason.getText().toString().isEmpty()) {
Toast.makeText(this, "Please enter a habit reason.",
Toast.LENGTH_SHORT).show();
return false;
}
if (hDate.getText().toString().trim().length() == 0) {
Toast.makeText(this, "Please enter a start date.",
Toast.LENGTH_SHORT).show();
return false;
}// else {
// Date hDateInput = DateHelpers.formatStringToDate(
// hDate.getText().toString(), "MM/dd/yyyy");
// Date currentDate = DateHelpers.removeTime(new Date());
// if (hDateInput.before(currentDate)) {
// Toast.makeText(this, "Date is in the past, try again.",
// Toast.LENGTH_SHORT).show();
// return false;
// }
// }
return true;
}
示例14: toString
import java.util.ArrayList; //导入方法依赖的package包/类
public String toString() {
StringBuilder result = new StringBuilder();
for (Entry<String, String> entry : this.urlParams.entrySet()) {
if (result.length() > 0) {
result.append("&");
}
result.append((String) entry.getKey());
result.append(SearchCriteria.EQ);
result.append((String) entry.getValue());
}
for (Entry<String, FileWrapper> entry2 : this.fileParams.entrySet()) {
if (result.length() > 0) {
result.append("&");
}
result.append((String) entry2.getKey());
result.append(SearchCriteria.EQ);
result.append("FILE");
}
for (Entry<String, ArrayList<String>> entry3 : this.urlParamsWithArray.entrySet()) {
if (result.length() > 0) {
result.append("&");
}
ArrayList<String> values = (ArrayList) entry3.getValue();
Iterator it = values.iterator();
while (it.hasNext()) {
String value = (String) it.next();
if (values.indexOf(value) != 0) {
result.append("&");
}
result.append((String) entry3.getKey());
result.append(SearchCriteria.EQ);
result.append(value);
}
}
return result.toString();
}
示例15: addNewSuccessor
import java.util.ArrayList; //导入方法依赖的package包/类
private static int addNewSuccessor(AbstractBeginNode newSuccessor, ArrayList<AbstractBeginNode> newSuccessors) {
int index = newSuccessors.indexOf(newSuccessor);
if (index == -1) {
index = newSuccessors.size();
newSuccessors.add(newSuccessor);
}
return index;
}