@Override public boolean isLess(int i, int j) { String s1 = resourceIds[resourceIdsIndex[i]]; String s2 = resourceIds[resourceIdsIndex[j]]; return FastStringComparator.INSTANCE.compare(s1, s2) < 0; }
static int compare(String left, String right) { return FastStringComparator.INSTANCE.compare(left, right); }
@Override public ResourceBlocks next() { if (!hasNext()) { throw new NoSuchElementException(); } String resourceId = resourceIds[resourceIdsIndex[index]]; List<Block> blocks = new ArrayList<>(); // while we are at the same resource, keep going do { blocks.add(getBlock(resourceIdsIndex[index], resourceId)); index++; } while (hasNext() && FastStringComparator.INSTANCE.compare(resourceIds[resourceIdsIndex[index]], resourceId) == 0); return new ResourceBlocks(resourceId, blocks); }
@Override public int compare(ClonePart o1, ClonePart o2) { return FastStringComparator.INSTANCE.compare(o1.getResourceId(), o2.getResourceId()); } };
/** * {@inheritDoc} * <p> * <strong>Note that this implementation does not guarantee that blocks would be sorted by index.</strong> * </p> */ @Override public Collection<Block> getByResourceId(String resourceId) { ensureSorted(); // prepare resourceId for binary search resourceIds[size] = resourceId; resourceIdsIndex[size] = size; int index = DataUtils.binarySearch(byResourceId); List<Block> result = new ArrayList<>(); int realIndex = resourceIdsIndex[index]; while (index < size && FastStringComparator.INSTANCE.compare(resourceIds[realIndex], resourceId) == 0) { result.add(getBlock(realIndex, resourceId)); index++; realIndex = resourceIdsIndex[index]; } return result; }
@Override public boolean isLess(int i, int j) { String s1 = resourceIds[resourceIdsIndex[i]]; String s2 = resourceIds[resourceIdsIndex[j]]; return FastStringComparator.INSTANCE.compare(s1, s2) < 0; }
@Override public int compare(ClonePart o1, ClonePart o2) { return FastStringComparator.INSTANCE.compare(o1.getResourceId(), o2.getResourceId()); } };
while (index < size && FastStringComparator.INSTANCE.compare(resourceIds[realIndex], resourceId) == 0) {