Contents

remove(_:)

Searches for the specified object and removes it from the tree.

Declaration

func remove(_ element: ElementType) -> Bool

Parameters

  • element:

    The object to be removed from the tree.

Return Value

true if the object was removed from the tree. false if the specified object is not in the tree.

Discussion

The tree does not directly reference its elements—quadtrees are optimized to search for elements based on spatial positions—so this method must exhaustively search the entire tree to find the object to remove. For quicker removal, keep a reference to the GKQuadtreeNode object returned when you add an object to the tree, and call the remove(_:using:) method instead.

See Also

Adding and Removing Elements