當前位置: 首頁>>代碼示例>>Java>>正文


Java List.indexOf方法代碼示例

本文整理匯總了Java中java.util.List.indexOf方法的典型用法代碼示例。如果您正苦於以下問題:Java List.indexOf方法的具體用法?Java List.indexOf怎麽用?Java List.indexOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.indexOf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: computeAdjacencyMatrix

import java.util.List; //導入方法依賴的package包/類
/**
 *
 *
 */
public boolean[][] computeAdjacencyMatrix(int upperLayerIndex) {
    List<Vertex> upperLayer = layers.get(upperLayerIndex);
    List<Vertex> lowerLayer = layers.get(upperLayerIndex+1);
    int upperLayerSize = upperLayer.size();
    int lowerLayerSize = lowerLayer.size();
    
    boolean[][] matrix = new boolean[upperLayerSize][lowerLayerSize];
    
    for (int j = 0; j < upperLayerSize; j++) {
        Vertex v = upperLayer.get(j);
        if (v != null) {
            Collection<Vertex> vertices = v.getLowerNeighbors();
            for (Vertex nv : vertices) {
                int k = lowerLayer.indexOf(nv);
                
                if (k > -1) {
                    matrix[j][k] = true;
                    //System.out.println(j + "," + k + " is set");
                }
            }
        }
    }
    
    return matrix;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:LayeredGraph.java

示例2: syncPreviews

import java.util.List; //導入方法依賴的package包/類
@Override
public void syncPreviews(List<PreviewViewModel> previews) {
    List<PreviewViewModel> reversedPreviews = Lists.reverse(Optional
                    .fromNullable(previews)
                    .or(new ArrayList<PreviewViewModel>(0)));

    for (PreviewViewModel vm : reversedPreviews) {
        EditTodoListInteractor interactor = new EditTodoListInteractorImpl(
                mExecutor,
                mMainThread,
                this,
                repository,
                vm.getUuid(),
                vm.getTitle(),
                reversedPreviews.indexOf(vm)
        );
        interactor.execute();
    }
}
 
開發者ID:djuelg,項目名稱:Neuronizer,代碼行數:20,代碼來源:DisplayPreviewPresenterImpl.java

示例3: onScoreboardInit

import java.util.List; //導入方法依賴的package包/類
@EventHandler
public void onScoreboardInit(ScoreboardInitEvent event) {
    List<MatchTeam> teams = TGM.get().getModule(TeamManagerModule.class).getTeams();

    SimpleScoreboard simpleScoreboard = event.getSimpleScoreboard();

    int i = 0;
    for (MatchTeam matchTeam : teams) {
        if (matchTeam.isSpectator()) continue;
        simpleScoreboard.add(matchTeam.getColor() + getTeamScoreLine(matchTeam), i);
        teamScoreboardLines.put(matchTeam, i++);
        simpleScoreboard.add(matchTeam.getColor() + matchTeam.getAlias(), i++);
        if (teams.indexOf(matchTeam) < teams.size() - 1) {
            simpleScoreboard.add(matchTeam.getColor() + " ", i++);
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:18,代碼來源:TDMModule.java

示例4: compareTo

import java.util.List; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int compareTo(UnitWas uw) {
    // Order by decreasing capacity of the location the unit is to
    // be moved to, so that if we traverse a sorted list of
    // UnitWas we minimize the chance of a unit being moved to a
    // full location.
    //
    // Unfortunately this also tends to move units that need
    // equipment first, leading to failures to rearm, so it is
    // best to make two passes anyway.  See revertAll().  However
    // we can still try our best by using the amount of equipment
    // the unit needs as a secondary criterion (favouring the
    // least equipped).
    List<Role> roles = this.unit.getAvailableRolesList(null);
    int cmp = ((UnitLocation)uw.loc).getUnitCapacity()
        - ((UnitLocation)this.loc).getUnitCapacity();
    if (cmp == 0) {
        cmp = roles.indexOf(this.role) - roles.indexOf(uw.role);
    }
    return cmp;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:25,代碼來源:UnitWas.java

示例5: insertOrderedComponent

import java.util.List; //導入方法依賴的package包/類
private void insertOrderedComponent(UIComponent component, Long after) {
	List<Long> ordered = orderedComponents.get(0);
	int size = ordered.size();
	
	if (ordered.contains(component.priority))
		return;
	
	if (after == null) {
		after = new Long(0);
		if (size>0)
			after = ordered.get(ordered.size()-1);
	}
	
	int order = ordered.indexOf(after);
	ordered.add(order+1, component.priority);
	hasChanged = true;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:18,代碼來源:UIComponent.java

示例6: getNextColumn

import java.util.List; //導入方法依賴的package包/類
/**
 * getNextColumn: get the next (previous) Column relative to this TableCell.
 *
 * @param forward should it return the next or previous Column?
 * @return next (previous) TableColumn or null if none exists in this row
 */
private TableColumn<S, ?> getNextColumn(boolean forward) {
  List<TableColumn<S, ?>> columns = new ArrayList<>();
  columns.addAll(getTableView().getColumns());

  // There is no other column that supports editing.
  if (columns.size() < 2) {
    return null;
  }
  int currentIndex = columns.indexOf(getTableColumn());
  int nextIndex = currentIndex;
  if (forward) {
    nextIndex++;
    if (nextIndex > columns.size() - 1) {
      return null;
    }
  } else {
    nextIndex--;
    //assumes, that the first column is not editable
    if (nextIndex < 1) {
      return null;
    }
  }
  return columns.get(nextIndex);
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:31,代碼來源:AdvancedTextFieldTableCell.java

示例7: doDelete

import java.util.List; //導入方法依賴的package包/類
/**
 * Perform Delete Operation
 * 
 * @param columnNames
 * @param source
 * @param rowData
 */
private void doDelete(List<String> fileHeader, List<FileRecord> fileRecords,
        final String source) {
    LOGGER.info("Performing Delete Operation - Source: {} | Header: {}",
            source, fileHeader);

    /* Get Index */
    int index = fileHeader.indexOf(source);

    /* Remove Header Entry */
    fileHeader.remove(index);

    /* Remove Records */
    for (final FileRecord fileRecord : fileRecords) {
        fileRecord.getData().remove(index);
    }
}
 
開發者ID:ukubuka,項目名稱:ukubuka-core,代碼行數:24,代碼來源:UkubukaTransformer.java

示例8: addAttributes

import java.util.List; //導入方法依賴的package包/類
public void addAttributes(List<Attribute> sources, Eval eval,
                          List<Attribute> attributes) {
    String[] values = eval.getValues();
    for (Attribute attribute : attributes) {
        if (sources.indexOf(attribute) < 0) {
            for (String value : values) {
                if (getAttributeEId(attribute.getId()).equals(value)) {
                    sources.add(attribute);
                    break;
                }
            }
        }
    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:15,代碼來源:Util.java

示例9: moveRight

import java.util.List; //導入方法依賴的package包/類
/**
 * This method does the same as {@link #moveLeft(int, Object, List)} but it moves the specified element
 * to the right instead of the left.
 */
public static <T> List<T> moveRight(int offset, T element, List<T> list)
{
    final int elementIndex = list.indexOf(element);
    
    if (elementIndex == -1) { throw new NoSuchElementException("Element not found in provided list."); }
    
    if (offset == 0)
    {
        return list;
    }
    else
    {
        int newElementIndex = elementIndex + offset;
        
        // Ensure that the element will not move off the end of the list.
        if      (newElementIndex >= list.size()) { newElementIndex = list.size() - 1; }
        else if (newElementIndex < 0)            { newElementIndex = 0; }
        
        List<T> result = new ArrayList<>(list);
        result.remove(element);
        
        result.add(newElementIndex, element);
        
        return result;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:31,代碼來源:CollectionUtils.java

示例10: buildCellHeight

import java.util.List; //導入方法依賴的package包/類
private int buildCellHeight(Cell cell,List<Row> rows){
	int height=cell.getRow().getRealHeight();
	int rowSpan=cell.getPageRowSpan();
	if(rowSpan>0){
		int pos=rows.indexOf(cell.getRow());
		int start=pos+1,end=start+rowSpan-1;
		for(int i=start;i<end;i++){
			height+=rows.get(i).getRealHeight();
		}
	}
	return height;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:13,代碼來源:PdfProducer.java

示例11: getOrder

import java.util.List; //導入方法依賴的package包/類
/**
 * Get representation of order for quick sort of a given database object.
 */
@Override
public Object getOrder(Object object) throws EngineException	{
    if (object instanceof Step) {
    	List<Long> ordered = orderedSteps.get(0);
    	long time = ((Step)object).priority;
    	if (ordered.contains(time))
    		return (long)ordered.indexOf(time);
    	else throw new EngineException("Corrupted step for StepWithExpressions \""+ getName() +"\". Step \""+ ((Step)object).getName() +"\" with priority \""+ time +"\" isn't referenced anymore.");
    } else return super.getOrder(object);
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:14,代碼來源:StepWithExpressions.java

示例12: calculateToolbarIndex

import java.util.List; //導入方法依賴的package包/類
public int calculateToolbarIndex ( final ViewInstanceDescriptor descriptor )
{
    if ( !isMain ( descriptor ) )
    {
        logger.debug ( "Has parent: {}", descriptor );
        return -1;
    }

    final List<ViewInstanceDescriptor> data = new ArrayList<ViewInstanceDescriptor> ( this.visibleDescriptors );

    // remove all views with a parent
    final Iterator<ViewInstanceDescriptor> i = data.iterator ();
    while ( i.hasNext () )
    {
        if ( !isMain ( i.next () ) )
        {
            logger.debug ( "{} has parent, remove: ", descriptor );
            i.remove ();
        }
    }

    data.add ( descriptor );
    Collections.sort ( data, ViewInstanceDescriptor.DESCRIPTOR_ORDER_COMPARATOR );

    logger.debug ( "Sort order: {}", data );

    final int result = data.indexOf ( descriptor );
    logger.debug ( "Index is: {}", result );
    return result;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:31,代碼來源:ToolBarNavigator.java

示例13: getOrder

import java.util.List; //導入方法依賴的package包/類
/**
    * Get representation of order for quick sort of a given database object.
    */
@Override
   public Object getOrder(Object object) throws EngineException	{
       if (object instanceof Variable) {
       	List<Long> ordered = orderedVariables.get(0);
       	long time = ((Variable)object).priority;
       	if (ordered.contains(time))
       		return (long)ordered.indexOf(time);
       	else throw new EngineException("Corrupted variable for test case \""+ getName() +"\". Variable \""+ ((Variable)object).getName() +"\" with priority \""+ time +"\" isn't referenced anymore.");
       }
       else return super.getOrder(object);
   }
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:15,代碼來源:TestCase.java

示例14: allocate

import java.util.List; //導入方法依賴的package包/類
@Override
public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
    List<String> cidAll) {
    List<MessageQueue> result = new ArrayList<MessageQueue>();
    int currentIndex = cidAll.indexOf(currentCID);
    if (currentIndex < 0) {
        return result;
    }
    List<MessageQueue> premqAll = new ArrayList<MessageQueue>();
    for (MessageQueue mq : mqAll) {
        String[] temp = mq.getBrokerName().split("@");
        if (temp.length == 2 && consumeridcs.contains(temp[0])) {
            premqAll.add(mq);
        }
    }

    int mod = premqAll.size() / cidAll.size();
    int rem = premqAll.size() % cidAll.size();
    int startIndex = mod * currentIndex;
    int endIndex = startIndex + mod;
    for (int i = startIndex; i < endIndex; i++) {
        result.add(mqAll.get(i));
    }
    if (rem > currentIndex) {
        result.add(premqAll.get(currentIndex + mod * cidAll.size()));
    }
    return result;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:29,代碼來源:AllocateMessageQueueByMachineRoom.java

示例15: canMoveDown

import java.util.List; //導入方法依賴的package包/類
protected boolean canMoveDown()
{
    List<ResourcePackListEntry> list = this.resourcePacksGUI.getListContaining(this);
    int i = list.indexOf(this);
    return i >= 0 && i < list.size() - 1 && ((ResourcePackListEntry)list.get(i + 1)).showHoverOverlay();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:7,代碼來源:ResourcePackListEntry.java


注:本文中的java.util.List.indexOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。