Swift · Comparison and Equality

Comparison and Equality

import StringZilla 6.0.0-rc.1 · 91a27bdd

Comparisons are SIMD-accelerated and return a StringZillaOrdering of .ascending, .equal, or .descending, or a Bool.

assert("apple".compare("banana") == .ascending)  // byte-order lexicographic
assert("abc".equals("abc"))                       // byte-level equality

utf8UncasedOrder(_:) performs the same ordering but with full Unicode case folding, so "STRASSE" and "straße" compare as equal.

assert("STRASSE".utf8UncasedOrder("straße") == .equal)

API

EnumStringZillaOrderingResult of a three-way string comparison.
StringProtocol+StringZilla.swift:25 ↗
enum StringZillaOrdering

Mirrors Foundation.ComparisonResult but is defined here so the package stays Foundation-free and usable on Linux and embedded targets. The cases match the verdicts of the exact and case-insensitive orderings.

Values

ascending
equal
descending

Conforms to

Equatable, Hashable, Sendable