List of usage examples for java.util NavigableSet floor
E floor(E e);
From source file:Main.java
public static void main(String[] args) { String[] cities = { "A", "B", "C", "D", "E", "F" }; NavigableSet<String> citiesSet = new TreeSet<String>(); for (String city : cities) citiesSet.add(city);/*from w w w . j a v a2 s .co m*/ System.out.println(citiesSet.floor("A")); }
From source file:Main.java
public static void main(String[] args) { NavigableSet<Integer> ns = new TreeSet<>(); ns.add(0);// w ww .j ava 2 s .c om ns.add(1); ns.add(2); ns.add(3); ns.add(4); ns.add(5); ns.add(6); // Get a reverse view of the navigable set NavigableSet<Integer> reverseNs = ns.descendingSet(); // Print the normal and reverse views System.out.println("Normal order: " + ns); System.out.println("Reverse order: " + reverseNs); NavigableSet<Integer> threeOrMore = ns.tailSet(3, true); System.out.println("3 or more: " + threeOrMore); System.out.println("lower(3): " + ns.lower(3)); System.out.println("floor(3): " + ns.floor(3)); System.out.println("higher(3): " + ns.higher(3)); System.out.println("ceiling(3): " + ns.ceiling(3)); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollLast(): " + ns.pollLast()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("Navigable Set: " + ns); System.out.println("pollFirst(): " + ns.pollFirst()); System.out.println("pollLast(): " + ns.pollLast()); }
From source file:ch.algotrader.service.CalendarServiceImpl.java
/** * {@inheritDoc}//from w ww. j a v a2 s . c om */ @Override public Date getCurrentTradingDate(final long exchangeId, final Date dateTime) { Validate.notNull(dateTime, "Data time is null"); Exchange exchange = this.exchangeDao.get(exchangeId); Validate.notNull(exchange, "exchange not found"); Date date = DateUtils.addDays(DateUtils.truncate(dateTime, Calendar.DATE), 2); NavigableSet<Date> openTimes = new TreeSet<>(); while ((openTimes.floor(dateTime)) == null) { date = DateUtils.addDays(date, -1); openTimes.addAll(getOpenTimes(exchange, date)); } return date; }
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
public void testFloor() { NavigableSet<E> set = createNavigableSet(); set.add(getKeys()[0]);/*from www . j a v a2 s. co m*/ assertEquals(null, set.floor(getLessThanMinimumKey())); assertEquals(getKeys()[0], set.floor(getKeys()[0])); assertEquals(getKeys()[0], set.floor(getKeys()[1])); assertEquals(getKeys()[0], set.floor(getGreaterThanMaximumKey())); assertEquals(set.toArray()[0], set.floor(getKeys()[1])); set.add(getKeys()[1]); assertEquals(null, set.floor(getLessThanMinimumKey())); assertEquals(getKeys()[0], set.floor(getKeys()[0])); assertEquals(getKeys()[1], set.floor(getKeys()[1])); assertEquals(getKeys()[1], set.floor(getGreaterThanMaximumKey())); }
From source file:org.apache.kylin.metadata.badquery.BadQueryHistoryManager.java
public BadQueryHistory updateEntryToProject(BadQueryEntry badQueryEntry, String project) throws IOException { if (StringUtils.isEmpty(project) || badQueryEntry.getAdj() == null || badQueryEntry.getSql() == null) throw new IllegalArgumentException(); BadQueryHistory badQueryHistory = getBadQueriesForProject(project); NavigableSet<BadQueryEntry> entries = badQueryHistory.getEntries(); BadQueryEntry entry = entries.floor(badQueryEntry); entry.setAdj(badQueryEntry.getAdj()); entry.setRunningSec(badQueryEntry.getRunningSec()); entry.setServer(badQueryEntry.getServer()); entry.setThread(badQueryEntry.getThread()); getStore().putResource(badQueryHistory.getResourcePath(), badQueryHistory, BAD_QUERY_INSTANCE_SERIALIZER); return badQueryHistory; }