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


Java ArrayList.removeIf方法代碼示例

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


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

示例1: main

import java.util.ArrayList; //導入方法依賴的package包/類
public static void main(String[] args) {
    ArrayList<String> list = new ArrayList<>(Arrays.asList("I", "love", "you", "too"));

    list.removeIf(new Predicate<String>() {
        @Override
        public boolean test(String s) {
            if (s.length() < 2) {

                return true;
            }
            return false;
        }
    });
    list.removeIf(l -> l.length() < 4);
    System.out.println(JSON.toJSONString(list));
    Date date = new Date();

    ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap<>();
    concurrentHashMap.put("ds", 1);
    concurrentHashMap.computeIfAbsent("fdfd", k -> k.toString());
    System.out.println(JSON.toJSONString(concurrentHashMap));
    HashMap hashMap = new HashMap<>();
    hashMap.put("fd1", 1);
    hashMap.put("fd2", 1);
    hashMap.put("fd3", 1);
    hashMap.put("fd4", "fd");
    hashMap.put("fd5", 1);
    hashMap.entrySet().stream().forEach(hash -> {
        System.out.println(hash.toString());
    });
}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:32,代碼來源:WashMap.java

示例2: getRecipeSlots

import java.util.ArrayList; //導入方法依賴的package包/類
@Override
public List<Slot> getRecipeSlots(ContainerGui container)
{
    ArrayList<Slot> slots = Lists.newArrayList(container.getSlotsForSource(moduleName));
    slots.removeIf(slot -> slot.getSlotIndex() >= inputSlots);
    return slots;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:8,代碼來源:TransferInfo.java

示例3: getPrivateChatsByTraveler

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Get all private chat rooms of a traveler
 *
 * @param travelerId int
 * @return List<ChatRoom>
 */
@RequestMapping(path = "/api/private-chats/list/{travelerId}", method = RequestMethod.GET)
public List<ChatRoom> getPrivateChatsByTraveler(@PathVariable int travelerId) {
	ArrayList<ChatRoom> rooms = chatRoomRepository.getByTravelerId(travelerId);
	rooms.removeIf(c -> !c.isPrivate());
	return rooms;
}
 
開發者ID:trvlrch,項目名稱:trvlr-backend,代碼行數:13,代碼來源:PrivateChatRoomController.java

示例4: getPublicChatsByTraveler

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Get all publich chat rooms of a traveler
 *
 * @param travelerId int
 * @return List<ChatRoom>
 */
@RequestMapping(path = "/api/public-chats/list/{travelerId}", method = RequestMethod.GET)
public List<ChatRoom> getPublicChatsByTraveler(@PathVariable int travelerId) {
	ArrayList<ChatRoom> rooms = chatRoomRepository.getByTravelerId(travelerId);
	rooms.removeIf(ChatRoom::isPrivate);
	return rooms;
}
 
開發者ID:trvlrch,項目名稱:trvlr-backend,代碼行數:13,代碼來源:PublicChatRoomController.java

示例5: apply

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 <hr>
 <h2>Applies this Rule on the Context param</h2>
 <h3>
 — A Person that didn't reach minium age can't get in couple <br>
 — A Person that already is in couple, can't get in couple with someone else <br>
 — 2 People have to <code>match</code> to get in couple <br>
 See {@link CoupleRule#isMatch(Person, Person)}</h3>
 <hr>
 <h3>
 Created : Alexandre Bolot 10/01 <br>
 Modified : Alexandre Bolot 14/01
 </h3>
 <hr>

 @param context Context to apply this rule onto
 */
@Contract ("null -> fail")
public void apply (@NotNull Context context)
{
    //region --> Check params
    if (context == null) throw new IllegalArgumentException("Contect param is null");
    //endregion

    ArrayList<Person> tmpPeople = new ArrayList<>(context.people());
    if (minimumAge != anyAge) tmpPeople.removeIf(person -> person.data().age() < minimumAge);
    tmpPeople.removeIf(person -> context.relations().stream().anyMatch(relation -> relation.involves(person)));

    for (Person person1 : tmpPeople)
    {
        for (Person person2 : tmpPeople)
        {
            if (person2.equals(person1)) continue;
            if (context.relations().contains(relation -> relation.involves(person1))) continue;
            if (context.relations().contains(relation -> relation.involves(person2))) continue;

            if (isMatch(person1, person2))
            {
                context.relations().add(new Relation(person1, person2, Couple, currentTime()));
                break;
            }
        }
    }
}
 
開發者ID:AlexBolot,項目名稱:PopulationSimulator,代碼行數:45,代碼來源:CoupleRule.java

示例6: enableOn

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Call this method to re-enable an Activity previously disabled with {@link #disableOn(Class)}.
 * @param activityClass The Activity class
 * @see #disableOn(Class)
 */
public void enableOn(Class<? extends Activity> activityClass) {
    ArrayList<Class<? extends Activity>> disabledActivities = this._DisabledActivities;
    if(disabledActivities != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            disabledActivities.removeIf(c -> c == activityClass);
        } else {
            disabledActivities.remove(activityClass);
        }
    }
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:16,代碼來源:Customerly.java


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