Structure

Scene.AnchorCollection

A collection of anchor entities.

Declaration

struct AnchorCollection

Topics

Comparing Collections

func elementsEqual<OtherSequence>(OtherSequence) -> Bool

Returns a Boolean value indicating whether this sequence and another sequence contain the same elements in the same order.

func elementsEqual<OtherSequence>(OtherSequence, by: (HasAnchoring, OtherSequence.Element) -> Bool) -> Bool

Returns a Boolean value indicating whether this sequence and another sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.

func starts<PossiblePrefix>(with: PossiblePrefix) -> Bool

Returns a Boolean value indicating whether the initial elements of the sequence are the same as the elements in another sequence.

func starts<PossiblePrefix>(with: PossiblePrefix, by: (HasAnchoring, PossiblePrefix.Element) -> Bool) -> Bool

Returns a Boolean value indicating whether the initial elements of the sequence are equivalent to the elements in another sequence, using the given predicate as the equivalence test.

func lexicographicallyPrecedes<OtherSequence>(OtherSequence, by: (HasAnchoring, HasAnchoring) -> Bool) -> Bool

Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.

Iterating Over the Collection

func makeIterator() -> Scene.AnchorCollection.Iterator

Returns an iterator over the elements of the collection.

func forEach((HasAnchoring) -> Void)

Calls the given closure on each element in the sequence in the same order as a for-in loop.

func enumerated() -> EnumeratedSequence<Scene.AnchorCollection>

Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero and x represents an element of the sequence.

var underestimatedCount: Int

A value less than or equal to the number of elements in the collection.

Counting Anchors

var count: Int

The number of elements in the collection.

var isEmpty: Bool

A Boolean value indicating whether the collection is empty.

Accessing Anchors

Finding Anchors

func contains(HasAnchoring) -> Bool

Returns a Boolean value indicating whether the sequence contains the given element.

func contains(where: (HasAnchoring) -> Bool) -> Bool

Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.

func allSatisfy((HasAnchoring) -> Bool) -> Bool

Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.

var first: HasAnchoring?

The first element of the collection.

func first(where: (HasAnchoring) -> Bool) -> HasAnchoring?

Returns the first element of the sequence that satisfies the given predicate.

func min(by: (HasAnchoring, HasAnchoring) -> Bool) -> HasAnchoring?

Returns the minimum element in the sequence, using the given predicate as the comparison between elements.

func max(by: (HasAnchoring, HasAnchoring) -> Bool) -> HasAnchoring?

Returns the maximum element in the sequence, using the given predicate as the comparison between elements.

Selecting Anchors

func filter((HasAnchoring) -> Bool) -> [HasAnchoring]

Returns an array containing, in order, the elements of the sequence that satisfy the given predicate.

