当前位置: 首页>>代码示例>>Java>>正文


Java ArrayList.contains方法代码示例

本文整理汇总了Java中java.util.ArrayList.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.contains方法的具体用法?Java ArrayList.contains怎么用?Java ArrayList.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addObserver

import java.util.ArrayList; //导入方法依赖的package包/类
public void addObserver(Object observer, int id) {
    if (Looper.getMainLooper() != Looper.myLooper()){
            throw new RuntimeException("addObserver allowed only from MAIN thread");
    }

    if (broadcasting != 0) {
        ArrayList<Object> arrayList = addAfterBroadcast.get(id);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            addAfterBroadcast.put(id, arrayList);
        }
        arrayList.add(observer);
        return;
    }
    ArrayList<Object> objects = observers.get(id);
    if (objects == null) {
        observers.put(id, (objects = new ArrayList<>()));
    }
    if (objects.contains(observer)) {
        return;
    }
    objects.add(observer);
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:24,代码来源:NotificationCenter.java

示例2: searchEmoticons

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Get all the emoticons that matches has the search tag starting from search query.
 * If the icon for the emoticon is supported by the emoticon provider then, that emoticon will
 * be added to list.
 *
 * @param searchQuery      Search string.
 * @param emoticonProvider {@link EmoticonProvider} or null for system emoticons.
 * @return List of all the supported emoticons for given emoticon icon pack.
 * @see com.kevalpatel2106.emoticongifkeyboard.emoticons.EmoticonProvider#hasEmoticonIcon(String)
 */
@NonNull
ArrayList<Emoticon> searchEmoticons(@NonNull final String searchQuery,
                                    @Nullable EmoticonProvider emoticonProvider) {
    SQLiteDatabase sqLiteDatabase = getReadableDatabase();
    Cursor cursor = sqLiteDatabase.query(EmoticonTagsColumns.TABLE,
            new String[]{EmoticonTagsColumns.UNICODE},      //Unicode.
            EmoticonTagsColumns.TAG + " LIKE ?", new String[]{searchQuery.trim() + "%"}, //Search for the tag
            null, null, null);

    ArrayList<Emoticon> emoticons = new ArrayList<>();
    while (cursor.moveToNext()) {
        String unicode = cursor.getString(cursor.getColumnIndex(EmoticonTagsColumns.UNICODE));

        //Check if there is icon available to display for custom emoticon page.
        if (emoticonProvider == null || emoticonProvider.hasEmoticonIcon(unicode)) {
            Emoticon emoticon = new Emoticon(unicode);
            if (!emoticons.contains(emoticon))  //Prevent duplicates.
                emoticons.add(new Emoticon(unicode));
        }
    }
    cursor.close();
    sqLiteDatabase.close();
    return emoticons;
}
 
开发者ID:kevalpatel2106,项目名称:EmoticonGIFKeyboard,代码行数:35,代码来源:EmoticonDbHelper.java

示例3: execute

import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public void execute(ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    if (params.isEmpty())
    {
        sendCmdHelp(sender);
        return;
    }

    ArrayList<String> commands = WorldBorder.COMMAND.getCommandNames();
    for (String param : params)
        if (commands.contains(param.toLowerCase()))
        {
            WorldBorder.COMMAND.subCommands.get(param.toLowerCase()).sendCmdHelp(sender);
            return;
        }

    sendErrorAndHelp(sender, "No command recognized.");
}
 
开发者ID:abused,项目名称:World-Border,代码行数:20,代码来源:CmdHelp.java

示例4: getSumSources

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * This method is used to when iMarker has marker type and we want to find it's sources both have
 * marker type or not.
 *
 * @param iMarker
 * @return
 */
