@Override
 protected Integer detectCurrentVersionNumber() throws IOException {
   SortedSet<CueballFilePath> localBases = Cueball.getBases(localPartitionRoot);
   if (localBases.size() > 0) {
     return localBases.last().getVersion();
   } else {
     return null;
   }
 }
 /**
  * Returns a new {@link GapAwareTrackingToken} instance based on the given {@code index} and
  * collection of {@code gaps}.
  *
  * @param index the highest global sequence number of events up until (and including) this
  *     tracking token
  * @param gaps global sequence numbers of events that have not been seen yet even though these
  *     sequence numbers are smaller than the current index. These missing sequence numbers may be
  *     filled in later when those events get committed to the store or may never be filled in if
  *     those events never get committed.
  * @return a new tracking token from given index and gaps
  */
 public static GapAwareTrackingToken newInstance(long index, Collection<Long> gaps) {
   if (gaps.isEmpty()) {
     return new GapAwareTrackingToken(index, Collections.emptySortedSet());
   }
   SortedSet<Long> gapSet = new TreeSet<>(gaps);
   Assert.isTrue(
       gapSet.last() < index,
       () ->
           String.format(
               "Gap indices [%s] should all be smaller than head index [%d]", gaps, index));
   return new GapAwareTrackingToken(index, gapSet);
 }
예제 #3
0
    @Override
    public int previousTab(int position) {
      int tabStop = 0;

      // Search for the first tab stop before the given position...
      SortedSet<Integer> headSet = myTabStops.headSet(Integer.valueOf(position));
      if (!headSet.isEmpty()) {
        tabStop = headSet.last();
      }

      // Don't go beyond the start of the line...
      return Math.max(0, tabStop);
    }
예제 #4
0
 /** @tests java.util.TreeSet#TreeSet(java.util.Comparator) */
 public void test_ConstructorLjava_util_Comparator() {
   // Test for method java.util.TreeSet(java.util.Comparator)
   SortedSet myTreeSet = db.createTreeSet("test", new ReversedIntegerComparator(), null);
   assertTrue("Did not construct correct TreeSet", myTreeSet.isEmpty());
   myTreeSet.add(new Integer(1));
   myTreeSet.add(new Integer(2));
   assertTrue(
       "Answered incorrect first element--did not use custom comparator ",
       myTreeSet.first().equals(new Integer(2)));
   assertTrue(
       "Answered incorrect last element--did not use custom comparator ",
       myTreeSet.last().equals(new Integer(1)));
 }
예제 #5
0
 /**
  * Build the method documentation.
  *
  * @param node the XML element that specifies which components to document
  * @param memberDetailsTree the content tree to which the documentation will be added
  */
 public void buildMethodDoc(XMLNode node, Content memberDetailsTree) {
   if (writer == null) {
     return;
   }
   if (!methods.isEmpty()) {
     Content methodDetailsTree = writer.getMethodDetailsTreeHeader(typeElement, memberDetailsTree);
     Set<Element> methodDetailSet =
         ((ConfigurationImpl) configuration).sortedMethodDetails
             ? methods
             : visibleMemberMap.getLeafClassMembersSourceOrder();
     for (Element e : methodDetailSet) {
       currentMethod = (ExecutableElement) e;
       Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod, methodDetailsTree);
       buildChildren(node, methodDocTree);
       methodDetailsTree.addContent(
           writer.getMethodDoc(methodDocTree, currentMethod == methods.last()));
     }
     memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree));
   }
 }
예제 #6
0
 public static void main(String[] args) {
   SortedSet<String> sortedSet = new TreeSet<String>();
   Collections.addAll(sortedSet, "one two three four five six seven eight".split(" "));
   print(sortedSet);
   String low = sortedSet.first();
   String high = sortedSet.last();
   print(low);
   print(high);
   Iterator<String> it = sortedSet.iterator();
   for (int i = 0; i <= 6; i++) {
     if (i == 3) low = it.next();
     if (i == 6) high = it.next();
     else it.next();
   }
   print(low);
   print(high);
   print(sortedSet.subSet(low, high));
   print(sortedSet.headSet(high));
   print(sortedSet.tailSet(low));
 }
예제 #7
0
 public Object lastElement() {
   // Return the appropriate element
   return m_Models.last();
 }
예제 #8
0
 /** @tests java.util.TreeSet#last() */
 public void test_last() {
   // Test for method java.lang.Object java.util.TreeSet.last()
   assertEquals("Returned incorrect last element", ts.last(), objArray[objArray.length - 1]);
 }