Tabnine Logo
TreeMap.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
java.util.TreeMap

Best Java code snippets using java.util.TreeMap.get (Showing top 20 results out of 11,241)

Refine searchRefine arrow

  • TreeMap.put
  • TreeMap.keySet
  • TreeMap.containsKey
  • Map.Entry.getKey
  • Map.Entry.getValue
  • TreeMap.<init>
  • TreeMap.remove
  • List.add
origin: apache/flink

@Override
public void add(Integer value) {
  Integer current = treeMap.get(value);
  Integer newValue = (current != null ? current : 0) + 1;
  this.treeMap.put(value, newValue);
}
origin: jenkinsci/jenkins

/**
 * Splits the range set at the given timestamp (if it hasn't been split yet)
 */
private void splitAt(long t) {
  if (data.containsKey(t)) return; // already split at this timestamp
  SortedMap<Long, int[]> head = data.headMap(t);
  int v = head.isEmpty() ? 0 : data.get(head.lastKey())[0];
  data.put(t, new int[]{v});
}
origin: hankcs/HanLP

/**
 * 将分数map排序折叠
 * @param scoreMap
 * @return
 */
private static TreeMap<Double ,Set<String>> sortScoreMap(TreeMap<String, Double> scoreMap)
{
  TreeMap<Double, Set<String>> result = new TreeMap<Double, Set<String>>(Collections.reverseOrder());
  for (Map.Entry<String, Double> entry : scoreMap.entrySet())
  {
    Set<String> sentenceSet = result.get(entry.getValue());
    if (sentenceSet == null)
    {
      sentenceSet = new HashSet<String>();
      result.put(entry.getValue(), sentenceSet);
    }
    sentenceSet.add(entry.getKey());
  }
  return result;
}
origin: hankcs/HanLP

@Override
public List<String> suggest(String key, int size)
{
  List<String> resultList = new ArrayList<String>(size);
  TreeMap<String, Double> scoreMap = new TreeMap<String, Double>();
  for (BaseScorer scorer : scorerList)
  {
    Map<String, Double> map = scorer.computeScore(key);
    Double max = max(map);  // 用于正规化一个map
    for (Map.Entry<String, Double> entry : map.entrySet())
    {
      Double score = scoreMap.get(entry.getKey());
      if (score == null) score = 0.0;
      scoreMap.put(entry.getKey(), score / max + entry.getValue() * scorer.boost);
    }
  }
  for (Map.Entry<Double, Set<String>> entry : sortScoreMap(scoreMap).entrySet())
  {
    for (String sentence : entry.getValue())
    {
      if (resultList.size() >= size) return resultList;
      resultList.add(sentence);
    }
  }
  return resultList;
}
origin: google/guava

