Skip to content

Commit 9fb195d

Browse files
committed
adding a comment
1 parent 333667c commit 9fb195d

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/org/opensolaris/opengrok/configuration/Groups.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@
4040
*/
4141
public final class Groups {
4242

43+
/**
44+
* Interface used to perform an action to a single group.
45+
*/
4346
private interface Walker {
4447

4548
/**
4649
* @param g group
47-
* @return true if traversing should end, false otherwise
50+
* @return true if traversing should stop just after this group, false
51+
* otherwise
4852
*/
4953
boolean call(Group g);
5054
}
@@ -326,7 +330,19 @@ private static void deleteGroup(Set<Group> groups, String groupname) {
326330
}
327331
}
328332

329-
private static boolean treeTraverseGroups(Set<Group> groups, Walker f) {
333+
/**
334+
* Traverse the set of groups starting in top level groups (groups without a
335+
* parent group) and performing depth first search in the group's subgroups.
336+
*
337+
* @param groups set of groups (mixed top level and other groups)
338+
* @param walker an instance of {@link Walker} which is used for every
339+
* traversed group
340+
* @return true if {@code walker} emits true for any of the groups; false
341+
* otherwise
342+
*
343+
* @see Walker
344+
*/
345+
private static boolean treeTraverseGroups(Set<Group> groups, Walker walker) {
330346
LinkedList<Group> stack = new LinkedList<>();
331347
for (Group g : groups) {
332348
// the flag here represents the group's depth in the group tree
@@ -340,7 +356,7 @@ private static boolean treeTraverseGroups(Set<Group> groups, Walker f) {
340356
Group g = stack.getFirst();
341357
stack.removeFirst();
342358

343-
if (f.call(g)) {
359+
if (walker.call(g)) {
344360
return true;
345361
}
346362

@@ -351,9 +367,17 @@ private static boolean treeTraverseGroups(Set<Group> groups, Walker f) {
351367
return false;
352368
}
353369

354-
private static boolean linearTraverseGroups(Set<Group> groups, Walker f) {
370+
/**
371+
* Traverse the set of groups linearly based on the set's iterator.
372+
*
373+
* @param groups set of groups (mixed top level and other groups)
374+
* @param walker an instance of {@link Walker} which is used for every
375+
* traversed group
376+
* @return true if {@code walker} emits true for any of the groups; false
377+
*/
378+
private static boolean linearTraverseGroups(Set<Group> groups, Walker walker) {
355379
for (Group g : groups) {
356-
if (f.call(g)) {
380+
if (walker.call(g)) {
357381
return true;
358382
}
359383
}

0 commit comments

Comments
 (0)