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


Java SortedMap.size方法代码示例

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


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

示例1: testTailMapClearThrough

import java.util.SortedMap; //导入方法依赖的package包/类
public void testTailMapClearThrough() {
  final SortedMap<K, V> map;
  try {
    map = makePopulatedMap();
  } catch (UnsupportedOperationException e) {
    return;
  }
  int oldSize = map.size();
  if (map.size() < 2 || !supportsClear) {
    return;
  }
  Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
  iterator.next(); // advance
  Entry<K, V> secondEntry = iterator.next();
  K key = secondEntry.getKey();
  SortedMap<K, V> subMap = map.tailMap(key);
  int subMapSize = subMap.size();
  subMap.clear();
  assertEquals(map.size(), oldSize - subMapSize);
  assertTrue(subMap.isEmpty());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:22,代码来源:SortedMapInterfaceTest.java

示例2: testTailMapWriteThrough

import java.util.SortedMap; //导入方法依赖的package包/类
public void testTailMapWriteThrough() {
  final SortedMap<K, V> map;
  try {
    map = makePopulatedMap();
  } catch (UnsupportedOperationException e) {
    return;
  }
  if (map.size() < 2 || !supportsPut) {
    return;
  }
  Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
  Entry<K, V> firstEntry = iterator.next();
  Entry<K, V> secondEntry = iterator.next();
  K key = secondEntry.getKey();
  SortedMap<K, V> subMap = map.tailMap(key);
  V value = getValueNotInPopulatedMap();
  subMap.put(key, value);
  assertEquals(secondEntry.getValue(), value);
  assertEquals(map.get(key), value);
  try {
    subMap.put(firstEntry.getKey(), value);
    fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException expected) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:SortedMapInterfaceTest.java

示例3: UnicodeLocaleExtension

import java.util.SortedMap; //导入方法依赖的package包/类
UnicodeLocaleExtension(SortedSet<String> attributes, SortedMap<String, String> keywords) {
    this();
    if (attributes != null && attributes.size() > 0) {
        _attributes = attributes;
    }
    if (keywords != null && keywords.size() > 0) {
        _keywords = keywords;
    }

    if (_attributes.size() > 0 || _keywords.size() > 0) {
        StringBuilder sb = new StringBuilder();
        for (String attribute : _attributes) {
            sb.append(LanguageTag.SEP).append(attribute);
        }
        for (Entry<String, String> keyword : _keywords.entrySet()) {
            String key = keyword.getKey();
            String value = keyword.getValue();

            sb.append(LanguageTag.SEP).append(key);
            if (value.length() > 0) {
                sb.append(LanguageTag.SEP).append(value);
            }
        }
        _value = sb.substring(1);   // skip leading '-'
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:UnicodeLocaleExtension.java

示例4: getHotspotsInfoByNum

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * 获取轮子中最接近key中第num个热点
 *
 * @param key
 * @param num
 * @return
 */
public T getHotspotsInfoByNum(String key, int num) {
    // 沿环的顺时针找到一个虚拟节点。
    SortedMap<Long, T> tail = nodes.tailMap(HashingUtils.hash(key));
    if (tail.size() == 0) {
        return nodes.get(nodes.firstKey());
    }
    int i = 1;
    for (T entry : tail.values()) {
        if (i == num) {
            return entry;
        }
        i++;
    }
    return tail.get(tail.firstKey()); // 返回该虚拟节点对应的真实缓存对象节点的信息
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:23,代码来源:HashWheel.java

示例5: getPreProvisioningLsp

import java.util.SortedMap; //导入方法依赖的package包/类
public static RsvpLspDto getPreProvisioningLsp(RsvpLspDto lsp) {
    if (lsp == null) {
        return null;
    }

    try {
        NaefDtoFacade dtofacade = InventoryConnector.getInstance().getDtoFacade();
        SortedMap<TransactionId.W, DateTime> enabledTimeHistory
                = dtofacade.getAttributeHistory(DtoUtil.getMvoId(lsp), ATTR.TASK_ENABLED_TIME);
        TransactionId.W lastProvisioningVersion
                = enabledTimeHistory.size() == 0
                ? null
                : enabledTimeHistory.lastKey();
        if (lastProvisioningVersion == null) {
            return null;
        }

        TransactionId.W tickBefore = new TransactionId.W(lastProvisioningVersion.serial - 1);
        RsvpLspDto oldVersionLsp
                = (RsvpLspDto) dtofacade.getMvoDto(DtoUtil.getMvoId(lsp), tickBefore);
        return oldVersionLsp;
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:26,代码来源:RsvpLspExtUtil.java

示例6: createSwitch

import java.util.SortedMap; //导入方法依赖的package包/类
private static IntegerSwitchNode createSwitch(ValuePhiNode switchedValue, SortedMap<Integer, AbstractBeginNode> dispatchTable, AbstractBeginNode defaultSuccessor) {
    int numKeys = dispatchTable.size();
    int numSuccessors = numKeys + 1;

    AbstractBeginNode[] switchSuccessors = new AbstractBeginNode[numSuccessors];
    int[] switchKeys = new int[numKeys];
    double[] switchKeyProbabilities = new double[numSuccessors];
    int[] switchKeySuccessors = new int[numSuccessors];

    int idx = 0;
    for (Map.Entry<Integer, AbstractBeginNode> entry : dispatchTable.entrySet()) {
        switchSuccessors[idx] = entry.getValue();
        switchKeys[idx] = entry.getKey();
        switchKeyProbabilities[idx] = 1d / numKeys;
        switchKeySuccessors[idx] = idx;
        idx++;
    }
    switchSuccessors[idx] = defaultSuccessor;
    /* We know the default branch is never going to be executed. */
    switchKeyProbabilities[idx] = 0;
    switchKeySuccessors[idx] = idx;

    return new IntegerSwitchNode(switchedValue, switchSuccessors, switchKeys, switchKeyProbabilities, switchKeySuccessors);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:GraphDecoder.java

示例7: ImmutableDescriptor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * <p>Construct a descriptor where the names and values of the fields
 * are the keys and values of the given Map.</p>
 *
 * @throws IllegalArgumentException if the parameter is null, or
 * if a field name is null or empty, or if the same field name appears
 * more than once (which can happen because field names are not case
 * sensitive).
 */
public ImmutableDescriptor(Map<String, ?> fields) {
    if (fields == null)
        throw new IllegalArgumentException("Null Map");
    SortedMap<String, Object> map =
            new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (Map.Entry<String, ?> entry : fields.entrySet()) {
        String name = entry.getKey();
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Empty or null field name");
        if (map.containsKey(name))
            throw new IllegalArgumentException("Duplicate name: " + name);
        map.put(name, entry.getValue());
    }
    int size = map.size();
    this.names = map.keySet().toArray(new String[size]);
    this.values = map.values().toArray(new Object[size]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:ImmutableDescriptor.java

示例8: ImmutableDescriptor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * <p>Construct a descriptor where the names and values of the fields
 * are the keys and values of the given Map.</p>
 *
 * @param fields the field names and values
 * @throws IllegalArgumentException if the parameter is null, or
 * if a field name is null or empty, or if the same field name appears
 * more than once (which can happen because field names are not case
 * sensitive).
 */
public ImmutableDescriptor(Map<String, ?> fields) {
    if (fields == null)
        throw new IllegalArgumentException("Null Map");
    SortedMap<String, Object> map =
            new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (Map.Entry<String, ?> entry : fields.entrySet()) {
        String name = entry.getKey();
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Empty or null field name");
        if (map.containsKey(name))
            throw new IllegalArgumentException("Duplicate name: " + name);
        map.put(name, entry.getValue());
    }
    int size = map.size();
    this.names = map.keySet().toArray(new String[size]);
    this.values = map.values().toArray(new Object[size]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ImmutableDescriptor.java

示例9: testTailMapRemoveThrough

import java.util.SortedMap; //导入方法依赖的package包/类
public void testTailMapRemoveThrough() {
  final SortedMap<K, V> map;
  try {
    map = makePopulatedMap();
  } catch (UnsupportedOperationException e) {
    return;
  }
  int oldSize = map.size();
  if (map.size() < 2 || !supportsRemove) {
    return;
  }
  Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
  Entry<K, V> firstEntry = iterator.next();
  Entry<K, V> secondEntry = iterator.next();
  K key = secondEntry.getKey();
  SortedMap<K, V> subMap = map.tailMap(key);
  subMap.remove(key);
  assertNull(subMap.remove(firstEntry.getKey()));
  assertEquals(map.size(), oldSize - 1);
  assertFalse(map.containsKey(key));
  assertEquals(subMap.size(), oldSize - 2);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:23,代码来源:SortedMapInterfaceTest.java

示例10: reloadData

import java.util.SortedMap; //导入方法依赖的package包/类
void reloadData(SortedMap<String, Boolean> items) {
    selected = new Boolean[items.size()];
    items.values().toArray(selected);
    if (originalSelected == null) {
        originalSelected = new Boolean[items.size()];
        System.arraycopy(selected, 0, originalSelected, 0, selected.length);
    }
    pkgNames = new String[items.size()];
    items.keySet().toArray(pkgNames);
    fireTableDataChanged();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SelectedItemsTable.java

示例11: getPublicProperty

import java.util.SortedMap; //导入方法依赖的package包/类
public Serializable getPublicProperty(
        Map<NodePropertyKey, NodePropertyValue> propertyValues,
        QName propertyQName)
{
    // Get the qname ID
    Pair<Long, QName> qnamePair = qnameDAO.getQName(propertyQName);
    if (qnamePair == null)
    {
        // There is no persisted property with that QName, so we can't match anything
        return null;
    }
    Long qnameId = qnamePair.getFirst();
    // Now loop over the properties and extract those with the given qname ID
    SortedMap<NodePropertyKey, NodePropertyValue> scratch = new TreeMap<NodePropertyKey, NodePropertyValue>();
    for (Map.Entry<NodePropertyKey, NodePropertyValue> entry : propertyValues.entrySet())
    {
        NodePropertyKey propertyKey = entry.getKey();
        if (propertyKey.getQnameId().equals(qnameId))
        {
            scratch.put(propertyKey, entry.getValue());
        }
    }
    // If we found anything, then collapse the properties to a Serializable
    if (scratch.size() > 0)
    {
        PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
        Serializable collapsedValue = collapsePropertiesWithSameQName(propertyDef, scratch);
        return collapsedValue;
    }
    else
    {
        return null;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:NodePropertyHelper.java

示例12: getHotspotsInfo

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * 获取轮子中最接近这个key的热点。
 *
 * @param key
 * @return
 */
public T getHotspotsInfo(String key) {
    // 沿环的顺时针找到一个虚拟节点。
    SortedMap<Long, T> tail = nodes.tailMap(HashingUtils.hash(key));
    if (tail.size() == 0) {
        return nodes.get(nodes.firstKey());
    }
    return tail.get(tail.firstKey()); // 返回该虚拟节点对应的真实缓存对象节点的信息
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:15,代码来源:HashWheel.java

示例13: keepDebate

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public boolean keepDebate(Debate debate)
        throws IOException
{
    // collect counts for each stance
    SortedMap<String, Integer> counts = new TreeMap<>();
    for (Argument argument : debate.getArgumentList()) {
        String stance = argument.getStance();

        if (argument.getParentId() == null) {

            if (!counts.containsKey(stance)) {
                counts.put(stance, 0);
            }
            counts.put(stance, counts.get(stance) + 1);
        }
    }

    // make sure we have two stances
    if (counts.size() < 2) {
        return false;
    }

    // check constraints for each stance
    for (Map.Entry<String, Integer> entry : counts.entrySet()) {
        if (entry.getValue() <= MINIMUM_NUMBER_OF_FIRST_LEVEL_ARGUMENTS_PER_SIDE) {
            return false;
        }
    }

    return true;
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:33,代码来源:MinimumRootArgumentCountFilterCreateDebate.java

示例14: getStartEndKey

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public Pair<Object, Object> getStartEndKey() {
  RowTupleConcurrentSkipListMap<Object, Object> internalMap =
      (RowTupleConcurrentSkipListMap<Object, Object>) _getMap();
  SortedMap<Object, Object> realMap = internalMap.getInternalMap();
  if (realMap.size() != 0) {
    Pair<Object, Object> result = new Pair<>();
    result.setFirst(realMap.firstKey());
    result.setSecond(realMap.lastKey());
    return result;
  } else {
    return null;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:AbstractRegionMap.java

示例15: makeCompositeMapping

import java.util.SortedMap; //导入方法依赖的package包/类
private MXBeanMapping makeCompositeMapping(Class<?> c,
                                           MXBeanMappingFactory factory)
        throws OpenDataException {

    // For historical reasons GcInfo implements CompositeData but we
    // shouldn't count its CompositeData.getCompositeType() field as
    // an item in the computed CompositeType.
    final boolean gcInfoHack =
        (c.getName().equals("com.sun.management.GcInfo") &&
            c.getClassLoader() == null);

    ReflectUtil.checkPackageAccess(c);
    final List<Method> methods =
            MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods()));
    final SortedMap<String,Method> getterMap = newSortedMap();

    /* Select public methods that look like "T getX()" or "boolean
       isX()", where T is not void and X is not the empty
       string.  Exclude "Class getClass()" inherited from Object.  */
    for (Method method : methods) {
        final String propertyName = propertyName(method);

        if (propertyName == null)
            continue;
        if (gcInfoHack && propertyName.equals("CompositeType"))
            continue;

        Method old =
            getterMap.put(decapitalize(propertyName),
                        method);
        if (old != null) {
            final String msg =
                "Class " + c.getName() + " has method name clash: " +
                old.getName() + ", " + method.getName();
            throw new OpenDataException(msg);
        }
    }

    final int nitems = getterMap.size();

    if (nitems == 0) {
        throw new OpenDataException("Can't map " + c.getName() +
                                    " to an open data type");
    }

    final Method[] getters = new Method[nitems];
    final String[] itemNames = new String[nitems];
    final OpenType<?>[] openTypes = new OpenType<?>[nitems];
    int i = 0;
    for (Map.Entry<String,Method> entry : getterMap.entrySet()) {
        itemNames[i] = entry.getKey();
        final Method getter = entry.getValue();
        getters[i] = getter;
        final Type retType = getter.getGenericReturnType();
        openTypes[i] = factory.mappingForType(retType, factory).getOpenType();
        i++;
    }

    CompositeType compositeType =
        new CompositeType(c.getName(),
                          c.getName(),
                          itemNames, // field names
                          itemNames, // field descriptions
                          openTypes);

    return new CompositeMapping(c,
                                compositeType,
                                itemNames,
                                getters,
                                factory);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:72,代码来源:DefaultMXBeanMappingFactory.java


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