func firstRange <D, R>(of: D, in: R) -> Range<Self.Index>?
Returns the first found range of the type’s data buffer.
その型のもつデータバッファの最初に見つかった範囲を返します。
Availability 有効性
Technology
func firstRange<D, R>(of: D, in: R) -> Range
<Self.Index
>? where D : DataProtocol
, R : RangeExpression
, Self.Index
== R.Bound
of
The data sequence to find. 捜すデータシーケンス。
in
A range to limit the scope of the search. 検索の領域を制限するある範囲。
The range, if found, of the first match of the provided data sequence. 提供されたデータシーケンスの最初の合致の範囲、もし見つかったならば。
An example of searching a constrained range within a data buffer for the first match: ある制約された範囲を、あるデータバッファ内で、その最初の合致を求めて検索する例:
let data: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
let pattern: [UInt8] = [2, 3, 4]
let possibleMatch = data.firstRange(of: pattern, in: 5...9)
// possibleMatch == nil
let match = data.firstRange(of: pattern, in: 2...9)
// match == 2..<5
func firstRange <D, R>(of: D, in: R) -> Range<Self.Index>?
func firstRange <D>(of: D) -> Range<Self.Index>?
func lastRange <D>(of: D) -> Range<Self.Index>?
func lastRange <D, R>(of: D, in: R) -> Range<Self.Index>?