Skip to content

Commit cda7c53

Browse files
author
Reed Es
committed
renamed misleading function name
1 parent 1a101f1 commit cda7c53

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Types scoped within `SimpleTree`:
5252

5353
- `func getParents(maxDepth: Int, excludeValues: ValueSet) -> [Node]`: Return the parent nodes, starting with immediate parent. Optional list of parent values to be excluded. A match will exclude further ancestors. Optional limit on depth.
5454

55-
- `func getAll(excludeValues: ValueSet) -> [Node]`: Fetch the node and its child nodes. Optional list of values for children to be excluded, along with their progeny. Traversal is breadth-first.
55+
- `func getSelfAndChildren(excludeValues: ValueSet) -> [Node]`: Fetch the node and its child nodes. Optional list of values for nodes to be excluded, along with their progeny. Traversal is breadth-first.
5656

5757
#### Node Search
5858

@@ -76,7 +76,7 @@ Types scoped within `SimpleTree`:
7676

7777
- `func getParentValues(maxDepth: Int, excludeValues: ValueSet) -> [T]`: Return the values of the parent nodes, starting with immediate parent. Optional list of parent values to be excluded. A match will exclude further ancestors. Optional limit on depth.
7878

79-
- `func getAllValues(excludeValues: ValueSet) -> [T]`: Fetch values for the node and its child nodes. Includes value of current node. Optional list of values for children to be excluded, along with their progeny. Traversal is breadth-first.
79+
- `func getSelfAndChildValues(excludeValues: ValueSet) -> [T]`: Fetch values for the node and its child nodes. Includes value of current node. Optional list of values for nodes to be excluded, along with their progeny. Traversal is breadth-first.
8080

8181
## See Also
8282

Sources/SimpleTree.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ extension SimpleTree {
103103
}
104104

105105
/// Fetch the node and its child nodes.
106-
/// Optional list of values for children to be excluded, along with their progeny.
106+
/// Optional list of values for nodes to be excluded, along with their progeny.
107107
/// Traversal is breadth-first.
108-
public func getAll(excludeValues: ValueSet = ValueSet()) -> [Node] {
108+
public func getSelfAndChildren(excludeValues: ValueSet = ValueSet()) -> [Node] {
109109
guard !excludeValues.contains(self.value) else { return [] }
110110
var nodes: [Node] = [self]
111111
nodes.append(contentsOf: getChildren(excludeValues: excludeValues))
@@ -223,9 +223,9 @@ extension SimpleTree {
223223
}
224224

225225
/// Fetch values for the node and its child nodes.
226-
/// Optional list of values for children to be excluded, along with their progeny.
226+
/// Optional list of values for nodes to be excluded, along with their progeny.
227227
/// Traversal is breadth-first.
228-
public func getAllValues(excludeValues: ValueSet = ValueSet()) -> [T] {
229-
getAll(excludeValues: excludeValues).map(\.value)
228+
public func getSelfAndChildValues(excludeValues: ValueSet = ValueSet()) -> [T] {
229+
getSelfAndChildren(excludeValues: excludeValues).map(\.value)
230230
}
231231
}

Tests/SimpleTreeTests.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,27 @@ class SimpleTreeTests: XCTestCase {
232232
let bar = foo.addChild(for: "bar")
233233
let baz = bar.addChild(for: "baz")
234234

235-
XCTAssertTrue(foo.getAllValues().contains("foo"))
236-
XCTAssertTrue(foo.getAllValues().contains("bar"))
237-
XCTAssertTrue(foo.getAllValues().contains("baz"))
238-
XCTAssertFalse(foo.getAllValues().contains("blah"))
239-
240-
XCTAssertFalse(bar.getAllValues().contains("foo"))
241-
XCTAssertTrue(bar.getAllValues().contains("bar"))
242-
XCTAssertTrue(bar.getAllValues().contains("baz"))
243-
XCTAssertFalse(bar.getAllValues().contains("blah"))
244-
245-
XCTAssertFalse(baz.getAllValues().contains("foo"))
246-
XCTAssertFalse(baz.getAllValues().contains("bar"))
247-
XCTAssertTrue(baz.getAllValues().contains("baz"))
248-
XCTAssertFalse(baz.getAllValues().contains("blah"))
235+
XCTAssertTrue(foo.getSelfAndChildValues().contains("foo"))
236+
XCTAssertTrue(foo.getSelfAndChildValues().contains("bar"))
237+
XCTAssertTrue(foo.getSelfAndChildValues().contains("baz"))
238+
XCTAssertFalse(foo.getSelfAndChildValues().contains("blah"))
239+
240+
XCTAssertFalse(bar.getSelfAndChildValues().contains("foo"))
241+
XCTAssertTrue(bar.getSelfAndChildValues().contains("bar"))
242+
XCTAssertTrue(bar.getSelfAndChildValues().contains("baz"))
243+
XCTAssertFalse(bar.getSelfAndChildValues().contains("blah"))
244+
245+
XCTAssertFalse(baz.getSelfAndChildValues().contains("foo"))
246+
XCTAssertFalse(baz.getSelfAndChildValues().contains("bar"))
247+
XCTAssertTrue(baz.getSelfAndChildValues().contains("baz"))
248+
XCTAssertFalse(baz.getSelfAndChildValues().contains("blah"))
249249
}
250250

251251
public func testGetAllValuesExcludeRoot() throws {
252252
let foo = SimpleTree<String>(value: "foo")
253253
_ = foo.addChild(for: "bar")
254254

255-
let actual = foo.getAllValues(excludeValues: Set(["foo"]))
255+
let actual = foo.getSelfAndChildValues(excludeValues: Set(["foo"]))
256256
XCTAssertFalse(actual.contains("foo"))
257257
XCTAssertFalse(actual.contains("bar"))
258258
}
@@ -262,7 +262,7 @@ class SimpleTreeTests: XCTestCase {
262262
let bar = foo.addChild(for: "bar")
263263
_ = bar.addChild(for: "baz")
264264

265-
let actual = foo.getAllValues(excludeValues: Set(["bar"]))
265+
let actual = foo.getSelfAndChildValues(excludeValues: Set(["bar"]))
266266
XCTAssertTrue(actual.contains("foo"))
267267
XCTAssertFalse(actual.contains("bar"))
268268
}
@@ -276,7 +276,7 @@ class SimpleTreeTests: XCTestCase {
276276
let bar = foo.addChild(for: "bar")
277277
_ = bar.addChild(for: "baz")
278278

279-
let actual = foo.getAllValues(excludeValues: Set(["blah"]))
279+
let actual = foo.getSelfAndChildValues(excludeValues: Set(["blah"]))
280280
XCTAssertTrue(actual.contains("foo"))
281281
XCTAssertFalse(actual.contains("blah"))
282282
XCTAssertFalse(actual.contains("bleh"))

0 commit comments

Comments
 (0)