Skip to content

Instantly share code, notes, and snippets.

View oozoofrog's full-sized avatar

oozoofrog oozoofrog

View GitHub Profile
protocol PatternComparable {}
struct Pattern<C: Comparable>: PatternComparable {
let op: (lhs: C, rhs: C) -> Bool
let to: C
func compare(from: C) -> Bool {
return op(lhs: from, rhs: to)
}
}
func -=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) {
lhs = O(rawValue: lhs.rawValue ^ rhs.rawValue)
}
func +=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) {
lhs = O(rawValue: lhs.rawValue | rhs.rawValue)
}
func +<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O {
return O(rawValue: lhs.rawValue | rhs.rawValue)
}
func -<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O {
func -<T: Equatable> (lhs: Array<T>, rhs: Array<T>) -> Array<T> {
return lhs.filter({ (lv) -> Bool in
return false == rhs.contains(lv)
})
}
func |<T: Equatable> (lhs: [T], rhs: [T]) -> [T] {
return lhs + rhs.filter({ (rv) -> Bool in
return false == lhs.contains(rv)
})
import UIKit
@IBDesignable
class CharacterView: UIView {
let pathLayer = CAShapeLayer()
override func didMoveToSuperview() {
if nil != superview {
if pathLayer.superlayer != self.layer {
self.layer.addSublayer(pathLayer)
Array has moveForMin.
It is find min from &lt;from&gt; index <br/>**- from was bad choice. i thought -**
<br/>and move to &lt;moveTo&gt;
```objc
extension Array where Element: Comparable{
mutating func moveForMin(offset: Int = 0, moveTo to: Int) {
let subArray = self[offset..<self.count]
guard let minValue = subArray.min(isOrderedBefore: <) else {