Skip to content

Commit

Permalink
renamed misleading function name
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Nov 18, 2021
1 parent 1a101f1 commit cda7c53
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Types scoped within `SimpleTree`:

- `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.

- `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.
- `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.

#### Node Search

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

- `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.

- `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.
- `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.

## See Also

Expand Down
10 changes: 5 additions & 5 deletions Sources/SimpleTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ extension SimpleTree {
}

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

/// Fetch values for the node and its child nodes.
/// Optional list of values for children to be excluded, along with their progeny.
/// Optional list of values for nodes to be excluded, along with their progeny.
/// Traversal is breadth-first.
public func getAllValues(excludeValues: ValueSet = ValueSet()) -> [T] {
getAll(excludeValues: excludeValues).map(\.value)
public func getSelfAndChildValues(excludeValues: ValueSet = ValueSet()) -> [T] {
getSelfAndChildren(excludeValues: excludeValues).map(\.value)
}
}
34 changes: 17 additions & 17 deletions Tests/SimpleTreeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,27 @@ class SimpleTreeTests: XCTestCase {
let bar = foo.addChild(for: "bar")
let baz = bar.addChild(for: "baz")

XCTAssertTrue(foo.getAllValues().contains("foo"))
XCTAssertTrue(foo.getAllValues().contains("bar"))
XCTAssertTrue(foo.getAllValues().contains("baz"))
XCTAssertFalse(foo.getAllValues().contains("blah"))

XCTAssertFalse(bar.getAllValues().contains("foo"))
XCTAssertTrue(bar.getAllValues().contains("bar"))
XCTAssertTrue(bar.getAllValues().contains("baz"))
XCTAssertFalse(bar.getAllValues().contains("blah"))

XCTAssertFalse(baz.getAllValues().contains("foo"))
XCTAssertFalse(baz.getAllValues().contains("bar"))
XCTAssertTrue(baz.getAllValues().contains("baz"))
XCTAssertFalse(baz.getAllValues().contains("blah"))
XCTAssertTrue(foo.getSelfAndChildValues().contains("foo"))
XCTAssertTrue(foo.getSelfAndChildValues().contains("bar"))
XCTAssertTrue(foo.getSelfAndChildValues().contains("baz"))
XCTAssertFalse(foo.getSelfAndChildValues().contains("blah"))

XCTAssertFalse(bar.getSelfAndChildValues().contains("foo"))
XCTAssertTrue(bar.getSelfAndChildValues().contains("bar"))
XCTAssertTrue(bar.getSelfAndChildValues().contains("baz"))
XCTAssertFalse(bar.getSelfAndChildValues().contains("blah"))

XCTAssertFalse(baz.getSelfAndChildValues().contains("foo"))
XCTAssertFalse(baz.getSelfAndChildValues().contains("bar"))
XCTAssertTrue(baz.getSelfAndChildValues().contains("baz"))
XCTAssertFalse(baz.getSelfAndChildValues().contains("blah"))
}

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

let actual = foo.getAllValues(excludeValues: Set(["foo"]))
let actual = foo.getSelfAndChildValues(excludeValues: Set(["foo"]))
XCTAssertFalse(actual.contains("foo"))
XCTAssertFalse(actual.contains("bar"))
}
Expand All @@ -262,7 +262,7 @@ class SimpleTreeTests: XCTestCase {
let bar = foo.addChild(for: "bar")
_ = bar.addChild(for: "baz")

let actual = foo.getAllValues(excludeValues: Set(["bar"]))
let actual = foo.getSelfAndChildValues(excludeValues: Set(["bar"]))
XCTAssertTrue(actual.contains("foo"))
XCTAssertFalse(actual.contains("bar"))
}
Expand All @@ -276,7 +276,7 @@ class SimpleTreeTests: XCTestCase {
let bar = foo.addChild(for: "bar")
_ = bar.addChild(for: "baz")

let actual = foo.getAllValues(excludeValues: Set(["blah"]))
let actual = foo.getSelfAndChildValues(excludeValues: Set(["blah"]))
XCTAssertTrue(actual.contains("foo"))
XCTAssertFalse(actual.contains("blah"))
XCTAssertFalse(actual.contains("bleh"))
Expand Down

0 comments on commit cda7c53

Please sign in to comment.