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

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

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

ConcurrentSkipListMap.firstKey介绍

暂无

代码示例

代码示例来源:origin: lealone/Lealone

@Override
public K firstKey() {
  try {
    return skipListMap.firstKey();
  } catch (NoSuchElementException e) {
    return null;
  }
}

代码示例来源:origin: alibaba/jstorm

/**
 * Adds an old value with a fixed timestamp to the reservoir.
 *
 * @param value     the value to be added
 * @param timestamp the epoch timestamp of {@code value} in seconds
 */
public void update(long value, long timestamp) {
  rescaleIfNeeded();
  lockForRegularUsage();
  try {
    final double itemWeight = weight(timestamp - startTime);
    final WeightedSnapshot.WeightedSample sample = new WeightedSnapshot.WeightedSample(value, itemWeight);
    final double priority = itemWeight / ThreadLocalRandom.current().nextDouble();
    final long newCount = count.incrementAndGet();
    if (newCount <= size) {
      values.put(priority, sample);
    } else {
      Double first = values.firstKey();
      if (first < priority && values.putIfAbsent(priority, sample) == null) {
        // ensure we always remove an item
        while (values.remove(first) == null) {
          first = values.firstKey();
        }
      }
    }
  } finally {
    unlockForRegularUsage();
  }
}

代码示例来源:origin: io.dropwizard.metrics/metrics-core

/**
 * Adds an old value with a fixed timestamp to the reservoir.
 *
 * @param value     the value to be added
 * @param timestamp the epoch timestamp of {@code value} in seconds
 */
public void update(long value, long timestamp) {
  rescaleIfNeeded();
  lockForRegularUsage();
  try {
    final double itemWeight = weight(timestamp - startTime);
    final WeightedSample sample = new WeightedSample(value, itemWeight);
    final double priority = itemWeight / ThreadLocalRandom.current().nextDouble();
    final long newCount = count.incrementAndGet();
    if (newCount <= size) {
      values.put(priority, sample);
    } else {
      Double first = values.firstKey();
      if (first < priority && values.putIfAbsent(priority, sample) == null) {
        // ensure we always remove an item
        while (values.remove(first) == null) {
          first = values.firstKey();
        }
      }
    }
  } finally {
    unlockForRegularUsage();
  }
}

代码示例来源:origin: loklak/loklak_server

