Sometimes you need order

Overview

SwiftSortedList

Version License Platform

Usage

All you need is a Comparable object:

import SwiftSortedList

struct MyObj : Comparable {
    var id: Int
}

func ==(x: MyObj, y: MyObj) -> Bool {
    return x.id == y.id
}
func <(x: MyObj, y: MyObj) -> Bool {
    return x.id < y.id
}

Then you can use the SortedList:

// create a new sorted list

var sl = SortedList<MyObj>()


// add an object

let mo = MyObj(id: 1)
sl.addElement(mo)


// get an object

let mo2 = sl.getAt(0)
let mo2s = sl[0]
print(mo2 == mo2s)


// helpers functions

let size: Int = sl.count
let elements: [MyObj] = sl.array


// remove an object

sl.removeElement(mo)


// replace an object
let mo3 = MyObj(id: 3)
sl.replace(at: 0, with: mo3)
print(mo2 == sl[0]) // false
print(mo3 == sl[0]) // true

// loop

for el in sl.array {
    // do something with el
}

Installation

SwiftSortedList is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftSortedList"

Author

Alessandro Miliucci

License

SwiftSortedList is available under the MIT license. See the LICENSE file for more info.

You might also like...
The Bank you really need.

OmegaBank Репозиторий

The most perfect Swift Timer you'll ever need.

Timerable ⏰ The most perfect Swift Timer you'll ever need. A protocol-oriented Timer Factory with all the features you'll ever need. I wrote it in bot

Simple Swift class to provide all the configurations you need to create custom camera view in your app

Camera Manager This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. It follows orientatio

Using async / await on iOS 13: everything you need to know
Using async / await on iOS 13: everything you need to know

Using async / await on iOS 13: everything you need to know! 🚀 Content This repository contains the code sample I've used during December 14th's lives

Hue is the all-in-one coloring utility that you'll ever need
Hue is the all-in-one coloring utility that you'll ever need

Hue is the all-in-one coloring utility that you'll ever need. Usage Hex You can easily use hex colors with the init(hex:) convenience initializer on U

AZS - There are two frameworks in the pod file, you need to install them to work with the project
AZS - There are two frameworks in the pod file, you need to install them to work with the project

AZS There are two frameworks in the pod file, you need to install them to work w

CrispyCalendar is the calendar UI framework you need
CrispyCalendar is the calendar UI framework you need

Whether you are writing yet another one task tracker or calendar app, or simply want to offer the users to skip the joy of using UIDatePicker and let them quickly and efficiently select dates — CrispyCalendar is the calendar UI framework you need.

The only Connect API library you'd ever need

ConnectKit A Swift client for Infinite Flight's Connect APIs, built using the Network framework. Supported APIs IF Session Discovery Connect API V2 Op

SuggestionsKit is a framework for iOS that was created in order to provide developers with the opportunity to educate users on various features of applications.
SuggestionsKit is a framework for iOS that was created in order to provide developers with the opportunity to educate users on various features of applications.

SuggestionsKit is a framework for iOS that was created in order to provide developers with the opportunity to educate users

This library uses ARKit Face Tracking in order to catch user's smile.
This library uses ARKit Face Tracking in order to catch user's smile.

SmileToUnlock Make your users smile before opening the app :) Gif with the demonstration Installation Cocoapods The most preferable way to use this li

Use this package in order to ease up working with Combine URLSession.

Use this package in order to ease up working with Combine URLSession. We support working with Codable for all main HTTP methods GET, POST, PUT and DELETE. We also support MultipartUpload

ViperServices - Simple dependency injection container for services written for iOS in swift supporting boot order

ViperServices Introduction ViperServices is dependency injection container for iOS applications written in Swift. It is more lightweight and simple in

Realm RxSwift - This application was written in order to use Realm, RxSwift frameworks in real example

Realm_RxSwift This simple app was written to introduce basic operations of some

RMSUI - A Simple Swift MVVM architectured Rick & Morty UI app in order to practice SwiftUI & GraphQL

RMSUI A Simple Swift MVVM architectured "Rick & Morty UI" app 📲 in order to pra

In this project I chose MVVM architectural pattern in order to design applications structure.

SwinjectExample In this project I chose MVVM architectural pattern in order to design applications structure. Also I used "Swinject" framework for con

IOS Swift : Explain Higher-order Function Examples

IOS Swift : Explain Higher-order Function Examples

App created in UIKit in order to control users' games library
App created in UIKit in order to control users' games library

App created in UIKit in order to control users' games library. It's developed in Swift 5 with Storyboard, and relies in a ASP.Net API backend.

iScheduleYourDay is a watchOS 8.5 app that can help order your daily tasks
iScheduleYourDay is a watchOS 8.5 app that can help order your daily tasks

Currently developing an App for watchOS 8.5 to help order your tasks daily. The app is a simple approach to the actual Apple App Remainders to become an improved version of it

Food Order App for iOS. VIPER pattern, Alamofire and Firebase used.
Food Order App for iOS. VIPER pattern, Alamofire and Firebase used.

Nibble Yemek Sipariş Uygulaması Techcareer.net Techmasters IOS Bootcamp bitirme ödevi için hazırladığım bir yemek sipariş uygulaması. API KEY SON GEÇE

Owner
Bemind Interactive
Bemind Interactive
iScheduleYourDay is a watchOS 8.5 app that can help order your daily tasks

Currently developing an App for watchOS 8.5 to help order your tasks daily. The app is a simple approach to the actual Apple App Remainders to become an improved version of it

Marta Granero I Martí 2 Aug 11, 2022
pick the voice from the local storage.you can play and pause the voice

flutter_add_voice A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you starte

Mehrab Bozorgi 1 Nov 27, 2021
xFonts is an app that lets you install custom fonts on iOS and iPadOS.

xFonts xFonts is an app that lets you install custom fonts on iOS and iPadOS. Grab fonts from your iCloud Drive or Dropbox and add them to your collec

manolo 137 Dec 10, 2022
BowTies - The main purpose of this application is to show how you can perform simple operations using Core Data

BowTies The main purpose of this application is to show how you can perform simp

slemeshaev 1 Jan 31, 2022
CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit)

CodableCloudKit CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit) Features ℹ️ Add CodableCloudKit f

Laurent Grondin 65 Oct 23, 2022
A simple order manager, created in order to try Realm database

Overview A simple order manager, created in order to get acquainted with the features and limitations of the local Realm database. The project is writ

Kirill Sidorov 0 Oct 14, 2021
Haven't you wished for `try` to sometimes try a little harder? Meet `retry`

Retry Example Haven't you wished for try to sometimes try a little harder? Meet retry To run the example project, clone the repo, and run pod install

Marin Todorov 500 Dec 13, 2022
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

MJExtension A fast, convenient and nonintrusive conversion framework between JSON and model. 转换速度快、使用简单方便的字典转模型框架 ?? ✍??Release Notes: more details Co

M了个J 8.5k Jan 3, 2023
This is OTPView made by HsynLoyiii in order to use in your login flow or whereever need it.

CustomOTPView This is OTPView made by HsynLoyiii in order to use in your login flow or wherever need it. It can use in IOS 15 and later in SwiftUI pro

Mohamad Hosein Hakimi 2 Jul 12, 2022
Hue is the all-in-one coloring utility that you'll ever need.

Hue is the all-in-one coloring utility that you'll ever need. Usage Hex You can easily use hex colors with the init(hex:) convenience initializer on U

Christoffer Winterkvist 3.4k Jan 3, 2023