### Question:
Directory extends File implements Iterable<DirectoryEntry> { @VisibleForTesting DirectoryEntry remove(Name name) { int index = bucketIndex(name, table.length); DirectoryEntry prev = null; DirectoryEntry entry = table[index]; while (entry != null) { if (name.equals(entry.name())) { if (prev != null) { prev.next = entry.next; } else { table[index] = entry.next; } entry.next = null; entryCount--; entry.file().decrementLinkCount(); return entry; } prev = entry; entry = entry.next; } throw new IllegalArgumentException("no entry matching '" + name + "' in this directory"); } private  Directory(int id); private  Directory(int id, Name rootName); static Directory create(int id); static Directory createRoot(int id, Name name); DirectoryEntry entryInParent(); Directory parent(); boolean isEmpty(); @NullableDecl DirectoryEntry get(Name name); void link(Name name, File file); void unlink(Name name); ImmutableSortedSet<Name> snapshot(); @Override Iterator<DirectoryEntry> iterator();  }### Answer:
@Test public void testRemove() { dir.put(entry("foo")); dir.put(entry("bar")); dir.remove(Name.simple("foo")); assertThat(dir.entryCount()).isEqualTo(3); assertThat(ImmutableSet.copyOf(dir)) .containsExactly( entry("bar"), new DirectoryEntry(dir, Name.SELF, dir), new DirectoryEntry(dir, Name.PARENT, root)); assertThat(dir.get(Name.simple("foo"))).isNull(); assertThat(dir.get(Name.simple("bar"))).isEqualTo(entry("bar")); dir.remove(Name.simple("bar")); assertThat(dir.entryCount()).isEqualTo(2); dir.put(entry("bar")); dir.put(entry("foo")); }