Skip to content

Instantly share code, notes, and snippets.

@mathieubolla
Created January 19, 2012 15:36
Show Gist options
  • Save mathieubolla/1640626 to your computer and use it in GitHub Desktop.
Save mathieubolla/1640626 to your computer and use it in GitHub Desktop.
What the fuck does this method do? Java puzzle #2 at work
/**
* Retrieves all descendants in breadth-first enumeration.
* Ordering for a particular level is undetermined.
*/
public List<Folder> getDescendants() {
List<Folder> folders = new ArrayList<Folder>(getChildren());
int i = 0;
while(i < folders.size()) {
Folder folder = folders.get(i);
folders.addAll(folder.getChildren());
i++;
}
return folders;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment