final ReferenceContainer<WordReference> c = (remaining >= container.size()) ? container : trimContainer(container, remaining);
// iterate through the entries in the container and check if the reference is in the repository
final Iterator<WordReference> i = c.entries();
final List<byte[]> notFoundx = new ArrayList<byte[]>();
while (i.hasNext()) {
final WordReference e = i.next();
if (this.references.containsKey(e.urlhash())) continue;
if (this.badReferences.has(e.urlhash())) {
notFoundx.add(e.urlhash());
continue;
}
final URIMetadataRow r = Transmission.this.segment.urlMetadata().load(e.urlhash());
if (r == null) {
notFoundx.add(e.urlhash());
this.badReferences.put(e.urlhash());
} else {
this.references.put(e.urlhash(), r);
}
}
// now delete all references that were not found
for (final byte[] b : notFoundx) c.removeReference(b);
// finally add the remaining container to the cache