java.util.TreeSet.last()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(133)

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

TreeSet.last介绍

[英]Returns the last element in this set.
[中]返回此集合中的最后一个元素。

代码示例

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

public String getDescription() {
  final int size = data.size();
  if (size > 0) {
    final TimeData first = data.first();
    final TimeData last = data.last();
    return "Total " + size + " items: " + first + " to " + last;
  }
  return "Total " + size + " items.";
}

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

@Override
public TreeSet<T> updateBatch(TreeSet<T> object, TreeSet<T> cache, Object... objects) {
  // TODO Auto-generated method stub
  if (cache == null) {
    cache = new TreeSet<T>(comparator);
  }
  cache.addAll(object);
  while (cache.size() > n) {
    cache.remove(cache.last());
  }
  return cache;
}

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

@SuppressWarnings("unchecked")
@Override
public TreeSet<T> update(Number object, TreeSet<T> cache, Object... others) {
  // TODO Auto-generated method stub
  if (cache == null) {
    cache = new TreeSet<T>(comparator);
  }
  cache.add((T) object);
  if (cache.size() > n) {
    cache.remove(cache.last());
  }
  return cache;
}

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

@Nullable
@Override
public byte[] peekLast() {
  return !isEmpty() ? treeSet.last() : null;
}

代码示例来源:origin: wdullaer/MaterialDateTimePicker

@Override
public int getMaxYear() {
  if (!selectableDays.isEmpty()) return selectableDays.last().get(Calendar.YEAR);
  // Ensure no years can be selected outside of the given maximum date
  return mMaxDate != null && mMaxDate.get(Calendar.YEAR) < mMaxYear ? mMaxDate.get(Calendar.YEAR) : mMaxYear;
}

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

public TopologyDetails getRunningTopologyWithLowestPriority(ISchedulingState cluster) {
  TreeSet<TopologyDetails> queue = getRunningTopologies(cluster);
  if (queue.isEmpty()) {
    return null;
  }
  return queue.last();
}

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

private static void checkSupported(JavaVersion currentJavaVersion) {
    if (!SUPPORTED_VERSIONS.contains(currentJavaVersion)) {
      System.err.println("Running GoCD requires Java version >= " + SUPPORTED_VERSIONS.first().name() +
          " and <= " + SUPPORTED_VERSIONS.last() +
          ". You are currently running with Java version " + currentJavaVersion + ". GoCD will now exit!");
      System.exit(1);
    }
  }
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns the largest key in this set.
 *
 * @return the largest key in this set
 * @throws NoSuchElementException if this set is empty
 */
public Key max() {
  if (isEmpty()) throw new NoSuchElementException("called max() with empty set");
  return set.last();
}

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

public int highestLevel() {
  return sortedLevelNumbers().last();
}

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

private boolean isNewerThanCurrentLatest(Stage stage, TreeSet<Long> ids) {
  return stage.getPipelineId() > ids.last();
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Returns the vertices that are "leftmost, rightmost"  Note this requires that the IndexedFeatureLabels present actually have
 * ordering information.
 * TODO: can be done more efficiently?
 */
public static Pair<IndexedWord, IndexedWord> leftRightMostChildVertices(IndexedWord startNode, SemanticGraph sg) {
 TreeSet<IndexedWord> vertices = new TreeSet<>();
 for (IndexedWord vertex : sg.descendants(startNode)) {
  vertices.add(vertex);
 }
 return Pair.makePair(vertices.first(), vertices.last());
}

代码示例来源:origin: wdullaer/MaterialDateTimePicker

@Override
public @NonNull Calendar getEndDate() {
  if (!selectableDays.isEmpty()) return (Calendar) selectableDays.last().clone();
  if (mMaxDate != null) return (Calendar) mMaxDate.clone();
  TimeZone timeZone = mController == null ? TimeZone.getDefault() : mController.getTimeZone();
  Calendar output = Calendar.getInstance(timeZone);
  output.set(Calendar.YEAR, mMaxYear);
  output.set(Calendar.DAY_OF_MONTH, 31);
  output.set(Calendar.MONTH, Calendar.DECEMBER);
  return output;
}

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

private void removeCurrentLatestIfNoLongerActive(Stage stage, TreeSet<Long> ids) {
  if (!ids.isEmpty()) {
    if (isNewerThanCurrentLatest(stage, ids) && isCurrentLatestInactive(ids)) {
      ids.remove(ids.last());
    }
  }
}

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

public List<Neighborhood2> getNeighborhoods() {
  if (angles.size() == 0) {
    return Collections.singletonList(new Neighborhood2(center));
  }
  final List<Neighborhood2> result = new ArrayList<Neighborhood2>();
  double last = angles.last();
  for (Double currentAngle : angles) {
    result.add(new Neighborhood2(center, last, currentAngle));
    last = currentAngle;
  }
  return Collections.unmodifiableList(result);
}

代码示例来源:origin: prestodb/presto

private Optional<Object> getHighestValue()
{
  return nonNullValues.size() > 0 ? Optional.of(nonNullValues.last()) : Optional.empty();
}

代码示例来源:origin: prestodb/presto

private Optional<Object> getHighestValue()
{
  return nonNullValues.size() > 0 ? Optional.of(nonNullValues.last()) : Optional.empty();
}

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

private void removeCompletedIfNotLatest(Stage stage,
                    Map<CaseInsensitiveString, TreeSet<Long>> activePipelinesToIds,
                    CaseInsensitiveString pipelineName) {
  if (stage.getState().completed()) {
    if (activePipelinesToIds.containsKey(pipelineName)) {
      TreeSet<Long> ids = activePipelinesToIds.get(pipelineName);
      if (!ids.last().equals(stage.getPipelineId())) {
        ids.remove(stage.getPipelineId());
      }
    }
  }
}

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

private boolean isCurrentLatestInactive(TreeSet<Long> ids) {
  return !loadHistory(ids.last()).isAnyStageActive();
}

代码示例来源:origin: wdullaer/MaterialDateTimePicker

@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean isPmDisabled() {
  Timepoint midday = new Timepoint(12);
  if (mMaxTime != null && mMaxTime.compareTo(midday) < 0) return true;
  if (!exclusiveSelectableTimes.isEmpty()) return exclusiveSelectableTimes.last().compareTo(midday) < 0;
  return false;
}

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

@Test
public void shouldGroupPiplineInstancesByName() throws Exception {
  PipelineInstanceModel raghu1 = pim("raghu");
  raghu1.setCounter(1);
  PipelineInstanceModel raghu2 = pim("raghu");
  raghu2.setCounter(2);
  PipelineInstanceModel phavan = pim("pavan");
  PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(pim("upstream"), PipelineInstanceModels.createPipelineInstanceModels(raghu2, phavan, raghu1));
  Map<String, TreeSet<PipelineInstanceModel>> map = graph.groupedDependencies();
  assertThat(map.size(), is(2));
  assertOrderIsMainted(map);
  assertThat(map.get("pavan").size(), is(1));
  assertThat(map.get("pavan"), hasItem(phavan));
  assertThat(map.get("raghu").size(), is(2));
  assertThat(map.get("raghu").first(), is(raghu2));
  assertThat(map.get("raghu").last(), is(raghu1));
}

相关文章