當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。