SortedArray

0.7.0

An array that keeps its elements sorted according to a given sort predicate.
ole/SortedArray

What's New

0.7.0

2018-06-18T16:39:52Z
  • Drop Swift 3.x support. Please continue to use version 0.6.0 if you need Swift 3 compatibility. The lowest supported version is now Swift 4.0.

  • Compatibility with Swift 4.2.

  • SortedArray now conditionally conforms to Equatable (on Swift 4.1 and up) and Hashable (on Swift 4.2 and up) if its Element type is Equatable or Hashable. Note that the comparator function is not considered for determining equality.

  • Added SortedArray.firstIndex(of:) as an alias for index(of:) (following the standard library). The old method isn’t deprecated yet, but may be in a future release.

  • The binary search is now implemented using recursion, which (surprisingly to me) turned out to be faster (#21). Thanks @kareman.

  • General cleanup because we no longer need to support Swift 3. Thanks @klaaspieter.

  • The performance tests are now in a separate target and do no longer run by default when you hit Cmd+U in Xcode. This speeds up the test suite. On the command line, use swift test --parallel --filter UnitTests to only run the unit tests.

SortedArray

A sorted array type for Swift 4.0+.

Provides the SortedArray type, an array that keeps its elements sorted according to a given sort predicate.

Written by Ole Begemann, February 2017.

For more info, see the GitHub repo and my accompanying blog article.

Status

Build Status

Supported Platforms

The current release supports Swift 4.0 and up.

If you need support for older Swift version, here's a list of the latest releases that support specific Swift versions:

Swift version Latest SortedArray release
4.x master
3.x 0.6.0
3.0 0.4

Since the code has no dependencies other than the Swift standard library (it doesn't even use Foundation), it should work on all platforms where Swift is available.

I tested it on macOS, iOS, tvOS, and Linux.

Usage

Swift Package Manager

Add this to your Package.swift file:

// Package.swift
import PackageDescription

let package = Package(
    name: "<Your package name>",
    dependencies: [
        .Package(url: "https://github.com/ole/SortedArray.git", majorVersion: 0)
    ]
)

Carthage

Add this to your Cartfile:

github "ole/SortedArray" ~> 0.7

Integration via Carthage should work for macOS, iOS, tvOS, and watchOS targets.

Manually

Clone the repository and add or copy SortedArray.swift to your project. It has no dependencies.

Dependencies

None.

License

MIT license.

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 24 2024 05:38:26 GMT-0900 (Hawaii-Aleutian Daylight Time)