String.UTF16View.Index

struct String.UTF16View.Index
Inheritance BidirectionalIndexType, Comparable, Equatable, ForwardIndexType, RandomAccessIndexType, Strideable, _BidirectionalIndexType, _Comparable, _ForwardIndexType, _Incrementable, _RandomAccessIndexType, _Strideable View Protocol Hierarchy →
Associated Types
Distance = Int
Import import Swift

Initializers

init(_:)

[Foundation] Construct from an integer offset.

Declaration

init(_ offset: Int)
init(_: String.Index, within: String.UTF16View)

Construct the position in utf16 that corresponds exactly to characterIndex.

Requires: characterIndex is an element of indices(String(utf16)!).

Declaration

init(_ characterIndex: String.Index, within utf16: String.UTF16View)
init(_: UnicodeScalarIndex, within: String.UTF16View)

Construct the position in utf16 that corresponds exactly to unicodeScalarIndex.

Requires: unicodeScalarIndex is an element of indices(String(utf16)!.unicodeScalars).

Declaration

init(_ unicodeScalarIndex: UnicodeScalarIndex, within utf16: String.UTF16View)
init?(_:within:)

Construct the position in utf16 that corresponds exactly to utf8Index. If no such position exists, the result is nil.

Requires: utf8Index is an element of indices(String(utf16)!.utf8).

Declaration

init?(_ utf8Index: UTF8Index, within utf16: String.UTF16View)

Instance Methods

func advancedBy(_:)

[Foundation] Return self offset by n steps.

Returns: If n > 0, the result of applying successor to self n times. If n < 0, the result of applying predecessor to self -n times. Otherwise, self.

Complexity: O(1)

Declaration

func advancedBy(x: Int) -> String.UTF16View.Index
func distanceTo(_:)

[Foundation] Return the minimum number of applications of successor or predecessor required to reach other from self.

Complexity: O(1).

Declaration

func distanceTo(x: String.UTF16View.Index) -> Int
func predecessor()

Declaration

func predecessor() -> String.UTF16View.Index
func samePositionIn(_: String)

Return the position in characters that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(characters.utf16).

Declaration

func samePositionIn(characters: String) -> String.Index?
func samePositionIn(_: String.UTF8View)

Return the position in utf8 that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(String(utf8)!.utf16).

Declaration

func samePositionIn(utf8: String.UTF8View) -> String.UTF8View.Index?
func samePositionIn(_: String.UnicodeScalarView)

Return the position in unicodeScalars that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(String(unicodeScalars).utf16).

Declaration

func samePositionIn(unicodeScalars: String.UnicodeScalarView) -> UnicodeScalarIndex?
func successor()

Declaration

func successor() -> String.UTF16View.Index