| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 unsigned ComposedTreeTraversal::countChildren(const Node& node) | 235 unsigned ComposedTreeTraversal::countChildren(const Node& node) |
| 236 { | 236 { |
| 237 assertPrecondition(node); | 237 assertPrecondition(node); |
| 238 unsigned count = 0; | 238 unsigned count = 0; |
| 239 for (Node* runner = traverseFirstChild(node); runner; runner = traverseNextS
ibling(*runner)) | 239 for (Node* runner = traverseFirstChild(node); runner; runner = traverseNextS
ibling(*runner)) |
| 240 ++count; | 240 ++count; |
| 241 return count; | 241 return count; |
| 242 } | 242 } |
| 243 | 243 |
| 244 Node* ComposedTreeTraversal::lastWithin(const Node& node) |
| 245 { |
| 246 assertPrecondition(node); |
| 247 Node* descendant = traverseLastChild(node); |
| 248 for (Node* child = descendant; child; child = lastChild(*child)) |
| 249 descendant = child; |
| 250 assertPostcondition(descendant); |
| 251 return descendant; |
| 252 } |
| 253 |
| 254 Node& ComposedTreeTraversal::lastWithinOrSelf(const Node& node) |
| 255 { |
| 256 assertPrecondition(node); |
| 257 Node* lastDescendant = lastWithin(node); |
| 258 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); |
| 259 assertPostcondition(&result); |
| 260 return result; |
| 261 } |
| 262 |
| 244 } // namespace | 263 } // namespace |
| OLD | NEW |