Swift 4.1 and <4.1 compatibility
This commit is contained in:
parent
2513dab395
commit
acf543fba1
|
@ -74,7 +74,11 @@ public class OrderedDictionary<Key: Hashable, Value: Equatable>: MutableCollecti
|
||||||
}
|
}
|
||||||
|
|
||||||
public var orderedValues: [Value] {
|
public var orderedValues: [Value] {
|
||||||
return _orderedKeys.compactMap { _keysToValues[$0] }
|
#if !swift(>=4.1)
|
||||||
|
return _orderedKeys.flatMap { _keysToValues[$0] }
|
||||||
|
#else
|
||||||
|
return _orderedKeys.compactMap { _keysToValues[$0] }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================= //
|
// ======================================================= //
|
||||||
|
|
|
@ -107,7 +107,12 @@ public class OrderedSet<T: Hashable> {
|
||||||
public func remove(_ object: T) {
|
public func remove(_ object: T) {
|
||||||
if let index = contents[object] {
|
if let index = contents[object] {
|
||||||
contents[object] = nil
|
contents[object] = nil
|
||||||
sequencedContents[index].deallocate()
|
#if !swift(>=4.1)
|
||||||
|
sequencedContents[index].deallocate(capacity: 1)
|
||||||
|
#else
|
||||||
|
sequencedContents[index].deallocate()
|
||||||
|
#endif
|
||||||
|
|
||||||
sequencedContents.remove(at: index)
|
sequencedContents.remove(at: index)
|
||||||
|
|
||||||
for (object, i) in contents {
|
for (object, i) in contents {
|
||||||
|
@ -150,10 +155,13 @@ public class OrderedSet<T: Hashable> {
|
||||||
public func removeAllObjects() {
|
public func removeAllObjects() {
|
||||||
contents.removeAll()
|
contents.removeAll()
|
||||||
|
|
||||||
for sequencedContent in sequencedContents {
|
for sequencedContent in sequencedContents {
|
||||||
sequencedContent.deallocate()
|
#if !swift(>=4.1)
|
||||||
}
|
sequencedContent.deallocate(capacity: 1)
|
||||||
|
#else
|
||||||
|
sequencedContent.deallocate()
|
||||||
|
#endif
|
||||||
|
}
|
||||||
sequencedContents.removeAll()
|
sequencedContents.removeAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1298,6 +1298,7 @@
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -1327,6 +1328,7 @@
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
@ -1397,6 +1399,7 @@
|
||||||
SUPPORTED_PLATFORMS = macosx;
|
SUPPORTED_PLATFORMS = macosx;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -1423,6 +1426,7 @@
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = macosx;
|
SUPPORTED_PLATFORMS = macosx;
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
@ -1454,6 +1458,7 @@
|
||||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3";
|
TARGETED_DEVICE_FAMILY = "1,2,3";
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.1;
|
TVOS_DEPLOYMENT_TARGET = 9.1;
|
||||||
};
|
};
|
||||||
|
@ -1486,6 +1491,7 @@
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3";
|
TARGETED_DEVICE_FAMILY = "1,2,3";
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.1;
|
TVOS_DEPLOYMENT_TARGET = 9.1;
|
||||||
};
|
};
|
||||||
|
@ -1519,6 +1525,7 @@
|
||||||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
};
|
};
|
||||||
|
@ -1551,6 +1558,7 @@
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
|
SWIFT_VERSION = 4.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue