@Test public void discardAll() { Fish lance = new Fish(LANCE); Metadata metadata = new Metadata(); metadata.put(KEY, lance); metadata.discardAll(KEY); assertNull(metadata.getAll(KEY)); assertNull(metadata.get(KEY)); }
@ExperimentalApi("https: public <T> void discardAll(Key<T> key) { if (isEmpty()) { return; } int writeIdx = 0; int readIdx = 0; for (; readIdx < size; readIdx++) { if (bytesEqual(key.asciiName(), name(readIdx))) { continue; } name(writeIdx, name(readIdx)); value(writeIdx, value(readIdx)); writeIdx++; } int newSize = writeIdx; Arrays.fill(namesAndValues, writeIdx * 2, len(), null); size = newSize; }
Metadata { @ExperimentalApi("https: public <T> void discardAll(Key<T> key) { if (isEmpty()) { return; } int writeIdx = 0; int readIdx = 0; for (; readIdx < size; readIdx++) { if (bytesEqual(key.asciiName(), name(readIdx))) { continue; } name(writeIdx, name(readIdx)); value(writeIdx, value(readIdx)); writeIdx++; } int newSize = writeIdx; Arrays.fill(namesAndValues, writeIdx * 2, len(), null); size = newSize; } }
Metadata { @ExperimentalApi("https: public <T> void discardAll(Key<T> key) { if (isEmpty()) { return; } int writeIdx = 0; int readIdx = 0; for (; readIdx < size; readIdx++) { if (bytesEqual(key.asciiName(), name(readIdx))) { continue; } name(writeIdx, name(readIdx)); value(writeIdx, value(readIdx)); writeIdx++; } int newSize = writeIdx; Arrays.fill(namesAndValues, writeIdx * 2, len(), null); size = newSize; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); }
Metadata { @ExperimentalApi("https: public <T> void discardAll(Key<T> key) { if (isEmpty()) { return; } int writeIdx = 0; int readIdx = 0; for (; readIdx < size; readIdx++) { if (bytesEqual(key.asciiName(), name(readIdx))) { continue; } name(writeIdx, name(readIdx)); value(writeIdx, value(readIdx)); writeIdx++; } int newSize = writeIdx; Arrays.fill(namesAndValues, writeIdx * 2, len(), null); size = newSize; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); boolean containsKey(Key<?> key); @Nullable T get(Key<T> key); @Nullable Iterable<T> getAll(final Key<T> key); @SuppressWarnings("deprecation") // The String ctor is deprecated, but fast. Set<String> keys(); void put(Key<T> key, T value); boolean remove(Key<T> key, T value); Iterable<T> removeAll(Key<T> key); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4691") void discardAll(Key<T> key); void merge(Metadata other); void merge(Metadata other, Set<Key<?>> keys); @SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0 @Override String toString(); }
Metadata { @ExperimentalApi("https: public <T> void discardAll(Key<T> key) { if (isEmpty()) { return; } int writeIdx = 0; int readIdx = 0; for (; readIdx < size; readIdx++) { if (bytesEqual(key.asciiName(), name(readIdx))) { continue; } name(writeIdx, name(readIdx)); value(writeIdx, value(readIdx)); writeIdx++; } int newSize = writeIdx; Arrays.fill(namesAndValues, writeIdx * 2, len(), null); size = newSize; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); boolean containsKey(Key<?> key); @Nullable T get(Key<T> key); @Nullable Iterable<T> getAll(final Key<T> key); @SuppressWarnings("deprecation") // The String ctor is deprecated, but fast. Set<String> keys(); void put(Key<T> key, T value); boolean remove(Key<T> key, T value); Iterable<T> removeAll(Key<T> key); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4691") void discardAll(Key<T> key); void merge(Metadata other); void merge(Metadata other, Set<Key<?>> keys); @SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0 @Override String toString(); static final String BINARY_HEADER_SUFFIX; static final BinaryMarshaller<byte[]> BINARY_BYTE_MARSHALLER; static final AsciiMarshaller<String> ASCII_STRING_MARSHALLER; }