Adds the key, value pair. If key already has values, value is added to the end. Duplicate values for the same key are permitted. @throws NullPointerException if key or value is null
(Key<T> key, T value)
| 340 | * @throws NullPointerException if key or value is null |
| 341 | */ |
| 342 | public <T> void put(Key<T> key, T value) { |
| 343 | Preconditions.checkNotNull(key, "key"); |
| 344 | Preconditions.checkNotNull(value, "value"); |
| 345 | maybeExpand(); |
| 346 | name(size, key.asciiName()); |
| 347 | if (key.serializesToStreams()) { |
| 348 | value(size, LazyValue.create(key, value)); |
| 349 | } else { |
| 350 | value(size, key.toBytes(value)); |
| 351 | } |
| 352 | size++; |
| 353 | } |
| 354 | |
| 355 | private void maybeExpand() { |
| 356 | if (len() == 0 || len() == cap()) { |