当前位置: 首页>>代码示例>>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;未经允许,请勿转载。