Skip to content

Commit

Permalink
Merge pull request #10 from intuit/amatiushkin-patch-4
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
Alex Matiushkin authored Jul 13, 2020
2 parents 4ae0ea1 + 9a091e6 commit 3eab125
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,27 +426,16 @@ Nodes are enumerated in the breadth-first order

```java
// populate the company according example at the top of this discussion
Company c = new Company("Company")
.businessEntity(new BusinessEntity("BU-Pacific")
.team(new Team("PD=Product Development")
.member(new Member("Sylvester Moonstone"))
.member(new Member("John Smith"))
.member(new Member("Lucy Gold")))
.team(new Team("SL=Sales Department")
.member(new Member("Nick Citrine"))
.member(new Member("Kleo Ruby")))
.team(new Team("MG=Management")
.member(new Member("Anna Peridot"))));
Company c = ...

// create breadth-first pre-order iterator
TraversingIterator<Company> i = Traverser
.breadthFirst(Node::getChildren)
.preOrderIterator(c);

// print names of the nodes in DFS sequence
// print names of the nodes in BFS sequence
while (i.hasNext()) {
Node node = i.next();
System.out.println(node.getName());
...
}
```
Output:
Expand Down Expand Up @@ -477,7 +466,7 @@ TraversingIterator<Company> i = Traverser
.breadthFirst(Node::getChildren)
.postOrderIterator(c);

// print names of the nodes in DFS sequence
// print names of the nodes in BFS sequence
while (i.hasNext()) {
...
}
Expand Down Expand Up @@ -524,17 +513,7 @@ In order to avoid infinite recursion loop, Traverser does not discover children
#### Execute both pre- and post- order actions
```java
// populate the company according example at the top of this discussion
Company c = new Company("Company")
.businessEntity(new BusinessEntity("BU-Pacific")
.team(new Team("PD=Product Development")
.member(new Member("Sylvester Moonstone"))
.member(new Member("John Smith"))
.member(new Member("Lucy Gold")))
.team(new Team("SL=Sales Department")
.member(new Member("Nick Citrine"))
.member(new Member("Kleo Ruby")))
.team(new Team("MG=Management")
.member(new Member("Anna Peridot"))));
Company c = ...;

// create depth-first traverser and execute it
boolean foundKleoRuby = Traverser
Expand Down

0 comments on commit 3eab125

Please sign in to comment.