public static ArrayList<IMarker> getSumSources(IMarker iMarker) {
  iMarker = MarkUtilities.getLeaderOfMarker(iMarker);

  final Map<IMarker, String> sourcesMap = AlloyUtilities.getRelationsOfSecondSideMarker(iMarker);
  final ArrayList<IMarker> sourcesList = AlloyUtilities.getSourcesOfMarkerAtRelations(iMarker);

  final ArrayList<IMarker> resultList = new ArrayList<>(sourcesList);

  final Set<IMarker> sourceMarkers = sourcesMap.keySet();
  final Iterator<IMarker> iter = sourceMarkers.iterator();
  while (iter.hasNext()) {
    final IMarker iMarkerSet = iter.next();
    if (!sourcesList.contains(iMarkerSet)) {
      resultList.add(iMarkerSet);
    }
  }
  return resultList;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:26,代码来源:AlloyUtilities.java

示例5: saveShareAppIndexs2Sp

import java.util.ArrayList; //导入方法依赖的package包/类
public static void saveShareAppIndexs2Sp(List<ResolveInfoWrap> list, Context context) {
    ArrayList<String> string = new ArrayList<>();
    for (ResolveInfoWrap resolveInfoWrap : list) {
        String name =resolveInfoWrap.resolveInfo.loadLabel(context.getPackageManager()).toString();
        if(!string.contains(name))
            string.add(name);
    }
    context.getSharedPreferences(ShareAppManagerActivity.SHARE_APPS, Context.MODE_PRIVATE).edit().
            putString(ConstantUtil.SHARE_APP_INDEX, new Gson().toJson(string)).apply();
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:11,代码来源:SharedIntentHelper.java

示例6: convert

import java.util.ArrayList; //导入方法依赖的package包/类
public void convert(JSONObject temp){


        ArrayList<String> keySet = AdditionalFunc.getKeySet(temp.keys());

        try {

            if(keySet.contains("code")){
                code = (String) temp.get("code");
            }
            if(keySet.contains("ingredient")){
                ingredient = (String) temp.get("ingredient");
            }
            if(keySet.contains("classification")){
                classification = (String) temp.get("classification");
            }
            if(keySet.contains("url")){
                url = (String) temp.get("url");
            }
            if(keySet.contains("usage_capacity")){
                usageCapacity = (String) temp.get("usage_capacity");
            }

        }catch (Exception e){
            e.printStackTrace();
        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:29,代码来源:MedicineDetail.java

示例7: removeDuplicates

import java.util.ArrayList; //导入方法依赖的package包/类
private List<ACL> removeDuplicates(List<ACL> acl) {

        ArrayList<ACL> retval = new ArrayList<ACL>();
        Iterator<ACL> it = acl.iterator();
        while (it.hasNext()) {
            ACL a = it.next();
            if (retval.contains(a) == false) {
                retval.add(a);
            }
        }
        return retval;
    }
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:13,代码来源:PrepRequestProcessor.java

示例8: convert

import java.util.ArrayList; //导入方法依赖的package包/类
public void convert(JSONObject temp){


        ArrayList<String> keySet = AdditionalFunc.getKeySet(temp.keys());

        try {

            if(keySet.contains("medicine_id")){
                id = (String) temp.get("medicine_id");
            }
            if(keySet.contains("medicine_type")){
                type = (String) temp.get("medicine_type");
            }
            if(keySet.contains("medicine_code")){
                code = (String) temp.get("medicine_code");
            }
            if(keySet.contains("medicine_name")){
                name = (String) temp.get("medicine_name");
            }
            if(keySet.contains("medicine_company")){
                company = (String) temp.get("medicine_company");
            }
            if(keySet.contains("medicine_standard")){
                standard = (String) temp.get("medicine_standard");
            }
            if(keySet.contains("medicine_unit")){
                unit = (String) temp.get("medicine_unit");
            }

        }catch (Exception e){
            e.printStackTrace();
        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:35,代码来源:Medicine.java

示例9: destroyAll

import java.util.ArrayList; //导入方法依赖的package包/类
public static void destroyAll(){
	ArrayList<Shader> checks = new ArrayList<Shader>();
	//clear the objects
	for(Shader shader : shaders.values()){
		if(!checks.contains(shader)){
			shader.destroy();
			checks.add(shader);
		}
	}
	
	//clear out all of the objects
	checks.clear();
	shaders.clear();
}
 
开发者ID:tek256,项目名称:LD38,代码行数:15,代码来源:Shader.java

示例10: getCleanTags

import java.util.ArrayList; //导入方法依赖的package包/类
public static String getCleanTags(String commaSepTags, boolean sort) {
  if (commaSepTags == null || commaSepTags.isEmpty()) {
    return commaSepTags;
  }
  String[] tagsA = commaSepTags.split(",");
  if (tagsA == null || tagsA.length == 0) {
    return commaSepTags.trim();
  }
  if (sort) {
    Arrays.sort(tagsA, new TagUtil.TagComparator());
  }
  String tTags = "";
  ArrayList<String> tagsL = new ArrayList<String>();
  ArrayList<String> dedupL = new ArrayList<String>();
  for (int i = 0; i < tagsA.length; i++) {
    if (!dedupL.contains(tagsA[i].toLowerCase())) {
      tagsL.add(tagsA[i]);
      dedupL.add(tagsA[i].toLowerCase());
      if (i != 0) {
        tTags += ",";
      }
      tTags += tagsA[i].trim();
    }
  }

  return tTags;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:28,代码来源:TagUtil.java

示例11: GetPepAbundanceByTopCorrFragAcrossSample

import java.util.ArrayList; //导入方法依赖的package包/类
public float GetPepAbundanceByTopCorrFragAcrossSample(ArrayList<String> PepFrag) {
    float totalabundance = 0f;
    int count = 0;
    if (PepFrag != null && FragmentPeaks != null) {
        for (FragmentPeak frag : FragmentPeaks) {
            if (PepFrag.contains(frag.GetFragKey())) {
                totalabundance += frag.intensity;
                count++;
            }
        }
    }
    return totalabundance;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:14,代码来源:PepIonID.java

示例12: ArmorStandGreef

import java.util.ArrayList; //导入方法依赖的package包/类
@EventHandler
public void ArmorStandGreef(PlayerArmorStandManipulateEvent e){
	if(e.getRightClicked() instanceof ArmorStand){
		ArmorStand clickedA = (ArmorStand) e.getRightClicked();
		if(clickedA.getPassenger() == null){
			ArrayList<ArmorStand> all_main_seats = new ArrayList<ArmorStand>();
			for(attractie att : Main.r.Attracties.values()){
				all_main_seats.addAll(att.getMainSeats());
			}
			if(all_main_seats.contains(clickedA)){
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:LimitedDani,项目名称:Achtbaan,代码行数:16,代码来源:EntityClick_Listener.java

示例13: SplitDiscreteData

import java.util.ArrayList; //导入方法依赖的package包/类
private void SplitDiscreteData(ArrayList<double[]> parentDataList, ArrayList<double[]> leftDataList, ArrayList<double[]> rightDataList, ArrayList<Double> splitValueList, int attrIndex)
{
    leftDataList.clear();
    rightDataList.clear();
    double checkAttribute = 0;
    for(int i=0; i<parentDataList.size(); i++)
    {
        checkAttribute = parentDataList.get(i)[attrIndex];
        if(splitValueList.contains(checkAttribute))
            leftDataList.add(parentDataList.get(i));
        else
            rightDataList.add(parentDataList.get(i));
    }
}
 
开发者ID:YubinXieSYSU,项目名称:m6ASNP,代码行数:15,代码来源:Tree.java

示例14: getIssueUsersExceptMe

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<String> getIssueUsersExceptMe(){
    if(timeline == null) return null;
    ArrayList<String> users = new ArrayList<String>();
    for(IssueEvent event : timeline){
        if(!AppData.INSTANCE.getLoggedUser().getLogin().equals(event.getUser().getLogin())
                && !users.contains(event.getUser().getLogin())){
            users.add(event.getUser().getLogin());
        }
    }
    return users;
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:12,代码来源:IssueTimelinePresenter.java

示例15: getSuccessors

import java.util.ArrayList; //导入方法依赖的package包/类
public List<Node<N, E>> getSuccessors() {
    ArrayList<Node<N, E>> succ = new ArrayList<>();
    for (Edge<N, E> e : getOutEdges()) {
        Node<N, E> n = e.getDest();
        if (!succ.contains(n)) {
            succ.add(n);
        }
    }
    return succ;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:11,代码来源:Node.java


注:本文中的java.util.ArrayList.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。