• Stars
    star
    251
  • Rank 161,862 (Top 4 %)
  • Language
    Swift
  • License
    Other
  • Created almost 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Swift collection of unique, ordered objects

Introduction

OrderedSet is essentially the Swift equivalent of Foundation's NSOrderedSet/NSMutableOrderedSet. It was created so Swift would have a unique, ordered collection with fast lookup performance that supported strong typing through Generics, and so we could store Swift structs and enums in it.

Usage

OrderedSet works very much like an Array. Here are some basic examples of its usage:

var set = OrderedSet<Int>()
set.append(1)
set.contains(1) // => true
set[0] = 2
set[0] // => 2
set.insert(3, at: 0)
set // => [3, 2]
set = [1,2,3] // OrderedSet's support array literals
set // => [1, 2, 3]
set += [3, 4] // You can concatenate any sequence type to an OrderedSet
set // => [1, 2, 3, 4] (Since 3 was already in the set it was not added again)

Its also recommended that you use the instance methods when possible instead of the global Swift methods for searching an OrderedSet. For example, the Swift.contains(haystack, needle) method will enumerate the OrderedSet instead of making use of the fast lookup implementation that the OrderedSet.contains(needle) method will do.

Be sure to check out the unit tests to see all the different ways to interact with an OrderedSet in action. You can also check out the sample project, which tweaks the default master/detail project to use an OrderedSet instead of an Array.

Installation

OrderedSet is a single Swift file in the Sources directory. You can copy that file into your project, or use via CocoaPods by adding the following line to your Podfile:

pod 'OrderedSet', '5.0'

or use via Carthage by adding

github "Weebly/OrderedSet"

to your Cartfile and embedding the OrderedSet.framework in your app.

And then add the following import where you want to use OrderedSet:

import OrderedSet

Using SwiftPM:

package.append(.package(url: "https://github.com/Weebly/OrderedSet.git", .upToNextMajor(from: "5.0.0")))

License

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

CONTRIBUTING

We love to have your help to make OrderedSet better. Feel free to

  • open an issue if you run into any problem.
  • fork the project and submit pull request.

More Repositories

1

Cereal

Swift object serialization
Swift
369
star
2

TableSchemer

Interactive static table views with ease
Swift
135
star
3

phpstan-laravel

Laravel plugins for PHPStan
PHP
51
star
4

JSONValue

Simple, awesome JSON representations in Swift
Swift
45
star
5

AnchorKit

A Swifty anchor-based API for AutoLayout.
Swift
45
star
6

Try

Handle Objective-C Exceptions with Swift's error handling system
Objective-C
21
star
7

laravel-mutate

Mutate Laravel attributes
PHP
13
star
8

Hare

Hare is a HTTP to RabbitMQ publishing gateway, written in Go
Go
12
star
9

php-webhook-client

Webhook client which sets up basic oauth flow and webhook event subscription.
PHP
10
star
10

weebly-client-php

A php client for using the Weebly Platform API
PHP
9
star
11

cloud-client-php

A php client for using the Weebly Cloud API
PHP
9
star
12

base-less-theme

This is the starting point for LESS based Weebly themes
JavaScript
7
star
13

base-css-theme

This is the starting point for css based Weebly themes
JavaScript
7
star
14

node-webhook-client

Webhook client which sets up basic oauth flow and webhook event subscription.
JavaScript
4
star
15

bootstrap-app

Smarty
4
star
16

node-weebly

CLI for Weebly Platform App Developers
JavaScript
4
star
17

cloud-client-python

A python client for using the Weebly Cloud API
Python
4
star
18

swift-jsonpatch

Swift
3
star
19

tinydns-filter

A filter to run before tinydns-data to handle extra resource record types
Perl
3
star
20

team-cards-app

Display an image and brief text in card format
JavaScript
3
star
21

ghost-io-php

Unofficial ghost.io API library for PHP
PHP
3
star
22

weeblybundler

WeeblyBundler is a CLI tool created to enable Weebly Platform Developers to rapidly deploy their apps and upload their themes
Ruby
3
star
23

simple-table-app

Add a table to your website
JavaScript
2
star
24

code-block-app

Display code at a glance
JavaScript
2
star
25

element-hello-world

A simple app to help Weebly Developers easily understand how Weebly Elements are constructed.
Smarty
2
star
26

cloud-client-java

A java client for using the Weebly Cloud API
Java
1
star
27

cloud-client-ruby

A ruby client for using the Weebly Cloud API
Ruby
1
star
28

accordion-app

Display only the most important information
JavaScript
1
star
29

TASTE

The Automated Selenium Testing Environment
Python
1
star