当前位置: 首页>>代码示例>>Java>>正文


Java SortedSet.first方法代码示例

本文整理汇总了Java中java.util.SortedSet.first方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.first方法的具体用法?Java SortedSet.first怎么用?Java SortedSet.first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.SortedSet的用法示例。


在下文中一共展示了SortedSet.first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Return the ith element of a set. Super lame
 * 
 * @param <T>
 * @param items
 * @param idx
 * @return
 */
public static <T> T get(Iterable<T> items, int idx) {
    if (items == null) {
        return (null);
    }
    else if (items instanceof List<?>) {
        return ((List<T>) items).get(idx);
    }
    else if (items instanceof ListOrderedSet<?>) {
        return ((ListOrderedSet<T>) items).get(idx);
    }
    else if (items instanceof SortedSet<?> && idx == 0) {
        SortedSet<T> set = (SortedSet<T>)items;
        return (set.isEmpty() ? null : set.first());
    }
    int ctr = 0;
    for (T t : items) {
        if (ctr++ == idx) return (t);
    }
    return (null);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:CollectionUtil.java

示例2: chooseOptimalSize

import java.util.SortedSet; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
private Size chooseOptimalSize(SortedSet<Size> sizes) {
    if (!mPreview.isReady()) { // Not yet laid out
        return sizes.first(); // Return the smallest size
    }
    int desiredWidth;
    int desiredHeight;
    final int surfaceWidth = mPreview.getWidth();
    final int surfaceHeight = mPreview.getHeight();
    if (mDisplayOrientation == 90 || mDisplayOrientation == 270) {
        desiredWidth = surfaceHeight;
        desiredHeight = surfaceWidth;
    } else {
        desiredWidth = surfaceWidth;
        desiredHeight = surfaceHeight;
    }
    Size result = null;
    for (Size size : sizes) { // Iterate from small to large
        if (desiredWidth <= size.getWidth() && desiredHeight <= size.getHeight()) {
            return size;

        }
        result = size;
    }
    return result;
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:27,代码来源:Camera1.java

示例3: create

import java.util.SortedSet; //导入方法依赖的package包/类
@Override
protected SortedSet<Integer> create(Integer[] elements) {
  SortedSet<Integer> set = nullCheckedTreeSet(elements);
  if (set.isEmpty()) {
    /*
     * The (tooLow + 1, tooHigh) arguments below would be invalid because tooLow would be
     * greater than tooHigh.
     */
    return ContiguousSet.create(Range.openClosed(0, 1), DiscreteDomain.integers()).subSet(0, 1);
  }
  int tooHigh = set.last() + 1;
  int tooLow = set.first() - 1;
  set.add(tooHigh);
  set.add(tooLow);
  return checkedCreate(set).subSet(tooLow + 1, tooHigh);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:SetGenerators.java

示例4: getMostCompatibleMethod

import java.util.SortedSet; //导入方法依赖的package包/类
public IMethod getMostCompatibleMethod(String name, ISignature signature) {
  IMethod result = null;

  SortedSet compatibleMethods
    = new TreeSet(new MethodSpecificityComparator());

  Iterator it = getMethods().iterator();
  while (it.hasNext()) {
    IMethod method = (IMethod)it.next();
    if ( name.equals( method.getName() ) ) {
      if ( method.hasCompatibleSignature( signature ) ) {
        compatibleMethods.add(method);
      }
    }
  }

  if (!compatibleMethods.isEmpty()) {
    result = (IMethod)compatibleMethods.first();
  }

  return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:ExternalClass.java

示例5: testLoadIndex

import java.util.SortedSet; //导入方法依赖的package包/类
@Test
public void testLoadIndex() throws IOException, URISyntaxException {
  final Path originalIndexPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource(this.getClass().getSimpleName() + "/original-index.yaml").getPath());
  assertNotNull(originalIndexPath);

  final Path newIndexPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource(this.getClass().getSimpleName() + "/new-index.yaml").getPath());
  assertNotNull(newIndexPath);

  final Index originalIndex = Index.loadFrom(originalIndexPath);
  assertNotNull(originalIndex);

  final Index newIndex = Index.loadFrom(newIndexPath);
  assertNotNull(newIndex);

  final Index mergedIndex = originalIndex.merge(newIndex);
  assertNotNull(mergedIndex);
  assertNotEquals(originalIndex, mergedIndex);

  final Map<String, SortedSet<Entry>> entries = mergedIndex.getEntries();
  assertNotNull(entries);
  assertEquals(3, entries.size());
  
  final SortedSet<Entry> zetcd = entries.get("zetcd");
  assertNotNull(zetcd);
  assertEquals(3, zetcd.size());
  Entry first = zetcd.first();
  assertNotNull(first);
  assertEquals("zetcd", first.getName());
  assertEquals("0.1.3", first.getVersion());

  final SortedSet<Entry> awsClusterAutoscaler = entries.get("aws-cluster-autoscaler");
  assertNotNull(awsClusterAutoscaler);
  assertEquals(6, awsClusterAutoscaler.size());
  first = awsClusterAutoscaler.first();
  assertNotNull(first);
  assertEquals("aws-cluster-autoscaler", first.getName());
  assertEquals("0.3.1", first.getVersion());
  
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:40,代码来源:TestMergeChartRepositoryIndices.java

示例6: create

import java.util.SortedSet; //导入方法依赖的package包/类
@Override
protected SortedSet<Integer> create(Integer[] elements) {
  SortedSet<Integer> set = nullCheckedTreeSet(elements);
  int tooLow = (set.isEmpty()) ? 0 : set.first() - 1;
  set.add(tooLow);
  return checkedCreate(set).tailSet(tooLow + 1);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:SetGenerators.java

示例7: sort

import java.util.SortedSet; //导入方法依赖的package包/类
private String sort(List<String> list, Comparator comparator)
{
    	SortedSet<String> sortedRoles = new TreeSet<String>(comparator);
    	for (String role : list)
    	{
    		sortedRoles.add(role);
    	}
    	return sortedRoles.first();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:RoleComparatorImplTest.java

示例8: testEmpty_first

import java.util.SortedSet; //导入方法依赖的package包/类
public void testEmpty_first() {
  SortedSet<String> set = of();
  try {
    set.first();
    fail();
  } catch (NoSuchElementException expected) {
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:ImmutableSortedSetTest.java

示例9: passesBloomFilter

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Checks whether the given scan passes the Bloom filter (if present). Only checks Bloom filters
 * for single-row or single-row-column scans. Bloom filter checking for multi-gets is
 * implemented as part of the store scanner system (see {@link StoreFileScanner#seekExactly})
 * and uses the lower-level API
 * {@link #passesGeneralBloomFilter(byte[], int, int, byte[], int, int)}.
 *
 * @param scan    the scan specification. Used to determine the row, and to check whether this is a
 *                single-row ("get") scan.
 * @param columns the set of columns. Only used for row-column Bloom filters.
 * @return true if the scan with the given column set passes the Bloom filter, or if the Bloom
 * filter is not applicable for the scan. False if the Bloom filter is applicable and
 * the scan fails it.
 */
boolean passesBloomFilter(Scan scan, final SortedSet<byte[]> columns) {
  // Multi-column non-get scans will use Bloom filters through the
  // lower-level API function that this function calls.
  if (!scan.isGetScan()) {
    return true;
  }

  byte[] row = scan.getStartRow();
  switch (this.bloomFilterType) {
  case ROW:
    return passesGeneralBloomFilter(row, 0, row.length, null, 0, 0);

  case ROWCOL:
    if (columns != null && columns.size() == 1) {
      byte[] column = columns.first();
      return passesGeneralBloomFilter(row, 0, row.length, column, 0, column.length);
    }

    // For multi-column queries the Bloom filter is checked from the
    // seekExact operation.
    return true;

  default:
    return true;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:StoreFile.java

示例10: determineMaxIpcNumber

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Run through the creation of a log without any faults injected,
 * and count how many RPCs are made to each node. This sets the
 * bounds for the other test cases, so they can exhaustively explore
 * the space of potential failures.
 */
private static long determineMaxIpcNumber() throws Exception {
  Configuration conf = new Configuration();
  MiniJournalCluster cluster = new MiniJournalCluster.Builder(conf).build();
  QuorumJournalManager qjm = null;
  long ret;
  try {
    qjm = createInjectableQJM(cluster);
    qjm.format(FAKE_NSINFO);
    doWorkload(cluster, qjm);
    
    SortedSet<Integer> ipcCounts = Sets.newTreeSet();
    for (AsyncLogger l : qjm.getLoggerSetForTests().getLoggersForTests()) {
      InvocationCountingChannel ch = (InvocationCountingChannel)l;
      ch.waitForAllPendingCalls();
      ipcCounts.add(ch.getRpcCount());
    }

    // All of the loggers should have sent the same number of RPCs, since there
    // were no failures.
    assertEquals(1, ipcCounts.size());
    
    ret = ipcCounts.first();
    LOG.info("Max IPC count = " + ret);
  } finally {
    IOUtils.closeStream(qjm);
    cluster.shutdown();
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestQJMWithFaults.java

示例11: findNext

import java.util.SortedSet; //导入方法依赖的package包/类
private final static <T> T findNext(SortedSet<T> set, T element){
    SortedSet<T> tail = set.tailSet(element);
    return tail.isEmpty() ? set.first() : tail.first();
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:5,代码来源:Polygon2DUtils.java

示例12: updateColumnValue

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Only used by tests. TODO: Remove
 *
 * Given the specs of a column, update it, first by inserting a new record,
 * then removing the old one.  Since there is only 1 KeyValue involved, the memstoreTS
 * will be set to 0, thus ensuring that they instantly appear to anyone. The underlying
 * store will ensure that the insert/delete each are atomic. A scanner/reader will either
 * get the new value, or the old value and all readers will eventually only see the new
 * value after the old was removed.
 *
 * @param row
 * @param family
 * @param qualifier
 * @param newValue
 * @param now
 * @return  Timestamp
 */
@Override
public long updateColumnValue(byte[] row,
                              byte[] family,
                              byte[] qualifier,
                              long newValue,
                              long now) {
  Cell firstCell = KeyValueUtil.createFirstOnRow(row, family, qualifier);
  // Is there a Cell in 'snapshot' with the same TS? If so, upgrade the timestamp a bit.
  SortedSet<Cell> snSs = snapshot.tailSet(firstCell);
  if (!snSs.isEmpty()) {
    Cell snc = snSs.first();
    // is there a matching Cell in the snapshot?
    if (CellUtil.matchingRow(snc, firstCell) && CellUtil.matchingQualifier(snc, firstCell)) {
      if (snc.getTimestamp() == now) {
        // poop,
        now += 1;
      }
    }
  }

  // logic here: the new ts MUST be at least 'now'. But it could be larger if necessary.
  // But the timestamp should also be max(now, mostRecentTsInMemstore)

  // so we cant add the new Cell w/o knowing what's there already, but we also
  // want to take this chance to delete some cells. So two loops (sad)

  SortedSet<Cell> ss = cellSet.tailSet(firstCell);
  for (Cell cell : ss) {
    // if this isnt the row we are interested in, then bail:
    if (!CellUtil.matchingColumn(cell, family, qualifier)
        || !CellUtil.matchingRow(cell, firstCell)) {
      break; // rows dont match, bail.
    }

    // if the qualifier matches and it's a put, just RM it out of the cellSet.
    if (cell.getTypeByte() == KeyValue.Type.Put.getCode() &&
        cell.getTimestamp() > now && CellUtil.matchingQualifier(firstCell, cell)) {
      now = cell.getTimestamp();
    }
  }

  // create or update (upsert) a new Cell with
  // 'now' and a 0 memstoreTS == immediately visible
  List<Cell> cells = new ArrayList<Cell>(1);
  cells.add(new KeyValue(row, family, qualifier, now, Bytes.toBytes(newValue)));
  return upsert(cells, 1L);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:DefaultMemStore.java

示例13: performRender

import java.util.SortedSet; //导入方法依赖的package包/类
@Override
protected void performRender ( final Graphics g, final Rectangle clientRect )
{
    final XAxis xAxis = this.seriesData.getXAxis ();
    final YAxis yAxis = this.seriesData.getYAxis ();

    g.setBackground ( this.color );
    g.setAlpha ( 128 );

    final SortedSet<DataEntry> entries = this.seriesData.getViewData ().getEntries ();
    if ( entries.isEmpty () )
    {
        g.fillRectangle ( clientRect );
        return;
    }

    g.setClipping ( clientRect );

    final DataPoint point = new DataPoint ();

    Integer lastPosition = null;
    Integer lastValidPosition = null;

    final DataEntry first = entries.first ();
    translateToPoint ( clientRect, xAxis, yAxis, point, first );
    if ( point.x > 0 )
    {
        g.fillRectangle ( clientRect.x, clientRect.y, (int)point.x - clientRect.x, clientRect.height );
    }

    final DataEntry last = entries.last ();
    translateToPoint ( clientRect, xAxis, yAxis, point, last );
    if ( point.x >= 0 && point.x < clientRect.width )
    {
        g.fillRectangle ( (int)point.x, clientRect.y, (int) ( clientRect.width - ( point.x - 1 - clientRect.x ) ), clientRect.height );
    }
    else if ( point.x < 0 )
    {
        g.fillRectangle ( clientRect );
    }

    for ( final DataEntry entry : entries )
    {
        final boolean hasData = translateToPoint ( clientRect, xAxis, yAxis, point, entry );

        final boolean qualityOk = checkQuality ( hasData, entry.getValue () );

        if ( lastPosition != null )
        {
            g.fillRectangle ( lastPosition, clientRect.y, (int)point.x - lastPosition, clientRect.height );
        }

        if ( !qualityOk )
        {
            if ( lastValidPosition != null && lastPosition == null )
            {
                g.fillRectangle ( lastValidPosition, clientRect.y, (int)point.x - lastValidPosition, clientRect.height );
            }
            lastPosition = (int)point.x;
        }
        else
        {
            lastValidPosition = (int)point.x;
            lastPosition = null;
        }
    }

    g.setClipping ( clientRect );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:70,代码来源:QualityRenderer.java

示例14: ceil

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Return the smallest key in this set >= k.
 */
public Key ceil(Key k) {
    SortedSet<Key> tail = set.tailSet(k);
    if (tail.isEmpty()) return null;
    else return tail.first();
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:9,代码来源:SET.java

示例15: getEditLogManifest

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * Return a manifest of what finalized edit logs are available. All available
 * edit logs are returned starting from the transaction id passed. If
 * 'fromTxId' falls in the middle of a log, that log is returned as well.
 * 
 * @param fromTxId Starting transaction id to read the logs.
 * @return RemoteEditLogManifest object.
 */
public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) {
  // Collect RemoteEditLogs available from each FileJournalManager
  List<RemoteEditLog> allLogs = Lists.newArrayList();
  for (JournalAndStream j : journals) {
    if (j.getManager() instanceof FileJournalManager) {
      FileJournalManager fjm = (FileJournalManager)j.getManager();
      try {
        allLogs.addAll(fjm.getRemoteEditLogs(fromTxId, false));
      } catch (Throwable t) {
        LOG.warn("Cannot list edit logs in " + fjm, t);
      }
    }
  }
  
  // Group logs by their starting txid
  ImmutableListMultimap<Long, RemoteEditLog> logsByStartTxId =
    Multimaps.index(allLogs, RemoteEditLog.GET_START_TXID);
  long curStartTxId = fromTxId;

  List<RemoteEditLog> logs = Lists.newArrayList();
  while (true) {
    ImmutableList<RemoteEditLog> logGroup = logsByStartTxId.get(curStartTxId);
    if (logGroup.isEmpty()) {
      // we have a gap in logs - for example because we recovered some old
      // storage directory with ancient logs. Clear out any logs we've
      // accumulated so far, and then skip to the next segment of logs
      // after the gap.
      SortedSet<Long> startTxIds = Sets.newTreeSet(logsByStartTxId.keySet());
      startTxIds = startTxIds.tailSet(curStartTxId);
      if (startTxIds.isEmpty()) {
        break;
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Found gap in logs at " + curStartTxId + ": " +
              "not returning previous logs in manifest.");
        }
        logs.clear();
        curStartTxId = startTxIds.first();
        continue;
      }
    }

    // Find the one that extends the farthest forward
    RemoteEditLog bestLog = Collections.max(logGroup);
    logs.add(bestLog);
    // And then start looking from after that point
    curStartTxId = bestLog.getEndTxId() + 1;
  }
  RemoteEditLogManifest ret = new RemoteEditLogManifest(logs);
  
  if (LOG.isDebugEnabled()) {
    LOG.debug("Generated manifest for logs since " + fromTxId + ":"
        + ret);      
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:JournalSet.java


注:本文中的java.util.SortedSet.first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。