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


Java CopyOnWriteArrayList.isEmpty方法代码示例

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


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

示例1: hasSubscriberForEvent

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
public boolean hasSubscriberForEvent(Class<?> eventClass) {
    List<Class<?>> eventTypes = lookupAllEventTypes(eventClass);
    if (eventTypes != null) {
        int countTypes = eventTypes.size();
        for (int h = 0; h < countTypes; h++) {
            Class<?> clazz = eventTypes.get(h);
            CopyOnWriteArrayList<Subscription> subscriptions;
            synchronized (this) {
                subscriptions = subscriptionsByEventType.get(clazz);
            }
            if (subscriptions != null && !subscriptions.isEmpty()) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:EventBus.java

示例2: postSingleEventForEventType

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
private boolean postSingleEventForEventType(Object event, PostingThreadState postingState, Class<?> eventClass) {
    CopyOnWriteArrayList<Subscription> subscriptions;
    synchronized (this) {
        subscriptions = subscriptionsByEventType.get(eventClass);
    }
    if (subscriptions != null && !subscriptions.isEmpty()) {
        for (Subscription subscription : subscriptions) {
            postingState.event = event;
            postingState.subscription = subscription;
            boolean aborted = false;
            try {
                postToSubscription(subscription, event, postingState.isMainThread);
                aborted = postingState.canceled;
            } finally {
                postingState.event = null;
                postingState.subscription = null;
                postingState.canceled = false;
            }
            if (aborted) {
                break;
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:EventBus.java

示例3: removeCharacteristicsChangedListener

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
@Override
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public void removeCharacteristicsChangedListener(UUID characteristicsUUID, CharacteristicsChangedListener listener) {
    boolean checkIdle;
    synchronized (lock) {
        CopyOnWriteArrayList<CharacteristicsChangedListener> list = changeListeners.get(characteristicsUUID);
        if (list != null) {
            list.remove(listener);
            if (list.isEmpty()) {
                changeListeners.remove(characteristicsUUID);
            }
        }
        checkIdle = currentCallback == DO_NOTHING_CALLBACK && queue.isEmpty() && queue.isEmpty();
    }
    if (checkIdle) {
        disconnectOnIdle();
    }
}
 
开发者ID:inovait,项目名称:neatle,代码行数:19,代码来源:Device.java

示例4: getSuggestions

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final ComposedData composedData,
        final NgramContext ngramContext, final long proximityInfoHandle,
        final SettingsValuesForSuggestion settingsValuesForSuggestion,
        final int sessionId, final float weightForLocale,
        final float[] inOutWeightOfLangModelVsSpatialModel) {
    final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries;
    if (dictionaries.isEmpty()) return null;
    // To avoid creating unnecessary objects, we get the list out of the first
    // dictionary and add the rest to it if not null, hence the get(0)
    ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composedData,
            ngramContext, proximityInfoHandle, settingsValuesForSuggestion, sessionId,
            weightForLocale, inOutWeightOfLangModelVsSpatialModel);
    if (null == suggestions) suggestions = new ArrayList<>();
    final int length = dictionaries.size();
    for (int i = 1; i < length; ++ i) {
        final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(
                composedData, ngramContext, proximityInfoHandle, settingsValuesForSuggestion,
                sessionId, weightForLocale, inOutWeightOfLangModelVsSpatialModel);
        if (null != sugg) suggestions.addAll(sugg);
    }
    return suggestions;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:DictionaryCollection.java

示例5: postSingleEventForEventType

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
private boolean postSingleEventForEventType(String tag, Object event, PostingThreadState postingState, Class<?> eventClass) {
    CopyOnWriteArrayList<Subscription> subscriptions;
    synchronized (this) {
        subscriptions = subscriptionsByEventType.get(eventClass);
    }
    if (subscriptions != null && !subscriptions.isEmpty()) {
        for (Subscription subscription : subscriptions) {
            postingState.event = event;
            postingState.subscription = subscription;
            boolean aborted = false;
            try {
                if (TextUtils.isEmpty(tag)) tag = DEFAULT_TAG;
                if (tag.equals(subscription.subscriberMethod.tag)) {
                    postToSubscription(subscription, event, postingState.isMainThread);
                } else {
                    Log.d("EventBus", "当前指定的Tag未找到");
                }
                aborted = postingState.canceled;
            } finally {
                postingState.event = null;
                postingState.subscription = null;
                postingState.canceled = false;
            }
            if (aborted) {
                break;
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:32,代码来源:EventBus.java

示例6: postSingleEventForEventType

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
/**
 * 找出所有订阅了eventClass事件的订阅者,并回调订阅者的响应方法
 *
 * @param event        要响应的事件
 * @param postingState 事件发送过程所需数据的封装
 * @param eventClass   响应的事件类型(也可能是event的父类类型)
 * @return 如果eventClass事件没有订阅者, 返回false
 */
private boolean postSingleEventForEventType(Object event, PostingThreadState postingState,
                                            Class<?> eventClass) {
    CopyOnWriteArrayList<Subscription> subscriptions;
    synchronized (this) {
        //所有订阅了eventClass的事件集合
        subscriptions = subscriptionsByEventType.get(eventClass);
    }
    if (subscriptions != null && !subscriptions.isEmpty()) {
        //回调subscription的响应方法
        for (Subscription subscription : subscriptions) {
            postingState.event = event;
            postingState.subscription = subscription;
            boolean aborted = false;
            try {
                postToSubscription(subscription, event, postingState.isMainThread);
                aborted = postingState.canceled;
            } finally {
                postingState.event = null;
                postingState.subscription = null;
                postingState.canceled = false;
            }
            if (aborted) {
                break;
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:kymjs,项目名称:Chidori,代码行数:38,代码来源:EventBus.java

示例7: postSingleEventForEventType

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
private boolean postSingleEventForEventType(Object event, PostingThreadState postingState, Class<?> eventClass) {
    synchronized (this) {
        CopyOnWriteArrayList<Subscription> subscriptions = (CopyOnWriteArrayList) this.subscriptionsByEventType.get(eventClass);
    }
    if (subscriptions == null || subscriptions.isEmpty()) {
        return false;
    }
    Iterator i$ = subscriptions.iterator();
    loop0:
    while (i$.hasNext()) {
        Subscription subscription = (Subscription) i$.next();
        postingState.event = event;
        postingState.subscription = subscription;
        boolean z = false;
        try {
            postToSubscription(subscription, event, postingState.isMainThread);
            z = postingState.canceled;
            continue;
        } finally {
            postingState.event = null;
            postingState.subscription = null;
            postingState.canceled = false;
        }
        if (z) {
            break loop0;
        }
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:30,代码来源:EventBus.java

示例8: getContentByCourse

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
/**
 * Method to get all contents of a given course.
 */
@SuppressWarnings("unchecked")
private Response getContentByCourse(String userId, Map<String, Object> request) {

  Response response = null;
  Util.DbInfo dbInfo = Util.dbInfoMap.get(JsonKey.LEARNER_CONTENT_DB);

  if (request.get(JsonKey.COURSE) != null) {
    Map<String, Object> courseMap = (Map<String, Object>) request.get(JsonKey.COURSE);
    String courseId = (String) courseMap.get(JsonKey.COURSE_ID);
    CopyOnWriteArrayList<String> contentIds =
        new CopyOnWriteArrayList<String>((List<String>) courseMap.get(JsonKey.CONTENT_IDS));
    LinkedHashMap<String, Object> queryMap = new LinkedHashMap<String, Object>();
    queryMap.put(JsonKey.USER_ID, userId);
    queryMap.put(JsonKey.COURSE_ID, courseId);
    response = cassandraOperation.getRecordsByProperties(dbInfo.getKeySpace(),
        dbInfo.getTableName(), queryMap);
    List<Map<String, Object>> modifiedContentList = new ArrayList<Map<String, Object>>();
    List<Map<String, Object>> resultedList =
        (List<Map<String, Object>>) response.getResult().get(JsonKey.RESPONSE);

    if (null != contentIds && !(contentIds.isEmpty())) {

      for (Map<String, Object> map : resultedList) {
        boolean flag = true;
        for (int i = 0; i < contentIds.size() && flag; i++) {
          String contentId = contentIds.get(i);
          if (contentId.equals((String) map.get(JsonKey.CONTENT_ID))) {
            modifiedContentList.add(map);
            flag = false;
          }
        }
      }
      response.getResult().put(JsonKey.RESPONSE, modifiedContentList);
    }
  }
  return response;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:41,代码来源:LearnerStateActor.java


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