java.util.concurrent.ConcurrentSkipListMap.comparable()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.util.concurrent.ConcurrentSkipListMap.comparable()方法的一些代码示例,展示了ConcurrentSkipListMap.comparable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentSkipListMap.comparable()方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentSkipListMap
类名称:ConcurrentSkipListMap
方法名:comparable

ConcurrentSkipListMap.comparable介绍

[英]If using comparator, return a ComparableUsingComparator, else cast key as Comparable, which may cause ClassCastException, which is propagated back to caller.
[中]如果使用comparator,则返回ComparableUsingComparator,否则将键强制转换为Comparable,这可能会导致ClassCastException,并将其传播回调用方。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * {@inheritDoc}
 *
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if any of the arguments are null
 */
public boolean replace(K key, V oldValue, V newValue) {
  if (oldValue == null || newValue == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return false;
    Object v = n.value;
    if (v != null) {
      if (!oldValue.equals(v))
        return false;
      if (n.casValue(v, newValue))
        return true;
    }
  }
}

代码示例来源:origin: robovm/robovm

/**
 * {@inheritDoc}
 *
 * @return the previous value associated with the specified key,
 *         or {@code null} if there was no mapping for the key
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if the specified key or value is null
 */
public V replace(K key, V value) {
  if (value == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null && n.casValue(v, value))
      return (V)v;
  }
}

代码示例来源:origin: robovm/robovm

Comparable<? super K> key = comparable(kkey);
for (;;) {
  Node<K,V> b = findPredecessor(key);

代码示例来源:origin: robovm/robovm

Comparable<? super K> key = comparable(idx.node.key);
if (key == null) throw new NullPointerException();

代码示例来源:origin: robovm/robovm

Comparable<? super K> key = comparable(okey);
for (;;) {
  Node<K,V> b = findPredecessor(key);

代码示例来源:origin: robovm/robovm

Comparable<? super K> key = comparable(kkey);
for (;;) {
  Node<K,V> b = findPredecessor(key);

代码示例来源:origin: robovm/robovm

break;
K key = n.key;
Comparable<? super K> ck = comparable(key);
if (!n.appendMarker(f) || !b.casNext(n, f))

代码示例来源:origin: MobiVM/robovm

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Gets value for key using findNode.
 * @param okey the key
 * @return the value, or null if absent
 */
private V doGet(Object okey) {
  Comparable<? super K> key = comparable(okey);
  /*
   * Loop needed here and elsewhere in case value field goes
   * null just as it is about to be returned, in which case we
   * lost a race with a deletion, so must retry.
   */
  for (;;) {
    Node<K,V> n = findNode(key);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null)
      return (V)v;
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * {@inheritDoc}
 *
 * @return the previous value associated with the specified key,
 *         or {@code null} if there was no mapping for the key
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if the specified key or value is null
 */
public V replace(K key, V value) {
  if (value == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null && n.casValue(v, value))
      return (V)v;
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * {@inheritDoc}
 *
 * @return the previous value associated with the specified key,
 *         or <tt>null</tt> if there was no mapping for the key
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if the specified key or value is null
 */
public V replace(K key, V value) {
  if (value == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null && n.casValue(v, value))
      return (V)v;
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * {@inheritDoc}
 *
 * @return the previous value associated with the specified key,
 *         or {@code null} if there was no mapping for the key
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if the specified key or value is null
 */
public V replace(K key, V value) {
  if (value == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null && n.casValue(v, value))
      return (V)v;
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * {@inheritDoc}
 *
 * @return the previous value associated with the specified key,
 *         or {@code null} if there was no mapping for the key
 * @throws ClassCastException if the specified key cannot be compared
 *         with the keys currently in the map
 * @throws NullPointerException if the specified key or value is null
 */
public V replace(K key, V value) {
  if (value == null)
    throw new NullPointerException();
  Comparable<? super K> k = comparable(key);
  for (;;) {
    Node<K,V> n = findNode(k);
    if (n == null)
      return null;
    Object v = n.value;
    if (v != null && n.casValue(v, value))
      return (V)v;
  }
}

相关文章

ConcurrentSkipListMap类方法