private Group(PathFilter[] pathFilters) { fullpaths = new ByteArraySet(pathFilters.length); prefixes = new ByteArraySet(pathFilters.length / 5); int hash = hasher.nextHash(); if (hasher.hasNext()) prefixes.addIfAbsent(pf.pathRaw, hasher.length(), hash); fullpaths.addIfAbsent(pf.pathRaw, pf.pathRaw.length, hasher.getHash()); if (compare(max, pf.pathRaw) < 0)
/** {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); for (byte[] b : table) { if (b == null) continue; if (sb.length() > 1) sb.append(" , "); //$NON-NLS-1$ sb.append('"'); sb.append(RawParseUtils.decode(b)); sb.append('"'); sb.append('('); sb.append(chainlength(b)); sb.append(')'); } sb.append(']'); return sb.toString(); }
if (equals(obj, newValue, length)) return obj; i = (i + 1) & msk; byte[] valueToInsert = copyIfNotSameSize(newValue, length); if (++size == grow) { grow(); insert(valueToInsert, hash); } else tbl[i] = valueToInsert;
private byte[] get(byte[] toFind, int length, int hash) { final int msk = mask; int i = hash & msk; final byte[][] tbl = table; byte[] obj; while ((obj = tbl[i]) != null) { if (equals(obj, toFind, length)) return obj; i = (i + 1) & msk; } return null; }
/** * Create an empty set. * * @param capacity */ ByteArraySet(int capacity) { initTable(1 << Integer.highestOneBit((capacity * 2) - 1)); }
/** * Returns true if this set contains the specified array. * * @param toFind * array to find. * @param length * The number of bytes in toFind that are used * @param hash * pre-computed hash of toFind * @return true if the mapping exists for this byte array; false otherwise. */ boolean contains(byte[] toFind, int length, int hash) { return get(toFind, length, hash) != null; }
@Override public boolean include(TreeWalk walker) { byte[] rp = walker.getRawPath(); Hasher hasher = new Hasher(rp, walker.getPathLength()); while (hasher.hasNext()) { int hash = hasher.nextHash(); if (fullpaths.contains(rp, hasher.length(), hash)) return true; if (!hasher.hasNext() && walker.isSubtree() && prefixes.contains(rp, hasher.length(), hash)) return true; } final int cmp = walker.isPathPrefix(max, max.length); if (cmp > 0) throw StopWalkException.INSTANCE; return false; }
private int chainlength(byte[] b) { Hasher h = new Hasher(b, b.length); int hash = h.hash(); final int msk = mask; int i = hash & msk; final byte[][] tbl = table; byte[] obj; int n = 0; while ((obj = tbl[i]) != null) { if (equals(obj, b, b.length)) return n; i = (i + 1) & msk; ++n; } return -1; }
/** * Create an empty set. * * @param capacity */ ByteArraySet(int capacity) { initTable(1 << Integer.highestOneBit((capacity * 2) - 1)); }
/** * Returns true if this set contains the specified array. * * @param toFind * array to find. * @param length * The number of bytes in toFind that are used * @param hash * pre-computed hash of toFind * @return true if the mapping exists for this byte array; false otherwise. */ boolean contains(final byte[] toFind, int length, int hash) { return get(toFind, length, hash) != null; }
@Override public boolean include(final TreeWalk walker) { byte[] rp = walker.getRawPath(); Hasher hasher = new Hasher(rp, walker.getPathLength()); while (hasher.hasNext()) { int hash = hasher.nextHash(); if (fullpaths.contains(rp, hasher.length(), hash)) return true; if (!hasher.hasNext() && walker.isSubtree() && prefixes.contains(rp, hasher.length(), hash)) return true; } final int cmp = walker.isPathPrefix(max, max.length); if (cmp > 0) throw StopWalkException.INSTANCE; return false; }
if (equals(obj, newValue, length)) return obj; i = (i + 1) & msk; byte[] valueToInsert = copyIfNotSameSize(newValue, length); if (++size == grow) { grow(); insert(valueToInsert, hash); } else tbl[i] = valueToInsert;
private Group(PathFilter[] pathFilters) { fullpaths = new ByteArraySet(pathFilters.length); prefixes = new ByteArraySet(pathFilters.length / 5); int hash = hasher.nextHash(); if (hasher.hasNext()) prefixes.addIfAbsent(pf.pathRaw, hasher.length(), hash); fullpaths.addIfAbsent(pf.pathRaw, pf.pathRaw.length, hasher.getHash()); if (compare(max, pf.pathRaw) < 0)
private byte[] get(final byte[] toFind, int length, int hash) { final int msk = mask; int i = hash & msk; final byte[][] tbl = table; byte[] obj; while ((obj = tbl[i]) != null) { if (equals(obj, toFind, length)) return obj; i = (i + 1) & msk; } return null; }
/** * Create an empty set. * * @param capacity */ ByteArraySet(int capacity) { initTable(1 << Integer.highestOneBit((capacity * 2) - 1)); }
/** * Returns true if this set contains the specified array. * * @param toFind * array to find. * @param length * The number of bytes in toFind that are used * @param hash * pre-computed hash of toFind * @return true if the mapping exists for this byte array; false otherwise. */ boolean contains(byte[] toFind, int length, int hash) { return get(toFind, length, hash) != null; }
@Override public boolean include(TreeWalk walker) { byte[] rp = walker.getRawPath(); Hasher hasher = new Hasher(rp, walker.getPathLength()); while (hasher.hasNext()) { int hash = hasher.nextHash(); if (fullpaths.contains(rp, hasher.length(), hash)) return true; if (!hasher.hasNext() && walker.isSubtree() && prefixes.contains(rp, hasher.length(), hash)) return true; } final int cmp = walker.isPathPrefix(max, max.length); if (cmp > 0) throw StopWalkException.INSTANCE; return false; }