/** * <p>Constructor for RefWriter.</p> * * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Collection<Ref> refs) { this.refs = RefComparator.sort(refs); }
/** {@inheritDoc} */ @Override public int compare(Ref o1, Ref o2) { return compareTo(o1, o2); }
/** * <p>Constructor for RefWriter.</p> * * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Map<String, Ref> refs) { if (refs instanceof RefMap) this.refs = refs.values(); else this.refs = RefComparator.sort(refs.values()); }
/** * Locate an entry by name. * * @param name * the name of the reference to find. * @return the index the reference is at. If the entry is not present * returns a negative value. The insertion position for the given * name can be computed from {@code -(index + 1)}. */ public final int find(String name) { int high = cnt; if (high == 0) return -1; int low = 0; do { final int mid = (low + high) >>> 1; final int cmp = RefComparator.compareTo(list[mid], name); if (cmp < 0) low = mid + 1; else if (cmp == 0) return mid; else high = mid; } while (low < high); return -(low + 1); }
/** * <p>Constructor for RefWriter.</p> * * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Collection<Ref> refs) { this.refs = RefComparator.sort(refs); }
private Ref resolveLoose(Ref l) { if (resolvedIdx < resolved.size()) { Ref r = resolved.get(resolvedIdx); int cmp = RefComparator.compareTo(l, r); if (cmp == 0) { resolvedIdx++; return r; } else if (cmp > 0) { // WTF, we have a symbolic entry but no match // in the loose collection. That's an error. throw new IllegalStateException(); } } return l; }
/** * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Collection<Ref> refs) { this.refs = RefComparator.sort(refs); }
else cur = new ObjectIdRef.Unpeeled(PACKED, name, id); if (last != null && RefComparator.compareTo(last, cur) > 0) needSort = true; all.add(cur);
/** * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Map<String, Ref> refs) { if (refs instanceof RefMap) this.refs = refs.values(); else this.refs = RefComparator.sort(refs.values()); }
/** {@inheritDoc} */ @Override public int compare(Ref o1, Ref o2) { return compareTo(o1, o2); }
/** * <p>Constructor for RefWriter.</p> * * @param refs * the complete set of references. This should have been computed * by applying updates to the advertised refs already discovered. */ public RefWriter(Map<String, Ref> refs) { if (refs instanceof RefMap) this.refs = refs.values(); else this.refs = RefComparator.sort(refs.values()); }
public int compare(final Ref o1, final Ref o2) { return compareTo(o1, o2); }
private Iterable<Ref> getSortedRefs(Map<String, Ref> all) { if (all instanceof RefMap || (all instanceof SortedMap && ((SortedMap) all).comparator() == null)) return all.values(); return RefComparator.sort(all.values()); }
/** * Locate an entry by name. * * @param name * the name of the reference to find. * @return the index the reference is at. If the entry is not present * returns a negative value. The insertion position for the given * name can be computed from {@code -(index + 1)}. */ public final int find(String name) { int high = cnt; if (high == 0) return -1; int low = 0; do { final int mid = (low + high) >>> 1; final int cmp = RefComparator.compareTo(list[mid], name); if (cmp < 0) low = mid + 1; else if (cmp == 0) return mid; else high = mid; } while (low < high); return -(low + 1); }
for (Ref ref : RefComparator.sort(refs)) {
/** * Locate an entry by name. * * @param name * the name of the reference to find. * @return the index the reference is at. If the entry is not present * returns a negative value. The insertion position for the given * name can be computed from {@code -(index + 1)}. */ public final int find(String name) { int high = cnt; if (high == 0) return -1; int low = 0; do { final int mid = (low + high) >>> 1; final int cmp = RefComparator.compareTo(list[mid], name); if (cmp < 0) low = mid + 1; else if (cmp == 0) return mid; else high = mid; } while (low < high); return -(low + 1); }
private void addRefs(final Collection<Ref> refs, final String prefix) { for (final Ref ref : RefComparator.sort(refs)) { final String name = ref.getName(); if (name.startsWith(prefix)) addRef(name.substring(name.indexOf('/', 5) + 1), ref); } }
do { cur = curLoose.get(curIdx); int cmp = RefComparator.compareTo(cur, name); if (cmp < 0) {
private Iterable<Ref> getSortedRefs() throws Exception { Map<String, Ref> all = db.getRefDatabase().getRefs(ALL); if (all instanceof RefMap || (all instanceof SortedMap && ((SortedMap) all).comparator() == null)) return all.values(); return RefComparator.sort(all.values()); }
public Entry<String, Ref> peek() { if (packedIdx < packed.size() && looseIdx < loose.size()) { Ref p = packed.get(packedIdx); Ref l = loose.get(looseIdx); int cmp = RefComparator.compareTo(p, l); if (cmp < 0) { packedIdx++; return toEntry(p); } if (cmp == 0) packedIdx++; looseIdx++; return toEntry(resolveLoose(l)); } if (looseIdx < loose.size()) return toEntry(resolveLoose(loose.get(looseIdx++))); if (packedIdx < packed.size()) return toEntry(packed.get(packedIdx++)); return null; }