Latest 1.2
Homepage https://github.com/robrix/Set
License MIT
Platforms ios 7.0, osx 10.9, requires ARC
Authors , ,

Build status

This is a Swift microframework which implements a PredicateSet and a Dictionary-backed Multiset.

Use

Multiset:

// Union
Multiset(1, 2, 3) + Multiset(3, 4, 5) // == Multiset(1, 2, 3, 3, 4, 5)

// Difference
Multiset(1, 2, 3) - Multiset(2, 3) // == Multiset(1)

// Intersection
Multiset(1, 2, 3) & Multiset(3, 4, 5) // == Multiset(3)

PredicateSet:

// Union
let union = PredicateSet { $0 > 0 } + PredicateSet { $0 % 2 == 0 }
union.contains(3) // true

// Difference
let difference = PredicateSet { $0 > 0 } - PredicateSet { $0 % 2 == 0 }
difference.contains(6) // false

// Special Sets
func isInt(number: Float) -> Bool {
    return Float(Int(number)) == number
}

let Q: PredicateSet<Float> = PredicateSet { _ in true } // Set of all real numbers.
let Z = Q & PredicateSet { isInt($0) } // Set of all integers.
let N = Z & PredicateSet { $0 > 0 } // Set of all natural numbers.

N.contains(1) // true
N.contains(-1.5) // false

See Multiset.swift and PredicateSet.swift for more details.

Integration

  1. Add this repo as a submodule in e.g. External/Set:

    git submodule add https://github.com/robrix/Set.git External/Set
  2. Drag Set.xcodeproj into your .xcworkspace/.xcodeproj.
  3. Add Set.framework to your target’s Link Binary With Libraries build phase.
  4. You may also want to add a Copy Files phase which copies Set.framework (and any other framework dependencies you need) into your bundle’s Frameworks directory. If your target is a framework, you may instead want the client app to include Set.framework.

Thanks

Latest podspec

{
    "name": "Set",
    "version": "1.2",
    "summary": "An implementation of a Dictionary-backed Set in Swift.",
    "homepage": "https://github.com/robrix/Set",
    "authors": {
        "Rob Rix": "[email protected]",
        "Adam Sharp": "[email protected]",
        "Ingmar Stein": "[email protected]"
    },
    "source": {
        "git": "https://github.com/robrix/Set.git",
        "tag": "1.2"
    },
    "platforms": {
        "ios": "7.0",
        "osx": "10.9"
    },
    "source_files": "Set/*.swift",
    "requires_arc": true,
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "description": "This is a Swift microframework which implements a Dictionary-backed Set.n"
}

Pin It on Pinterest

Share This