func prefix(Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence, up to the specified maximum length, containing the initial elements of the collection.

func prefix(through: Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence from the start of the collection through the specified position.

func prefix(upTo: Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence from the start of the collection up to, but not including, the specified position.

func prefix(while: (HasAnchoring) -> Bool) -> Slice<Scene.AnchorCollection>

Returns a subsequence containing the initial elements until predicate returns false and skipping the remaining elements.

func suffix(Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence, up to the given maximum length, containing the final elements of the collection.

func suffix(from: Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence from the specified position to the end of the collection.

func randomElement() -> HasAnchoring?

Returns a random element of the collection.

func randomElement<T>(using: inout T) -> HasAnchoring?

Returns a random element of the collection, using the given generator as a source for randomness.

Transforming Anchors

func map<T>((HasAnchoring) -> T) -> [T]

Returns an array containing the results of mapping the given closure over the sequence’s elements.

func flatMap<SegmentOfResult>((HasAnchoring) -> SegmentOfResult) -> [SegmentOfResult.Element]

Returns an array containing the concatenated results of calling the given transformation with each element of this sequence.

func compactMap<ElementOfResult>((HasAnchoring) -> ElementOfResult?) -> [ElementOfResult]

Returns an array containing the non-nil results of calling the given transformation with each element of this sequence.

func reduce<Result>(Result, (Result, HasAnchoring) -> Result) -> Result

Returns the result of combining the elements of the sequence using the given closure.

func reduce<Result>(into: Result, (inout Result, HasAnchoring) -> ()) -> Result

Returns the result of combining the elements of the sequence using the given closure.

var lazy: LazySequence<Scene.AnchorCollection>

A sequence containing the same elements as this sequence, but on which some operations, such as map and filter, are implemented lazily.

Reordering Anchors

func sorted(by: (HasAnchoring, HasAnchoring) -> Bool) -> [HasAnchoring]

Returns the elements of the sequence, sorted using the given predicate as the comparison between elements.

func reversed() -> [HasAnchoring]

Returns an array containing the elements of this sequence in reverse order.

func shuffled() -> [HasAnchoring]

Returns the elements of the sequence, shuffled.

func shuffled<T>(using: inout T) -> [HasAnchoring]

Returns the elements of the sequence, shuffled using the given generator as a source for randomness.

Excluding Anchors

func dropFirst(Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence containing all but the given number of initial elements.

func dropLast(Int) -> Slice<Scene.AnchorCollection>

Returns a subsequence containing all but the specified number of final elements.

func drop(while: (HasAnchoring) -> Bool) -> Slice<Scene.AnchorCollection>

Returns a subsequence by skipping elements while predicate returns true and returning the remaining elements.

Splitting the Collection

func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator: (HasAnchoring) -> Bool) -> [Slice<Scene.AnchorCollection>]

Returns the longest possible subsequences of the collection, in order, that don’t contain elements satisfying the given predicate.

func split(separator: HasAnchoring, maxSplits: Int, omittingEmptySubsequences: Bool) -> [ArraySlice<HasAnchoring>]

Returns the longest possible subsequences of the sequence, in order, around elements equal to the given element.

func split(separator: HasAnchoring, maxSplits: Int, omittingEmptySubsequences: Bool) -> [Slice<Scene.AnchorCollection>]

Returns the longest possible subsequences of the collection, in order, around elements equal to the given element.

Manipulating Indices

var indices: DefaultIndices<Scene.AnchorCollection>

The indices that are valid for subscripting the collection, in ascending order.

func index(Int, offsetBy: Int) -> Int

Returns an index that is the specified distance from the given index.

func index(Int, offsetBy: Int, limitedBy: Int) -> Int?

Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.

func index(of: HasAnchoring) -> Int?

Returns the first index where the specified value appears in the collection.

Deprecated
func firstIndex(of: HasAnchoring) -> Int?

Returns the first index where the specified value appears in the collection.

func firstIndex(where: (HasAnchoring) -> Bool) -> Int?

Returns the first index in which an element of the collection satisfies the given predicate.

func formIndex(inout Int, offsetBy: Int)

Offsets the given index by the specified distance.

func formIndex(inout Int, offsetBy: Int, limitedBy: Int) -> Bool

Offsets the given index by the specified distance, or so that it equals the given limiting index.

func formIndex(after: inout Int)

Replaces the given index with its successor.

func distance(from: Int, to: Int) -> Int

Returns the distance between two indices.

Accessing Underlying Storage

func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<HasAnchoring>) -> R) -> R?

Call body(p), where p is a pointer to the collection’s contiguous storage. If no such storage exists, it is first created. If the collection does not support an internal representation in a form of contiguous storage, body is not called and nil is returned.

Describing the Collection

Instance Methods

func index(where: (HasAnchoring) -> Bool) -> Int?

Returns the first index in which an element of the collection satisfies the given predicate.

Deprecated

Relationships

See Also

Adding and Removing Anchors

var anchors: Scene.AnchorCollection

The collection of anchors contained in the scene.

func addAnchor(HasAnchoring)

Adds an anchor to the scene’s list of anchors.

func removeAnchor(HasAnchoring)

Removes the specified anchor from the scene.