### Question:
BinaryHeaderMap implements Recyclable, Iterable<BinaryHeaderMap.Entry> { public void copyFrom(BinaryHeaderMap other) { resetState(); keys.addAll(other.keys); ((Buffer) other.valueBuffer).flip(); if (valueBuffer.capacity() < other.valueBuffer.remaining()) { valueBuffer = CharBuffer.allocate(other.valueBuffer.remaining()); } valueBuffer.put(other.valueBuffer); if (this.valueLengths.length < other.valueLengths.length) { this.valueLengths = new int[other.valueLengths.length]; } System.arraycopy(other.valueLengths, 0, this.valueLengths, 0, other.valueLengths.length); } BinaryHeaderMap(); int size(); boolean isEmpty(); boolean add(String key, byte[] value); @Override void resetState(); @Override Iterator<Entry> iterator(); void copyFrom(BinaryHeaderMap other); static final int MAXIMUM_HEADER_BUFFER_SIZE; }### Answer:
@Test void testCopyFrom() { headerMap.add(String.valueOf(0), "value0".getBytes()); headerMap.add(String.valueOf(1), "value1".getBytes()); BinaryHeaderMap copy = new BinaryHeaderMap(); copy.add("foo", "bar".getBytes()); copy.copyFrom(headerMap); int index = 0; int numElements = 0; for (BinaryHeaderMap.Entry entry : copy) { numElements++; String indexS = String.valueOf(index++); assertThat(entry.getKey()).isEqualTo(indexS); assertThat(entry.getValue().toString()).isEqualTo("value" + indexS); } assertThat(numElements).isEqualTo(2); }