CompareOptions
These options apply to the various search/find and comparison methods (except where noted).
- iOS
- 8.0+
- macOS
- 10.0+
- tvOS
- 9.0+
- watchOS
- 2.0+
struct CompareOptions
These options apply to the various search/find and comparison methods (except where noted).
struct CompareOptions
import FoundationEssentials
import Swift
@frozen struct String
A Unicode string value that is a collection of characters.
init(_ characters: Slice<AttributedString.CharacterView>)
init?<S>(bytes: S, encoding: String.Encoding) where S : Sequence, S.Element == UInt8
Creates a new string equivalent to the given bytes interpreted in the specified encoding. Note: This API does not interpret embedded nulls as termination of the string. Use String?(validatingCString:)
instead for null-terminated C strings.
init(contentsOf url: URL, encoding enc: String.Encoding) throws
Produces a string created by reading data from a given URL interpreted using a given encoding.
init(contentsOf url: URL, usedEncoding: inout String.Encoding) throws
Produces a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.
init(contentsOfFile path: String, encoding enc: String.Encoding) throws
Produces a string created by reading data from the file at a given path interpreted using a given encoding.
init(contentsOfFile path: String, usedEncoding: inout String.Encoding) throws
Produces a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.
init?(data: Data, encoding: String.Encoding)
Returns a String
initialized by converting given data
into Unicode characters using a given encoding
.
func data(using encoding: String.Encoding, allowLossyConversion: Bool = false) -> Data?
func withFileSystemRepresentation<R>(_ block: (UnsafePointer<CChar>?) throws -> R) rethrows -> R
func withMutableFileSystemRepresentation<R>(_ block: (UnsafeMutablePointer<CChar>?) throws -> R) rethrows -> R
struct Encoding
protocol Equatable
A type that can be compared for value equality.
protocol ExpressibleByArrayLiteral
A type that can be initialized using an array literal.
protocol OptionSet : RawRepresentable, SetAlgebra
A type that presents a mathematical set interface to a bit set.
protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
protocol Sendable
protocol SetAlgebra<Element> : Equatable, ExpressibleByArrayLiteral
A type that provides mathematical set operations.
init(rawValue: UInt)
static let anchored: String.CompareOptions
Search is limited to start (or end, if .backwards
) of source string
static let backwards: String.CompareOptions
Search from end of source string
static let caseInsensitive: String.CompareOptions
static let diacriticInsensitive: String.CompareOptions
If specified, ignores diacritics (o-umlaut == o)
static let forcedOrdering: String.CompareOptions
If specified, comparisons are forced to return either .orderedAscending
or .orderedDescending
if the strings are equivalent but not strictly equal, for stability when sorting (e.g. “aaa” > “AAA” with .caseInsensitive
specified)
static let literal: String.CompareOptions
Exact character-by-character equivalence
static let numeric: String.CompareOptions
Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find
static let regularExpression: String.CompareOptions
The search string is treated as an ICU-compatible regular expression; if set, no other options can apply except .caseInsensitive
and .anchored
static let widthInsensitive: String.CompareOptions
If specified, ignores width differences (‘a’ == UFF41)
let rawValue: UInt
init()
Creates an empty option set.
init<S>(_ sequence: S) where S : Sequence, Self.Element == S.Element
Creates a new set from a finite sequence of items.
init(arrayLiteral: Self.Element...)
Creates a set containing the elements of the given array literal.
var isEmpty: Bool { get }
A Boolean value that indicates whether the set has no elements.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
func contains(_ member: Self) -> Bool
Returns a Boolean value that indicates whether a given element is a member of the option set.
mutating func formIntersection(_ other: Self)
Removes all elements of this option set that are not also present in the given set.
mutating func formSymmetricDifference(_ other: Self)
Replaces this set with a new set containing all elements contained in either this set or the given set, but not in both.
mutating func formUnion(_ other: Self)
Inserts the elements of another set into this option set.
@discardableResult mutating func insert(_ newMember: Self.Element) -> (inserted: Bool, memberAfterInsert: Self.Element)
Adds the given element to the option set if it is not already a member.
func intersection(_ other: Self) -> Self
Returns a new option set with only the elements contained in both this set and the given set.
func isDisjoint(with other: Self) -> Bool
Returns a Boolean value that indicates whether the set has no members in common with the given set.
func isStrictSubset(of other: Self) -> Bool
Returns a Boolean value that indicates whether this set is a strict subset of the given set.
func isStrictSuperset(of other: Self) -> Bool
Returns a Boolean value that indicates whether this set is a strict superset of the given set.
func isSubset(of other: Self) -> Bool
Returns a Boolean value that indicates whether the set is a subset of another set.
func isSuperset(of other: Self) -> Bool
Returns a Boolean value that indicates whether the set is a superset of the given set.
@discardableResult mutating func remove(_ member: Self.Element) -> Self.Element?
Removes the given element and all elements subsumed by it.
mutating func subtract(_ other: Self)
Removes the elements of the given set from this set.
func subtracting(_ other: Self) -> Self
Returns a new set containing the elements of this set that do not occur in the given set.
func symmetricDifference(_ other: Self) -> Self
Returns a new option set with the elements contained in this set or in the given set, but not in both.
func union(_ other: Self) -> Self
Returns a new option set of the elements contained in this set, in the given set, or in both.
@discardableResult mutating func update(with newMember: Self.Element) -> Self.Element?
Inserts the given element into the set.