it.unimi.dsi.fastutil.shorts.Short2ObjectMap Java Examples

The following examples show how to use it.unimi.dsi.fastutil.shorts.Short2ObjectMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 6 votes vote down vote up
/**
 * 移除map中符合条件的元素,并对删除的元素执行后续的操作
 *
 * @param map       必须是可修改的map
 * @param predicate 过滤条件,为真的删除
 * @param then      元素删除之后执行的逻辑
 * @param <V>       the type of value
 * @return 删除的元素数量
 */
public static <V> int removeIfAndThen(final Short2ObjectMap<V> map, final ShortObjPredicate<? super V> predicate, ShortObjConsumer<V> then) {
    if (map.size() == 0) {
        return 0;
    }

    ObjectIterator<Short2ObjectMap.Entry<V>> itr = map.short2ObjectEntrySet().iterator();
    int removeNum = 0;
    Short2ObjectMap.Entry<V> entry;
    short k;
    V v;
    while (itr.hasNext()) {
        entry = itr.next();
        k = entry.getShortKey();
        v = entry.getValue();
        if (predicate.test(k, v)) {
            itr.remove();
            removeNum++;
            then.accept(k, v);
        }
    }
    return removeNum;
}
 
Example #2
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 4 votes vote down vote up
public static <V> void requireNotContains(Short2ObjectMap<V> map, short key, String msg) {
    if (map.containsKey(key)) {
        throw new IllegalArgumentException("duplicate " + msg + "-" + key);
    }
}
 
Example #3
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 4 votes vote down vote up
public static <V> void requireContains(Short2ObjectMap<V> map, short key, String msg) {
    if (!map.containsKey(key)) {
        throw new IllegalArgumentException("nonexistent " + msg + "-" + key);
    }
}
 
Example #4
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
ObjectSet<Short2ObjectMap.Entry<String>> getKeyValueEntries() {
  return keyToValue.short2ObjectEntrySet();
}
 
Example #5
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
private Short2ObjectMap<String> keyToValueMap() {
  return keyToValue;
}
 
Example #6
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
ObjectSet<Short2ObjectMap.Entry<String>> getKeyValueEntries() {
  return keyToValue.short2ObjectEntrySet();
}
 
Example #7
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
private Short2ObjectMap<String> keyToValueMap() {
  return keyToValue;
}