classMap.put(cls.getName(), cls);
Optional<String> testedClassName = TEST_SUFFIX.chop(cls.getName());
if (testedClassName.isPresent()) {
 Class<?> testedClass = classMap.get(testedClassName.get());
 if (testedClass != null) {
  testClasses.put(testedClass, cls);
result.add(candidate);
origin: oracle/opengrok

              String[] desc = tags.remove(prevLn);
              out.write(desc[2]);
              out.write(" </i>");
          hit.setLine(sb.toString());
          if (prevHi) {
           String[] desc = tags.remove(prevLn);
           hit.setTag(desc[2]);
          hits.add(hit);
for(Integer rem : tags.keySet()) {
  String[] desc = tags.get(rem);
  out.write("<a class=\"s\" href=\"");
  out.write(url);
for(Integer rem : tags.keySet()) {
  String[] desc = tags.get(rem);
  hit = new Hit(url, "<html>" + Util.htmlize(desc[3]).replace(desc[0], "<b>" + desc[0] + "</b>"),
         desc[1], false, alt);
  hit.setTag(desc[2]);
  hits.add(hit);
origin: stackoverflow.com

 TreeMap<String, String> myMap = new TreeMap<String, String>();
String first = myMap.firstEntry().getValue();
String firstOther = myMap.get(myMap.firstKey());
origin: apache/storm

public void resetLogLevels() {
  TreeMap<String, LogLevel> latestLogLevelMap = latestLogConfig.get();
  LOG.debug("Resetting log levels: Latest log config is {}", latestLogLevelMap);
  LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
  for (String loggerName : latestLogLevelMap.descendingKeySet()) {
    LogLevel loggerSetting = latestLogLevelMap.get(loggerName);
    long timeout = loggerSetting.get_reset_log_level_timeout_epoch();
    String resetLogLevel = loggerSetting.get_reset_log_level();
    if (timeout < Time.currentTimeMillis()) {
      LOG.info("{}: Resetting level to {}", loggerName, resetLogLevel);
      setLoggerLevel(loggerContext, loggerName, resetLogLevel);
      latestLogConfig.getAndUpdate(input -> {
        TreeMap<String, LogLevel> result = new TreeMap<>(input);
        result.remove(loggerName);
        return result;
      });
    }
  }
  loggerContext.updateLoggers();
}
origin: apache/hive

private static boolean removeFromRunningTaskMap(TreeMap<Integer, TreeSet<TaskInfo>> runningTasks,
  Object task, TaskInfo taskInfo) {
 int priority = taskInfo.priority.getPriority();
 Set<TaskInfo> tasksAtPriority = runningTasks.get(priority);
 if (tasksAtPriority == null) return false;
 boolean result = tasksAtPriority.remove(taskInfo);
 if (tasksAtPriority.isEmpty()) {
  runningTasks.remove(priority);
 }
 return result;
}
origin: sannies/mp4parser

public V get(Object k) {
  if (!(k instanceof Comparable)) {
    return null;
  }
  Comparable<K> key = (Comparable<K>) k;
  if (isEmpty()) {
    return null;
  }
  Iterator<K> keys = base.keySet().iterator();
  K a = keys.next();
  do {
    if (keys.hasNext()) {
      if (key.compareTo(a) < 0) {
        a = keys.next();
      } else {
        return base.get(a);
      }
    } else {
      return base.get(a);
    }
  } while (true);
}
origin: apache/storm

@Override
public void execute(BatchInfo info, Tuple input) {
  // there won't be a BatchInfo for the success stream
  TransactionAttempt attempt = (TransactionAttempt) input.getValue(0);
  if (input.getSourceStreamId().equals(MasterBatchCoordinator.COMMIT_STREAM_ID)) {
    if (attempt.equals(_activeBatches.get(attempt.getTransactionId()))) {
      ((ICommitterTridentSpout.Emitter) _emitter).commit(attempt);
      _activeBatches.remove(attempt.getTransactionId());
    } else {
      throw new FailedException("Received commit for different transaction attempt");
    }
  } else if (input.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {
    // valid to delete before what's been committed since 
    // those batches will never be accessed again
    _activeBatches.headMap(attempt.getTransactionId()).clear();
    _emitter.success(attempt);
  } else {
    _collector.setBatch(info.batchId);
    _emitter.emitBatch(attempt, input.getValue(1), _collector);
    _activeBatches.put(attempt.getTransactionId(), attempt);
  }
}
origin: apache/storm

/**
 * Returns null if it was created, the value otherwise.
 */
public Object getStateOrCreate(long txid, StateInitializer init) {
  Object state;
  if (_curr.containsKey(txid)) {
    state = _curr.get(txid);
  } else {
    getState(txid, init);
    state = null;
  }
  return state;
}
origin: apache/incubator-druid

@Override
public PartitionHolder<ObjectType> findEntry(Interval interval, VersionType version)
{
 try {
  lock.readLock().lock();
  for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> entry : allTimelineEntries.entrySet()) {
   if (entry.getKey().equals(interval) || entry.getKey().contains(interval)) {
    TimelineEntry foundEntry = entry.getValue().get(version);
    if (foundEntry != null) {
     return new ImmutablePartitionHolder<ObjectType>(
       foundEntry.getPartitionHolder()
     );
    }
   }
  }
  return null;
 }
 finally {
  lock.readLock().unlock();
 }
}
origin: hankcs/HanLP

public boolean load(InputStream inputStream)
  TreeMap<String, Set<Long>> treeMap = new TreeMap<String, Set<Long>>();
  String line = null;
  try
      for (Synonym synonym : synonymList)
        Set<Long> idSet = treeMap.get(synonym.realWord);
        if (idSet == null)
          treeMap.put(synonym.realWord, idSet);
    for (String key : treeMap.keySet())
      keyList.add(key);
      valueList.add(idSet.toArray(new Long[0]));
origin: apache/hive

private void addPendingTask(TaskInfo taskInfo) {
 writeLock.lock();
 try {
  List<TaskInfo> tasksAtPriority = pendingTasks.get(taskInfo.priority);
  if (tasksAtPriority == null) {
   tasksAtPriority = new LinkedList<>();
   pendingTasks.put(taskInfo.priority, tasksAtPriority);
  }
  // Delayed tasks will not kick in right now. That will happen in the scheduling loop.
  tasksAtPriority.add(taskInfo);
  knownTasks.putIfAbsent(taskInfo.task, taskInfo);
  tasksById.put(taskInfo.attemptId, taskInfo);
  if (metrics != null) {
   metrics.incrPendingTasksCount();
  }
  if (LOG.isInfoEnabled()) {
   LOG.info("PendingTasksInfo={}", constructPendingTaskCountsLogMessage());
  }
 } finally {
  writeLock.unlock();
 }
}
origin: apache/storm

private TreeMap<Long, Integer> getStoredCurrAttempts(long currTransaction, int maxBatches) {
  TreeMap<Long, Integer> ret = new TreeMap<Long, Integer>();
  for (TransactionalState state : _states) {
    Map<Object, Number> attempts = (Map) state.getData(CURRENT_ATTEMPTS);
    if (attempts == null) {
      attempts = new HashMap();
    }
    for (Entry<Object, Number> e : attempts.entrySet()) {
      // this is because json doesn't allow numbers as keys...
      // TODO: replace json with a better form of encoding
      Number txidObj;
      if (e.getKey() instanceof String) {
        txidObj = Long.parseLong((String) e.getKey());
      } else {
        txidObj = (Number) e.getKey();
      }
      long txid = ((Number) txidObj).longValue();
      int attemptId = ((Number) e.getValue()).intValue();
      Integer curr = ret.get(txid);
      if (curr == null || attemptId > curr) {
        ret.put(txid, attemptId);
      }
    }
  }
  ret.headMap(currTransaction).clear();
  ret.tailMap(currTransaction + maxBatches - 1).clear();
  return ret;
}
origin: hankcs/HanLP

static void combineChain(TreeMap<String, String> s2t, TreeMap<String, String> t2x)
{
  for (Map.Entry<String, String> entry : s2t.entrySet())
  {
    String x = t2x.get(entry.getValue());
    if (x != null)
    {
      entry.setValue(x);
    }
  }
  for (Map.Entry<String, String> entry : t2x.entrySet())
  {
    String s = CharTable.convert(entry.getKey());
    if (!s2t.containsKey(s))
    {
      s2t.put(s, entry.getValue());
    }
  }
}
origin: google/ExoPlayer

private void handleManifestExpiredMessage(long eventTimeUs, long manifestPublishTimeMsInEmsg) {
 Long previousExpiryTimeUs = manifestPublishTimeToExpiryTimeUs.get(manifestPublishTimeMsInEmsg);
 if (previousExpiryTimeUs == null) {
  manifestPublishTimeToExpiryTimeUs.put(manifestPublishTimeMsInEmsg, eventTimeUs);
 } else {
  if (previousExpiryTimeUs > eventTimeUs) {
   manifestPublishTimeToExpiryTimeUs.put(manifestPublishTimeMsInEmsg, eventTimeUs);
  }
 }
}
origin: FudanNLP/fnlp

private void deleteSortMap(int a, int b, double oridata) {
  Set<String> set = sortmap.get(oridata);
  if (set == null)
    return;
  if (set.size() == 1)
    sortmap.remove(oridata);
  else
    set.remove(id2String(a, b));
}
origin: com.h2database/h2

@Override
public void truncate(long size) {
  writeCount.incrementAndGet();
  if (size == 0) {
    fileSize = 0;
    memory.clear();
    return;
  }
  fileSize = size;
  for (Iterator<Long> it = memory.keySet().iterator(); it.hasNext();) {
    long pos = it.next();
    if (pos < size) {
      break;
    }
    ByteBuffer buff = memory.get(pos);
    if (buff.capacity() > size) {
      throw DataUtils.newIllegalStateException(
          DataUtils.ERROR_READING_FAILED,
          "Could not truncate to {0}; " +
          "partial truncate is not supported", pos);
    }
    it.remove();
  }
}
java.utilTreeMapget

Javadoc

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that key compares equal to k according to the map's ordering, then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The #containsKey operation may be used to distinguish these two cases.

Popular methods of TreeMap

  • <init>
    Constructs a new tree map containing the same mappings and using the same ordering as the specified
  • put
    Associates the specified value with the specified key in this map. If the map previously contained a
  • entrySet
    Returns a Set view of the mappings contained in this map. The set's iterator returns the entries in
  • values
    Returns a Collection view of the values contained in this map. The collection's iterator returns the
  • size
    Returns the number of key-value mappings in this map.
  • keySet
    Returns a Set view of the keys contained in this map. The set's iterator returns the keys in ascendi
  • remove
  • containsKey
    Returns true if this map contains a mapping for the specified key.
  • isEmpty
  • clear
    Removes all of the mappings from this map. The map will be empty after this call returns.
  • firstKey
  • putAll
    Copies all of the mappings from the specified map to this map. These mappings replace any mappings t
  • firstKey,
  • putAll,
  • lastKey,
  • firstEntry,
  • tailMap,
  • lastEntry,
  • floorEntry,
  • headMap,
  • subMap

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • getApplicationContext (Context)
  • onCreateOptionsMenu (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • JButton (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now