this.pendingQueue.remove(t.getKey());
  this.finishedQueue.put(t.getKey(), t.getValue());
  while (this.finishedQueue.size() > MAX_FINISHED) this.finishedQueue.remove(this.finishedQueue.firstKey());
  continue timeoutcheck;
} catch (IOException e) {

代码示例来源:origin: oracle/helidon

/**
 * Adds an old value with a fixed timestamp to the reservoir.
 *
 * @param value     the value to be added
 * @param timestamp the epoch timestamp of {@code value} in seconds
 */
public void update(long value, long timestamp) {
  rescaleIfNeeded();
  lockForRegularUsage();
  try {
    final double itemWeight = weight(timestamp - startTime);
    final WeightedSnapshot.WeightedSample sample = new WeightedSnapshot.WeightedSample(value, itemWeight);
    final double priority = itemWeight / ThreadLocalRandom.current().nextDouble();
    final long newCount = count.incrementAndGet();
    if (newCount <= size) {
      values.put(priority, sample);
    } else {
      Double first = values.firstKey();
      if ((first < priority) && (values.putIfAbsent(priority, sample) == null)) {
        // ensure we always remove an item
        while (values.remove(first) == null) {
          first = values.firstKey();
        }
      }
    }
  } finally {
    unlockForRegularUsage();
  }
}

代码示例来源:origin: networknt/light-4j

/**
 * Adds an old value with a fixed timestamp to the reservoir.
 *
 * @param value     the value to be added
 * @param timestamp the epoch timestamp of {@code value} in seconds
 */
public void update(long value, long timestamp) {
  rescaleIfNeeded();
  lockForRegularUsage();
  try {
    final double itemWeight = weight(timestamp - startTime);
    final WeightedSample sample = new WeightedSample(value, itemWeight);
    final double priority = itemWeight / (1.0d - ThreadLocalRandom.current().nextDouble());
    final long newCount = count.incrementAndGet();
    if (newCount <= size) {
      values.put(priority, sample);
    } else {
      Double first = values.firstKey();
      if (first < priority && values.putIfAbsent(priority, sample) == null) {
        // ensure we always remove an item
        while (values.remove(first) == null) {
          first = values.firstKey();
        }
      }
    }
  } finally {
    unlockForRegularUsage();
  }
}

代码示例来源:origin: apache/hbase

@Test
public void testFirstKey() throws Exception {
 assertEquals(csm.firstKey(), m.firstKey());
}

代码示例来源:origin: lealone/Lealone

protected K getFirstLast(boolean first) {
  Object k, k1, k2;
  try {
    if (first)
      k1 = buffer.firstKey();
    else
      k1 = buffer.lastKey();
  } catch (NoSuchElementException e) {
    k1 = null;
  }
  if (first)
    k2 = map.firstKey();
  else
    k2 = map.lastKey();
  if (k1 == null)
    k = k2;
  else if (k2 == null)
    k = k1;
  else {
    if (first)
      k = getKeyType().compare(k1, k2) < 0 ? k1 : k2;
    else
      k = getKeyType().compare(k1, k2) < 0 ? k2 : k1;
  }
  return (K) k;
}

代码示例来源:origin: lealone/Lealone

try {
  if (key == null) {
    k1 = buffer.firstKey();
  } else {
    if (!min) {

代码示例来源:origin: sc.fiji/TrackMate_

/**
 * Returns the first (lowest) frame currently in this collection.
 *
 * @return the first (lowest) frame currently in this collection.
 */
public Integer firstKey()
{
  if ( content.isEmpty() ) { return 0; }
  return content.firstKey();
}

代码示例来源:origin: fiji/TrackMate

/**
 * Returns the first (lowest) frame currently in this collection.
 *
 * @return the first (lowest) frame currently in this collection.
 */
public Integer firstKey()
{
  if ( content.isEmpty() ) { return 0; }
  return content.firstKey();
}

代码示例来源:origin: com.n3twork.druid/druid-processing

public long getMinTimeMillis()
{
 return facts.firstKey().getTimestamp();
}

代码示例来源:origin: dworkin/reddwarf

/** {@inheritDoc} */
public void run() {
  long now = System.currentTimeMillis();
  if (!disconnectingHandlersMap.isEmpty() &&
  disconnectingHandlersMap.firstKey() < now) {
  Map<Long, SessionProtocol> expiredSessions = 
    disconnectingHandlersMap.headMap(now);
  for (SessionProtocol protocol : expiredSessions.values()) {
    try {
    protocol.close();
    } catch (IOException e) {
    }
  }
  expiredSessions.clear();
  }
}
}

代码示例来源:origin: org.reddwarfserver.server/sgs-server

/** {@inheritDoc} */
public void run() {
  long now = System.currentTimeMillis();
  if (!disconnectingHandlersMap.isEmpty() &&
  disconnectingHandlersMap.firstKey() < now) {
  Map<Long, SessionProtocol> expiredSessions = 
    disconnectingHandlersMap.headMap(now);
  for (SessionProtocol protocol : expiredSessions.values()) {
    try {
    protocol.close();
    } catch (IOException e) {
    }
  }
  expiredSessions.clear();
  }
}
}

代码示例来源:origin: Unidata/thredds

private CacheElement updateInCache(CacheElement elem) {
 if (shadowCache.firstKey() == elem) return elem;
 elem.updateAccessed();
 CacheElement prev = shadowCache.put(elem, elem); // faster if we could just insert at the top of the list. maybe we need to use LinkedList ?
 if (prev != null && (elem != prev)) {
  CacheElementComparator cc = new CacheElementComparator();
  System.out.printf("elem != prev compare=%d%n", cc.compare(elem, prev));
  System.out.printf("hash elem =%d prev=%d%n", elem.hashCode(), prev.hashCode());
 }
 return elem;
}

代码示例来源:origin: edu.ucar/cdm

private CacheElement updateInCache(CacheElement elem) {
 if (shadowCache.firstKey() == elem) return elem;
 elem.updateAccessed();
 CacheElement prev = shadowCache.put(elem, elem); // faster if we could just insert at the top of the list. maybe we need to use LinkedList ?
 if (prev != null && (elem != prev)) {
  CacheElementComparator cc = new CacheElementComparator();
  System.out.printf("elem != prev compare=%d%n", cc.compare(elem, prev));
  System.out.printf("hash elem =%d prev=%d%n", elem.hashCode(), prev.hashCode());
 }
 return elem;
}

代码示例来源:origin: cinchapi/concourse

@Override
public K firstKey() {
  long[] stamps = grabAllSegmentWriteLocks();
  try {
    sort();
    return sorted.firstKey();
  }
  finally {
    releaseSegmentLocks(stamps);
  }
}

代码示例来源:origin: org.glassfish.main.elasticity/elastic-api

private NavigableMap<Long, MetricEntryHolder> getOldestView(long duration, TimeUnit unit) {
  NavigableMap<Long, MetricEntryHolder> result = _emptyMap;
  if (! map.isEmpty()) {
    Long maxKey = map.lastKey();
    if (maxKey != null) {
      Long minKey = map.floorKey(maxKey - TimeUnit.MILLISECONDS.convert(duration, unit));
      if (minKey != null) {
        result = map.subMap(map.firstKey(), true, minKey, true);
      }
    }
  }
  
  return result;
}

代码示例来源:origin: org.apache.hbase/hbase-common

@Test
public void testFirstKey() throws Exception {
 assertEquals(csm.firstKey(), m.firstKey());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

@Test
public void testFirstKey() throws Exception {
 assertEquals(csm.firstKey(), m.firstKey());
}

相关文章

微信公众号

最新文章

更多

ConcurrentSkipListMap类方法