Created
January 19, 2012 15:36
-
-
Save mathieubolla/1640626 to your computer and use it in GitHub Desktop.
What the fuck does this method do? Java puzzle #2 at work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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