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."; }
@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; }
@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; }
@Nullable @Override public byte[] peekLast() { return !isEmpty() ? treeSet.last() : null; }
@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; }
public TopologyDetails getRunningTopologyWithLowestPriority(ISchedulingState cluster) { TreeSet<TopologyDetails> queue = getRunningTopologies(cluster); if (queue.isEmpty()) { return null; } return queue.last(); }
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); } } }
/** * 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(); }
public int highestLevel() { return sortedLevelNumbers().last(); }
private boolean isNewerThanCurrentLatest(Stage stage, TreeSet<Long> ids) { return stage.getPipelineId() > ids.last(); }
/** * 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()); }
@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; }
private void removeCurrentLatestIfNoLongerActive(Stage stage, TreeSet<Long> ids) { if (!ids.isEmpty()) { if (isNewerThanCurrentLatest(stage, ids) && isCurrentLatestInactive(ids)) { ids.remove(ids.last()); } } }
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); }
private Optional<Object> getHighestValue() { return nonNullValues.size() > 0 ? Optional.of(nonNullValues.last()) : Optional.empty(); }
private Optional<Object> getHighestValue() { return nonNullValues.size() > 0 ? Optional.of(nonNullValues.last()) : Optional.empty(); }
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()); } } } }
private boolean isCurrentLatestInactive(TreeSet<Long> ids) { return !loadHistory(ids.last()).isAnyStageActive(); }
@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; }
@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)); }