### Question:
CcsdsTmIndex extends AbstractYamcsService implements TmIndexService { private static int compare(short apid, long time, short seq, Record ar) { short arapid = ar.apid(); if (apid != arapid) { return 0x3FFF * Integer.signum(apid - arapid); } int c = compare(time, seq, ar.firstTime(), ar.firstSeq()); if (c <= 0) { return c; } c = compare(time, seq, ar.lastTime(), ar.lastSeq()); if (c >= 0) { return c; } return 0; }  @Override void init(String yamcsInstance, YConfiguration args); @Override void onTuple(Stream stream, Tuple tuple); @Override synchronized void close(); @Override synchronized void deleteRecords(long start, long stop); void printApidDb(); void printApidDb(short apid, long start, long stop); @Override IndexIterator getIterator(List<NamedObjectId> names, long start, long stop); @Override void streamClosed(Stream stream); synchronized CompletableFuture<Void> rebuild(TimeInterval interval);  }### Answer:
@Test public void testCompare() { assertTrue(CcsdsTmIndex.compare(0L, (short) 1, 1L, (short) 5) < -1); assertTrue(CcsdsTmIndex.compare(1L, (short) 5, 0L, (short) 1) > 1); assertTrue(CcsdsTmIndex.compare(0L, (short) 1, 2L, (short) 2) == -1); assertTrue(CcsdsTmIndex.compare(2L, (short) 2, 0L, (short) 1) == 1); assertTrue(CcsdsTmIndex.compare(0L, (short) 1, 0L, (short) 5) < -1); assertTrue(CcsdsTmIndex.compare(0L, (short) 5, 0L, (short) 1) > 1); assertTrue(CcsdsTmIndex.compare(0L, (short) 1, 0L, (short) 2) == -1); assertTrue(CcsdsTmIndex.compare(0L, (short) 2, 0L, (short) 1) == 1); assertTrue(CcsdsTmIndex.compare(0L, (short) 0x3FFF, 0L, (short) 0) == -1); assertTrue(CcsdsTmIndex.compare(0L, (short) 0, 0L, (short) 0x3FFF) == 1); assertTrue(CcsdsTmIndex.compare(0L, (short) 0x3FEF, 0L, (short) 5) < -1); assertTrue(CcsdsTmIndex.compare(0L, (short) 5, 0L, (short) 0x3FEF) > 1); assertTrue(CcsdsTmIndex.compare(2L, (short) 2, 2L, (short) 2) == 0); }